I've setup Kubernetes with the steps below. Everything looks fine - but it's running on a single node/server.
Now I want to take the next step for running on multiple nodes. I wonder where should I configure my physical servers ip's so I could create the pod in more than one physical server.
I run:
hack/local-up-cluster.sh
then (In another 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
And:
cluster/kubectl.sh create -f run-aii.yaml
my 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
Additional info:
[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
Sounds like you want to setup a multi-node cluster, there are numerous ways to do that (http://kubernetes.io/docs/getting-started-guides/).
If you want a local solution on your machine, the vagrant way or the docker way is pretty straight forward.
If looking for a cloud, then GCE is the next easiest (https://cloud.google.com/container-engine/).
Once you have your multi-node cluster setup, then when you deploy your pod, it will be scheduled to a node in the cluster.
The only gotcha to be careful of given your manifest above, is you are using HostPaths
for all your volume mounts. This is fine when you know what machine you are running the pod on, however, you should be abstracting yourself away from that.
To better solve you'll need to look into some persistent volumes that are not host specific. BUT for now, you can get it working. =)