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

你可能感兴趣的:(k8s)