我已经按照以下步骤设置了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
我的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
答案 0 :(得分:1)
听起来您想要设置多节点群集,有很多方法可以做到这一点(http://kubernetes.io/docs/getting-started-guides/)。
如果你想在你的机器上使用本地解决方案,那么流浪者或者码头工作方式非常简单。
如果要寻找云,那么GCE是下一个最简单的(https://cloud.google.com/container-engine/)。
一旦设置了多节点群集,那么在部署pod时,它将被安排到群集中的节点。
唯一的 gotcha 要注意上面的清单,您是否正在使用HostPaths
进行所有卷安装。当您知道正在运行pod的机器时,这很好,但是,您应该将自己抽象出来。
为了更好地解决您,您需要查看一些非特定于主机的持久性卷。但是现在,你可以让它运作起来。 =)