k8s对象管理三种模式
kubectl 安装
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/linux/amd64/kubectl
验证:
kubectl cluster-info
1.命令式命令 Imperative commands 建议开发项目使用
kubectl run ningx —image nginx
kubectl create deployment nginx —images nginx
2.命令式对象配置 Imperative object configuration 建议生产环境使用
kubectl create -f nginx.yaml
kubectl delete -f nginx.yaml -f redis.yaml
kubectl replace -f nginx.yaml
3.声明式对象配置 Declarative object configuration 建议生产环境使用
文件处理方式
kubectl diff -f configs/
kubectl apply -f configs/
文件夹处理方式
kubectl diff -R -f configs/
kubectl apply -R -f configs/
4.节点调度
kubectl cordon $NODENAME 设置后可以控制k8s不再调度新的pod到这个节点上。要解除限制用uncordon 。