这篇笔记的作用是整理一下近几天学习过的K8s命令。然后将机器清空,安装KubeSphere,练习可视化使用。后面真的要接触K8s相关东西,更多的应该也是操作图形化工具吧。
1.Yaml的应用和删除
你永远可以相信yaml 不论是创建Pod,Deployment,Service, PV,PVC,ConfigMap
kubectl apply -f xxx.yaml
kubectl delete -f xxx.yaml
2.Pod相关命令
#查询
kubectl get pod
kubectl get pod -n default
kubectl get pod -A
kubectl get pod -owide #明细
kubectl logs pod xxx
kubectl describe pod xxx
kubectl edit pod xxx
kubectl delete pod xxx
kubectl run pod名称 --image=镜像名称
kubectl run nginxpod --image=nginx
3.NameSpace相关命令
kubectl create ns hellons
kubectl get ns
kubectl delete ns hellons
4.Deployment相关命令
kubectl create deployment mytomcat --image=tomcat:8.5.68 --replicas=3
kubectl create deploy mytomcat --image=tomcat:8.5.68 --replicas=3
kubectl get deploy
kubectl get deploy -A
kubectl get deploy -n default
kubectl get deploy -owide
kubectl describe deploy xxx
kubectl delete deploy xxx
kubectl edit deploy xxxx
5.Service相关命令
kubectl expose deployment my-dep --port=8000 --target-port=80
kubectl expose deployment my-dep --port=8000 --target-port=80 --type=ClusterIP
kubectl expose deployment my-dep --port=8000 --target-port=80 --type=NodePort
kubectl get svc
kubectl describe svc xxx
kubectl edit svc xxx
kubectl delete svc xxx
6.Ingress规则相关命令
kubectl get ingress
kubectl describe ingress xxx
kubectl edit ingress xx
kubectl delete ingress xxx
7.PV相关命令
kubectl get pv
kubectl describe pv xx
kubectl edit pv xxx
kubectl delete pv xxx
8.PVC相关命令
kubectl get pvc
kubectl describe pvc xx
kubectl edit pvc xxx
kubectl delete pvc xxx
9.ConfigMap相关命令
kubectl create cm redis-conf --from-file=redis.conf
kubectl get cm
kubectl describe cm xx
kubectl edit cm xxx
kubectl delete cm xxx