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