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

标签 docker kubernetes

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

现在,我要执行在多个节点上运行的下一步。我想知道应该在哪里配置物理服务器ip,以便可以在多个物理服务器中创建容器。

我跑:

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

我的run-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

最佳答案

听起来好像您想设置一个多节点集群,有很多方法可以做到(http://kubernetes.io/docs/getting-started-guides/)。

如果您希望在计算机上使用本地解决方案,那么无所事事的方式或docker的方式都非常简单。

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

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

上面给出的 list 是唯一需要注意的陷阱,因为所有卷挂载都使用HostPaths。当您知道运行Pod的计算机时,这很好,但是,您应该从中抽象出来。

为了更好地解决问题,您需要研究一些与主机无关的持久卷。但现在,您可以使其正常运行。 =)

关于docker - kubernetes设置所有物理节点的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37511020/

相关文章:

php - mysql>源backupfile.sql对我不起作用

kubernetes - kubectl 命令在空闲几分钟后断开连接

openshift - 在 Kubernetes/OpenShift 中的容器之间共享持久卷声明

amazon-web-services - AWS EKS : Assign multiple Service Accounts to Deployment\Pod

node.js - Jenkins 、Docker、Kubernetes、AWS EKS : RUN npm install either hangs or produces EAI_AGAIN

google-app-engine - 使用 Docker 的 gcloud auth 登录不能像文档中所说的那样工作

mongodb - 由Docker-Compose启动的Mongo-Express导致错误[MongoError]:首次连接时无法连接到服务器[mongo:27017]

linux - 如何管理/轮换/删除 mesos 日志

kubernetes - argocd 应用程序在 CI 管道中创建(GitHub Actions、Tekton...)抛出 "PermissionDenied desc = permission denied: applications, create, default/myapp"

docker - jenkins管道中docker gcloud容器中的kubectl问题