apiVersion: v1 kind: ReplicationController metadata: name: myapp-rc labels: app: myapp type: front-end spec: template: #ниже начинается описание пода metadata: name: myapp-pod #string labels: app: myapp anyKey: AnyValue spec: containers: #List/Array - name: nginx-container image: nginx resources: {} restartPolicy: Always replicas: 2 #указать количество экземпляров
Применение:
kubectl create -f rd-definition.yaml
Получить сведения:
kubectl get replicationcontroller
apiVersion: apps/v1 kind: ReplicaSet metadata: name: myapp-replicaset labels: app: myapp type: front-end spec: template: metadata: name: myapp-pod #string labels: app: myapp anyKey: anyValue spec: containers: - image: nginx name: myapp replicas: 3 selector: matchLabels: # совпадение меток от ПОДов anyKey: anyValue
kubectl create -f rs-definition.yaml
Получить список реплик:
kubectl get replicasets.apps
Изменить количество реплик:
kubectl scale --replicas=3 rs/myapp-replicaset