千家信息网

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

发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,这篇文章主要介绍了Kubernetes实用的自动化运维脚本有哪些,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。findEmptyNam
千家信息网最后更新 2025年02月01日Kubernetes实用的自动化运维脚本有哪些

这篇文章主要介绍了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

-n | --namespace : Namespace to analyse. Default: default
-p | --pod : Pod to analyse.
-d | --duration : Duration of sampling. Default: 0 (infinite)
-i | --interval : Interval between samples. Default: 5
-o | --output : Output file. Default: top-.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

-n | --namespace : Namespace to analyse. Default: --all-namespaces
-o | --output : 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

-n | --namespace : Namespace to analyse. Default: --all-namespaces
-o | --output : 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实用的自动化运维脚本有哪些"这篇文章对大家有帮助,同时也希望大家多多支持,关注行业资讯频道,更多相关知识等着你来学习!

0