脚本如下123456789101112131415161718192021#!/bin/bashsource /etc/rc.d/init.d/functionsset -euo pipefailexport PATH=/opt/kube/bin:$PATHsecret_name=test-comcert_name=test.com.crtkey_name=test.com.keyif [ "$#" == 0 ];then for ns in `kubectl get ns|grep -v "NAME\|kube-*"|awk '{print $1}'`;do kubectl create secret tls $secret_name --cert=$cert_name --key=$key_name -n $ns --dry-run=client -o yaml |kubectl apply -f - action $ns true doneelse for ns in $@;do kubectl create secret tls $secret_name --cert=$cert_name --key=$key_name -n $ns --dry-run=client -o yaml |kubectl apply -f - action $ns true donefi