linux怎么查看本机内存大小
377
2022-09-12
从 k8s 上卸载 KubeSphere
您可以使用 kubesphere-delete.sh 将 KubeSphere 从您现有的 Kubernetes 集群中卸载。复制 GitHub 源文件并在本地机器上执行此脚本。警告: 卸载意味着 KubeSphere 会从您的 Kubernetes 集群中移除。此操作不可逆并且没有任何备份,请谨慎操作。#!/usr/bin/env bashfunction delete_sure(){ cat << eof$(echo -e "\033[1;36mNote:\033[0m")Delete the KubeSphere cluster, including the module kubesphere-system kubesphere-devops-system kubesphere-monitoring-system kubesphere-logging-system openpitrix-system.eofread -p "Please reconfirm that you want to delete the KubeSphere cluster. (yes/no) " answhile [[ "x"$ans != "xyes" && "x"$ans != "xno" ]]; do read -p "Please reconfirm that you want to delete the KubeSphere cluster. (yes/no) " ansdoneif [[ "x"$ans == "xno" ]]; then exitfi}delete_sure# delete ks-installkubectl delete deploy ks-installer -n kubesphere-system 2>/dev/null# delete helmfor namespaces in kubesphere-system kubesphere-devops-system kubesphere-monitoring-system kubesphere-logging-system openpitrix-systemdo helm list -n $namespaces | grep -v NAME | awk '{print $1}' | sort -u | xargs -r -L1 helm uninstall -n $namespaces 2>/dev/nulldone# delete kubefedkubectl get cc -n kubesphere-system ks-installer -o jsonpath="{.status.multicluster}" | grep enableif [[ $? -eq 0 ]]; then helm uninstall -n kube-federation-system kubefed 2>/dev/null #kubectl delete ns kube-federation-system 2>/dev/nullfihelm uninstall -n kube-system snapshot-controller 2>/dev/null# delete kubesphere deploymentkubectl delete deployment -n kubesphere-system `kubectl get deployment -n kubesphere-system -o jsonpath="{.items[*].metadata.name}"` 2>/dev/null# delete monitor statefulsetkubectl delete prometheus -n kubesphere-monitoring-system k8s 2>/dev/nullkubectl delete statefulset -n kubesphere-monitoring-system `kubectl get statefulset -n kubesphere-monitoring-system -o jsonpath="{.items[*].metadata.name}"` 2>/dev/nullkubectl --no-headers=true get pvc -n kubesphere-monitoring-system -o custom-columns=:metadata.namespace,:metadata.name | grep -E kubesphere-monitoring-system | xargs -n2 kubectl delete pvc -n 2>/dev/null# delete pvcpvcs="kubesphere-system|openpitrix-system|kubesphere-devops-system|kubesphere-logging-system"kubectl --no-headers=true get pvc --all-namespaces -o custom-columns=:metadata.namespace,:metadata.name | grep -E $pvcs | xargs -n2 kubectl delete pvc -n 2>/dev/null# delete rolebindingsdelete_role_bindings() { for rolebinding in `kubectl -n $1 get rolebindings -l iam.kubesphere.io/user-ref -o jsonpath="{.items[*].metadata.name}"` do kubectl -n $1 delete rolebinding $rolebinding 2>/dev/null done}# delete rolesdelete_roles() { kubectl -n $1 delete role admin 2>/dev/null kubectl -n $1 delete role operator 2>/dev/null kubectl -n $1 delete role viewer 2>/dev/null for role in `kubectl -n $1 get roles -l iam.kubesphere.io/role-template -o jsonpath="{.items[*].metadata.name}"` do kubectl -n $1 delete role $role 2>/dev/null done}# remove useless labels and finalizersfor ns in `kubectl get ns -o jsonpath="{.items[*].metadata.name}"`do kubectl label ns $ns kubesphere.io/workspace- kubectl label ns $ns kubesphere.io/namespace- kubectl patch ns $ns -p '{"metadata":{"finalizers":null,"ownerReferences":null}}' delete_role_bindings $ns delete_roles $nsdone# delete clustersfor cluster in `kubectl get clusters -o jsonpath="{.items[*].metadata.name}"`do kubectl patch cluster $cluster -p '{"metadata":{"finalizers":null}}' --type=mergedonekubectl delete clusters --all 2>/dev/null# delete workspacesfor ws in `kubectl get workspaces -o jsonpath="{.items[*].metadata.name}"`do kubectl patch workspace $ws -p '{"metadata":{"finalizers":null}}' --type=mergedonekubectl delete workspaces --all 2>/dev/null# delete devopsprojectsfor devopsproject in `kubectl get devopsprojects -o jsonpath="{.items[*].metadata.name}"`do kubectl patch devopsprojects $devopsproject -p '{"metadata":{"finalizers":null}}' --type=mergedonefor pip in `kubectl get pipeline -A -o jsonpath="{.items[*].metadata.name}"`do kubectl patch pipeline $pip -n `kubectl get pipeline -A | grep $pip | awk '{print $1}'` -p '{"metadata":{"finalizers":null}}' --type=mergedonefor s2ibinaries in `kubectl get s2ibinaries -A -o jsonpath="{.items[*].metadata.name}"`do kubectl patch s2ibinaries $s2ibinaries -n `kubectl get s2ibinaries -A | grep $s2ibinaries | awk '{print $1}'` -p '{"metadata":{"finalizers":null}}' --type=mergedonefor s2ibuilders in `kubectl get s2ibuilders -A -o jsonpath="{.items[*].metadata.name}"`do kubectl patch s2ibuilders $s2ibuilders -n `kubectl get s2ibuilders -A | grep $s2ibuilders | awk '{print $1}'` -p '{"metadata":{"finalizers":null}}' --type=mergedonefor s2ibuildertemplates in `kubectl get s2ibuildertemplates -A -o jsonpath="{.items[*].metadata.name}"`do kubectl patch s2ibuildertemplates $s2ibuildertemplates -n `kubectl get s2ibuildertemplates -A | grep $s2ibuildertemplates | awk '{print $1}'` -p '{"metadata":{"finalizers":null}}' --type=mergedonefor s2iruns in `kubectl get s2iruns -A -o jsonpath="{.items[*].metadata.name}"`do kubectl patch s2iruns $s2iruns -n `kubectl get s2iruns -A | grep $s2iruns | awk '{print $1}'` -p '{"metadata":{"finalizers":null}}' --type=mergedonekubectl delete devopsprojects --all 2>/dev/null# delete validatingwebhookconfigurationsfor webhook in ks-events-admission-validate users.iam.kubesphere.io network.kubesphere.io validating-webhook-configurationdo kubectl delete validatingwebhookconfigurations.admissionregistration.k8s.io $webhook 2>/dev/nulldone# delete mutatingwebhookconfigurationsfor webhook in ks-events-admission-mutate logsidecar-injector-admission-mutate mutating-webhook-configurationdo kubectl delete mutatingwebhookconfigurations.admissionregistration.k8s.io $webhook 2>/dev/nulldone# delete usersfor user in `kubectl get users -o jsonpath="{.items[*].metadata.name}"`do kubectl patch user $user -p '{"metadata":{"finalizers":null}}' --type=mergedonekubectl delete users --all 2>/dev/null# delete crdsfor crd in `kubectl get crds -o jsonpath="{.items[*].metadata.name}"`do if [[ $crd == *kubesphere.io ]]; then kubectl delete crd $crd 2>/dev/null; fidone# delete relevance nsfor ns in kubesphere-alerting-system kubesphere-controls-system kubesphere-devops-system kubesphere-logging-system kubesphere-monitoring-system openpitrix-system kubesphere-systemdo kubectl delete ns $ns 2>/dev/nulldone
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~