第二个'规范'的目的

时间:2018-03-17 22:36:00

标签: kubernetes kubectl

我对这个kubernetes yaml文件有点困惑。第一个'规范'表示需要一直有3个副本。

“容器”上面的第二个“规格”怎么样?此外,模板的作用是什么?

apiVersion: v1
kind: ReplicationController
metadata:
  name: node-js
  labels:
    name: node-js
spec:
 replicas: 3
 selector:
   name: node-js
 template:
metadata:
 labels:
 name: node-js
 spec:
 containers:
 - name: node-js
   image: jonbaier/node-express-info:latest
   ports:
    - containerPort: 80

1 个答案:

答案 0 :(得分:0)

第一个规范是ReplicationController本身的设置。

其中名为“template”和“spec”的块是pod template,其中包含要由复制控制器运行的pod配置:

apiVersion: v1 kind: ReplicationController metadata: name: node-js labels: name: node-js spec: # related to ReplicationController itself replicas: 3 # value 3 mean that you want to launch 3 replicas of a pod selector: name: node-js template: # section with a pod template metadata: labels: name: node-js spec: # related to a container you want to run containers: - name: node-js image: jonbaier/node-express-info:latest ports: - containerPort: 80