Kubernetes之ReplicaSet

Replicaset在继承Pod的所有特性的同时, 它可以利用预先创建好的模板定义副本数量并自动控制, 通过改变Pod副本数量实现Pod的扩容和缩容

缺点: 无法修改template模板, 也就无法发布新的镜像版本

1.创建Replicaset

# vi replicaset.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: demo-rc
  labels:
    app: demo-rc
spec:
  replicas: 2
  selector:
    matchLabels:
      app: demo-rc
  template:
    metadata:
      labels:
        app: demo-rc
    spec:
      containers:
      - name: httpd
        image: httpd
        imagePullPolicy: Always

# kubectl create -f replicaset.yaml

2.查看replicaset

# kubectl get replicaset
NAME      READY     STATUS    RESTARTS   AGE
demo-rc    1/1       Running      0       8d
# kubectl describe replicaset
...

3.删除replicaset

# kubectl delete replicaset demo-rc






发表于: 13天前   最后更新时间: 13天前   游览量:51
上一条: Kubernetes之Pod
下一条: Kubernetes之Deployment

评论…


  • 评论…
    • in this conversation