1. 这篇笔记的作用是整理一下近几天学习过的K8s命令。然后将机器清空,安装KubeSphere,练习可视化使用。后面真的要接触K8s相关东西,更多的应该也是操作图形化工具吧。

1.Yaml的应用和删除

你永远可以相信yaml 不论是创建Pod,Deployment,Service, PV,PVC,ConfigMap

  1. kubectl apply -f xxx.yaml
  2. kubectl delete -f xxx.yaml

2.Pod相关命令

  1. #查询
  2. kubectl get pod
  3. kubectl get pod -n default
  4. kubectl get pod -A
  5. kubectl get pod -owide #明细
  6. kubectl logs pod xxx
  7. kubectl describe pod xxx
  8. kubectl edit pod xxx
  9. kubectl delete pod xxx
  10. kubectl run pod名称 --image=镜像名称
  11. kubectl run nginxpod --image=nginx

3.NameSpace相关命令

  1. kubectl create ns hellons
  2. kubectl get ns
  3. kubectl delete ns hellons

4.Deployment相关命令

  1. kubectl create deployment mytomcat --image=tomcat:8.5.68 --replicas=3
  2. kubectl create deploy mytomcat --image=tomcat:8.5.68 --replicas=3
  3. kubectl get deploy
  4. kubectl get deploy -A
  5. kubectl get deploy -n default
  6. kubectl get deploy -owide
  7. kubectl describe deploy xxx
  8. kubectl delete deploy xxx
  9. kubectl edit deploy xxxx

5.Service相关命令

  1. kubectl expose deployment my-dep --port=8000 --target-port=80
  2. kubectl expose deployment my-dep --port=8000 --target-port=80 --type=ClusterIP
  3. kubectl expose deployment my-dep --port=8000 --target-port=80 --type=NodePort
  4. kubectl get svc
  5. kubectl describe svc xxx
  6. kubectl edit svc xxx
  7. kubectl delete svc xxx

6.Ingress规则相关命令

  1. kubectl get ingress
  2. kubectl describe ingress xxx
  3. kubectl edit ingress xx
  4. kubectl delete ingress xxx

7.PV相关命令

  1. kubectl get pv
  2. kubectl describe pv xx
  3. kubectl edit pv xxx
  4. kubectl delete pv xxx

8.PVC相关命令

  1. kubectl get pvc
  2. kubectl describe pvc xx
  3. kubectl edit pvc xxx
  4. kubectl delete pvc xxx

9.ConfigMap相关命令

  1. kubectl create cm redis-conf --from-file=redis.conf
  2. kubectl get cm
  3. kubectl describe cm xx
  4. kubectl edit cm xxx
  5. kubectl delete cm xxx