2016-05-29 24 views
1

我已經按照以下步驟設置了Kubernetes。一切看起來都很好 - 但它運行在單個節點/服務器上。kubernetes設置所有物理節點的列表

現在我想要在多個節點上運行下一步。我想知道我應該在哪裏配置我的物理服務器ip,以便我可以在多個物理服務器上創建該pod。

我運行:

hack/local-up-cluster.sh 

然後(在另一端):

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 

附加信息:

[[email protected] kubernetes]$ cluster/kubectl.sh get pod 
NAME     READY  STATUS RESTARTS AGE 
aii-3934754246-yilg3 2/2  Running 0   59s 

[[email protected] 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 

回答

1

聽起來像是你想設置一個多節點集羣,有很多方法可以做到這一點(http://kubernetes.io/docs/getting-started-guides/)。

如果你想在你的機器上使用本地解決方案,流浪者的方式或碼頭方式非常簡單。

如果要查找雲,那麼GCE是下一個最簡單的(https://cloud.google.com/container-engine/)。

一旦你完成了多節點集羣設置,那麼當你部署你的pod時,它將被安排到集羣中的一個節點。

唯一的gotcha要小心給定您的清單上面,你是使用HostPaths所有你的卷掛載。當你知道你在運行什麼機器時,這很好,但是,你應該抽離自己。

爲了更好地解決問題,您需要查看一些非主機特定的持久卷。但現在,你可以得到它的工作。 =)