in ~/.bashrc
alias kubewatch='watch -n 1 -d kubectl get ingress,svc,deploy,po'
adhoc way
$ kubectl create deployment nginx --image=nginx
$ kubectl expose deployment/nginx --port=80
$ kubectl get svc,deploy,po -l app=nginx
$ kubectl edit <the resource>
$ kubectl get deployment nginx -o yaml
$ kubectl scale deployment nginx --replicas=3
$ kubectl set image deploy nginx=nginx:1.9.1 --all
$ kubectl set image deploy nginx=nginx:1.12.1-alpine --all
$ kubectl rollout history deploy nginx
$ kubectl rollout history deploy nginx --revision=2
$ kubectl rollout undo deploy/nginx --revision=1
先看一個乾淨的 deployment,快速得到的方式:
$ kubectl create deployment nginx --image=nginx --dry-run -o yaml > nginx-deploy.yaml
命名 nginx-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
然後改成 daemonset,命名 nginx-daemon.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: nginx
name: nginx
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
查看兩個檔案的差異
$ diff nginx-deploy.yaml nginx-daemon.yaml
2c2
< kind: Deployment
---
> kind: DaemonSet
8d7
< replicas: 2
確認 daemonset 是否部署在每個 node 上