k8s 使用Replication Controller创建管理pod的简单范例
[root@v75 yml]# cat rc1.yaml apiVersion: v1kind: ReplicationControllermetadata: name: my-nginxspec: replicas: 2 selector: app: nginx template: metadata: labels: app: ...
[root@v75 yml]# cat rc1.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: my-nginx
spec:
replicas: 2
selector:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
按照replicas: 2指定的数量,启动2个pod
手动删除一个pod,马上有一个新的pod被创建,与replicas: 2指定的数量保持一致
扩容Pod副本数量:
[root@v76 yml]# kubectl scale replicationcontroller my-nginx --replicas=3
replicationcontroller/my-nginx scaled
创建的过程:
减少Pod副本的数量:
[root@v76 yml]# kubectl scale replicationcontroller my-nginx --replicas=1
replicationcontroller/my-nginx scaled
更多推荐
所有评论(0)