温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Kubernetes实用的自动化运维脚本有哪些

发布时间:2021-11-08 11:21:34 来源:亿速云 阅读:117 作者:小新 栏目:云计算

这篇文章主要介绍了Kubernetes实用的自动化运维脚本有哪些,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。


 

findEmptyNamespaces.sh

遍历集群中的所有名称空间并找到空的namespace

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

getPodsTopCSV.sh

获取以CSV格式文件编写的Pod的cpu和内存使用情况

???? ???? ./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格式获取每个容器的所有容器资源请求和限制,并对其值进行标准化。CSV格式非常易于自动化,非常适合粘贴到Excel进行进一步处理。


???? ???? ./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是否真的准备就绪的简单脚本。检查状态为“正在运行”,并且所有容器均已准备就绪。如果准备就绪,则返回0。如果尚未准备就绪,则返回1。

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

感谢你能够认真阅读完这篇文章,希望小编分享的“Kubernetes实用的自动化运维脚本有哪些”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI