k8s資源的常見操作:
kubectl create -f test.yaml
kubectl get pod|rc
kubectl describe pod nginx
kubectl delete pod nginx 或者 kubectl delete -f test.yaml
kubectl edit pod nginx
創建rc
[root@k8s-master ~]
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx
spec:
replicas: 5
selector:
app: myweb
template:
metadata:
labels:
app: myweb
spec:
containers:
- name: myweb
image: 10.0.0.11:5000/nginx:1.13
ports:
- containerPort: 80
rc滾動升級
[root@k8s-master ~]
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx2
spec:
replicas: 5
selector:
app: myweb2
template:
metadata:
labels:
app: myweb2
spec:
containers:
- name: myweb
image: 10.0.0.11:5000/nginx:1.16
ports:
- containerPort: 80
升級
kubectl rolling-update nginx -f rc_update.yaml --update-period=10s
--update-period=10s
回滾
kubectl rolling-update nginx2 -f rc_1.13.yaml --update-period=1s