kuberneter常用运维命令持续学习更新中

1.彻底删除当前k8s版本

systemctl stop kubelet
systemctl stop etcd
systemctl stop docker

kubeadm reset -f
yum list installed | grep kube

yum -y remove kube*

yum list installed | grep kube
yum -y remove cri-tools.x86_64
yum list installed | grep kube

yum -y remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
rm -rf /var/lib/docker
rm -rf /var/lib/containerd

rm -rvf $HOME/.kube
rm -rvf ~/.kube/
rm -rvf /etc/kubernetes/
rm -rvf /etc/systemd/system/kubelet.service.d
rm -rvf /etc/systemd/system/kubelet.service
rm -rvf /usr/bin/kube*
rm -rvf /etc/cni
rm -rvf /opt/cni
rm -rvf /var/lib/etcd
rm -rvf /var/etcd

systemctl status docker
systemctl | grep kube
yum list installed | grep kube
yum list installed | docker
rpm -qa | grep kube
rpm -qa | grep docker

2.删除已部署
namespace
kubectl get namespace

	kubectl create namespace mydlqcloud
	
pod
	kubectl describe pod mysql-8cb4fd7b-kk596 --namespace=mysql
services
	如下命令可列出所有在命名空间内创建的所有服务
	kubectl get svc --all-namespaces -o wide
	kubectl get services --all-namespaces -o wide
	
	让我们描述一下该服务,以便快速理解其功能
	kubectl describe svc my-dep-svc --namespace=webapps
	
	方法1:使用 kubectl delete 命令删除服务
	kubectl delete svc --namespace=default nginx-hush
	
pv
	kubectl get --all-namespaces pv
	kubectl delete pv mysql
pvc
	kubectl get --all-namespaces pvc
	kubectl delete pvc es-local-pvc1 -n test-logging
	
	kubectl describe pvc pvc-mysql-01 --namespace=default
	
	问题一:storageclass.storage.k8s.io "rook-ceph-block" not found
		解决:https://www.5axxw.com/questions/simple/sed06p
	
	kubectl apply -f 
	
Deployment
	无状态:
	kubectl get deployments:获取所有deployments
	kubectl get deployment mysql -n mydlqcloud
	
	kubectl delete deployment ${name}:删除命令
	kubectl delete deployment mysql-01
	kubectl delete deployment mysql -n mydlqcloud
	
	有状态:
	kubectl get StatefulSets -A:获取所有列表
	kubectl delete StatefulSet ${name}:删除命令
	
	本例操作
	kubectl delete StatefulSet nacos

3.执行yaml
kubectl apply -f mysql_ns.yaml
kubectl apply -f mysql_pvc.yaml
kubectl apply -f mysql_svc.yaml
kubectl apply -f mysql_deploy.yaml

4.部署mysql ms
kubectl apply -f mysql-conf.yaml
kubectl apply -f mysql-pv.yaml
kubectl apply -f mysql-pvc.yaml
kubectl apply -f mysql-service.yaml
kubectl apply -f mysql-ss.yaml

kubectl create -f mysql-conf.yaml
kubectl create -f mysql-pv.yaml
kubectl create -f mysql-pvc.yaml
kubectl create -f mysql-service.yaml
kubectl create -f mysql-ss.yaml

5.kubectl create -f mysql-config.yaml -n mydlqcloud

6.删除pod\pvc\pv
一般删除步骤为:先删pod再删pvc最后删pv

kubectl patch pvc redis-pv -p ‘{“metadata”:{“finalizers”:null}}’

kubectl patch pv redis-pv -p ‘{“metadata”:{“finalizers”:null}}’

你可能感兴趣的:(kuberneter,运维,学习,kubernetes)