Linux從入門到放棄 k8s ReplicationController資源

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 ~]# vim rc.yml
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx
spec:
  replicas: 5  #副本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 ~]# vim rc_update.yml
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx2
spec:
  replicas: 5  #副本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 # 間隔時間 默認60s

回滾

kubectl rolling-update nginx2 -f rc_1.13.yaml --update-period=1s
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章