kubernetes设置所有物理节点的列表

我已经按照以下步骤设置了Kubernetes。 一切看起来都不错 – 但它运行在单个节点/服务器上。

现在我想要在多个节点上运行下一步。 我想知道我应该在哪里configuration我的物理服务器的ip,所以我可以在多个物理服务器上创buildpod。

我运行:

hack/local-up-cluster.sh 

然后(在另一个terminal):

 cluster/kubectl.sh config set-cluster local --server=http://127.0.0.1:8080 --insecure-skip-tls-verify=true cluster/kubectl.sh config set-context local --cluster=local cluster/kubectl.sh config use-context local 

和:

 cluster/kubectl.sh create -f run-aii.yaml 

我的跑步aii.yaml:

 apiVersion: extensions/v1beta1 kind: Deployment metadata: name: aii spec: replicas: 1 template: metadata: labels: run: aii spec: containers: - name: aii image: localhost:5000/dev/aii ports: - containerPort: 5144 env: - name: KAFKA_IP value: kafka volumeMounts: - mountPath: /root/script name: scripts-data readOnly: true - mountPath: /home/aii/core name: core-aii readOnly: false - mountPath: /home/aii/genome name: genome-aii readOnly: true - mountPath: /home/aii/main name: main-aii readOnly: false - name: kafka image: localhost:5000/dev/kafkazoo volumeMounts: - mountPath: /root/script name: scripts-data readOnly: true - mountPath: /root/config name: config-data readOnly: true volumes: - name: scripts-data hostPath: path: /home/aii/general/infra/script - name: config-data hostPath: path: /home/aii/general/infra/config - name: core-aii hostPath: path: /home/aii/general/core - name: genome-aii hostPath: path: /home/aii/general/genome - name: main-aii hostPath: path: /home/aii/general/main - mountPath: /home/aii/main name: main-aii readOnly: false - name: kafka image: localhost:5000/dev/kafkazoo volumeMounts: - mountPath: /root/script name: scripts-data readOnly: true - mountPath: /root/config name: config-data readOnly: true volumes: - name: scripts-data hostPath: path: /home/aii/general/infra/script - name: config-data hostPath: path: /home/aii/general/infra/config - name: core-aii hostPath: path: /home/aii/general/core - name: genome-aii hostPath: path: /home/aii/general/genome - name: main-aii hostPath: path: /home/aii/general/main 

附加信息:

 [aii@localhost kubernetes]$ cluster/kubectl.sh get pod NAME READY STATUS RESTARTS AGE aii-3934754246-yilg3 2/2 Running 0 59s [aii@localhost kubernetes]$ cluster/kubectl.sh describe pod aii-3934754246-yilg3 Name: aii-3934754246-yilg3 Namespace: default Node: 127.0.0.1/127.0.0.1 Start Time: Sun, 29 May 2016 16:58:20 +0300 Labels: pod-template-hash=3934754246,run=aii Status: Running IP: 172.17.0.4 Controllers: ReplicaSet/aii-3934754246 Containers: aii: Container ID: docker://71609cfd8e33c01a81a36770d12d884443a12b4c2969b95e3042d9dee4fb455b Image: localhost:5000/dev/aii Image ID: docker://sha256:7e70fbb724962b2f23c9439a1c00356deb551fd96ffd27a8afa6340fc903e735 Port: 5144/TCP QoS Tier: memory: BestEffort cpu: BestEffort State: Running Started: Sun, 29 May 2016 16:58:23 +0300 Ready: True Restart Count: 0 Environment Variables: KAFKA_IP: kafka kafka: Container ID: docker://6eb891e5968cf1106b26a9f3f7db881683a8e15dd59b1858435715580c90656c Image: localhost:5000/dev/kafkazoo Image ID: docker://sha256:b78e60582cbc8d3c4946807baf59552d110c7802c8204157e6fba509b96bc11c Port: QoS Tier: cpu: BestEffort memory: BestEffort State: Running Started: Sun, 29 May 2016 16:58:24 +0300 Ready: True Restart Count: 0 Environment Variables: Conditions: Type Status Ready True Volumes: scripts-data: Type: HostPath (bare host directory volume) Path: /home/aii/general/infra/script config-data: Type: HostPath (bare host directory volume) Path: /home/aii/general/infra/config core-aii: Type: HostPath (bare host directory volume) Path: /home/aii/general/core genome-aii: Type: HostPath (bare host directory volume) Path: /home/aii/general/genome main-aii: Type: HostPath (bare host directory volume) Path: /home/aii/general/main default-token-5z9rd: Type: Secret (a volume populated by a Secret) SecretName: default-token-5z9rd Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 1m 1m 1 {default-scheduler } Normal Scheduled Successfully assigned aii-3934754246-yilg3 to 127.0.0.1 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Pulling pulling image "localhost:5000/dev/aii" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Pulled Successfully pulled image "localhost:5000/dev/aii" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Created Created container with docker id 71609cfd8e33 1m 1m 1 {kubelet 127.0.0.1} spec.containers{aii} Normal Started Started container with docker id 71609cfd8e33 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Pulling pulling image "localhost:5000/dev/kafkazoo" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Pulled Successfully pulled image "localhost:5000/dev/kafkazoo" 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Created Created container with docker id 6eb891e5968c 1m 1m 1 {kubelet 127.0.0.1} spec.containers{kafka} Normal Started Started container with docker id 6eb891e5968c 

听起来你想要build立一个多节点集群,有很多方法可以做到这一点( http://kubernetes.io/docs/getting-started-guides/ )。

如果你想在你的机器上使用本地解决scheme,那么无用的方式或者docker的方式非常简单。

如果要查找云,那么GCE是下一个最简单的( https://cloud.google.com/container-engine/ )。

一旦完成了多节点集群的设置,那么当您部署pod时,它将被安排到集群中的一个节点。

在上面给出的清单中,唯一需要注意的是,您是否正在使用HostPaths进行所有卷装载。 当你知道什么机器在运行时,这很好,但是,你应该把自己从这个抽象出来。

为了更好地解决问题,您需要查看一些不是主机特定的持久性卷。 但现在,你可以得到它的工作。 =)