溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Kubernetes實用的自動化運維腳本有哪些

發(fā)布時間:2021-11-08 11:21:34 來源:億速云 閱讀:126 作者:小新 欄目:云計算

這篇文章主要介紹了Kubernetes實用的自動化運維腳本有哪些,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。


 

findEmptyNamespaces.sh

遍歷集群中的所有名稱空間并找到空的namespace

???? ???? ./findEmptyNamespaces.sh default
kube-public
online
test
   

getPodsTopCSV.sh

獲取以CSV格式文件編寫的Pod的cpu和內(nèi)存使用情況

???? ???? ./getPodsTopCSV.sh --help
./getPodsTopCSV.sh - Get formatted results of kubectl top pod in a Kubernetes cluster for a selected namespace and pod in a CSV format

Usage: ./getPodsTopCSV.sh <options>

-n | --namespace <name>                : Namespace to analyse.      Default: default
-p | --pod <name>                      : Pod to analyse.
-d | --duration <seconds>              : Duration of sampling.      Default: 0 (infinite)
-i | --interval <seconds>              : Interval between samples.  Default: 5
-o | --output <name>                   : Output file.               Default: top-<timestamp>.csv
-c | --containers                      : Output per container.      Default: off
-q | --quite                           : Don't output to screen.    Default: Output to screen
-h | --help                            : Show this usage
--no-headers                           : Don't print headers line

Examples:
========
Get for pod foo in namespace bar:                                $ ./getPodsTopCSV.sh --namespace bar --pod foo
Get for pod foo in namespace bar and output to file foo.csv :    $ ./getPodsTopCSV.sh --namespace bar --pod foo --output foo.csv
   

getResourcesCSV.sh

以CSV格式獲取每個容器的所有容器資源請求和限制,并對其值進(jìn)行標(biāo)準(zhǔn)化。CSV格式非常易于自動化,非常適合粘貼到Excel進(jìn)行進(jìn)一步處理。


???? ???? ./getResourcesCSV.sh --help

./getResourcesCSV.sh - Extract resource requests and limits in a Kubernetes cluster for a selected namespace or all namespaces in a CSV format

Usage: ./getResourcesCSV.sh <options>

-n | --namespace <name>                : Namespace to analyse.    Default: --all-namespaces
-o | --output <name>                   : Output file.             Default: resources.csv
-q | --quite                           : Don't output to screen.  Default: Output to screen
-h | --help                            : Show this usage
--no-headers                           : Don't print headers line

Examples:
========
Get all:                                                  $ ./getResourcesCSV.sh
Get for namespace foo:                                    $ ./getResourcesCSV.sh --namespace foo
Get for namespace foo and use output file bar.csv :       $ ./getResourcesCSV.sh --namespace foo --output bar.csv
   

getRestartingPods.sh

獲取在一個或多個容器中檢測到重新啟動的所有Pod(全部或單個命名空間)。格式為CSV。

???? ???? ./getRestartingPods.sh --help
./getRestartingPods.sh - Extract resource requests and limits in a Kubernetes cluster for a selected namespace or all namespaces in a CSV format

Usage: ./getRestartingPods.sh <options>

-n | --namespace <name>                : Namespace to analyse.    Default: --all-namespaces
-o | --output <name>                   : Output file.             Default: restarting.csv
-q | --quite                           : Don't output to screen.  Default: Output to screen
-h | --help                            : Show this usage
--no-headers                           : Don't print headers line

Examples:
========
Get all:                                                  $ ./getRestartingPods.sh
Get for namespace foo:                                    $ ./getRestartingPods.sh --namespace foo
Get for namespace foo and use output file bar.csv :       $ ./getRestartingPods.sh --namespace foo --output bar.csv
   

podReady.sh

檢查Pod是否真的準(zhǔn)備就緒的簡單腳本。檢查狀態(tài)為“正在運行”,并且所有容器均已準(zhǔn)備就緒。如果準(zhǔn)備就緒,則返回0。如果尚未準(zhǔn)備就緒,則返回1。

???? ???? ./podReady.sh kube-flannel-ds-lf87p kube-system

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“Kubernetes實用的自動化運維腳本有哪些”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識等著你來學(xué)習(xí)!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI