Kubernetes in Google Cloud – Part 2: kubernetes nodes

Following on from my previous post which stood up an etcd cluster, here’s how to add Kubernetes nodes which you can schedule Docker containers upon.

Note that the IP addresses will have changed from the previous post, as I’ve re-created the etcd cluster.

Kubernetes uses flannel to enable inter-node communications. This needs some configuration first, so log into one of your etcd nodes and create the network configuration entry.

local$ gcloud compute --project wavering-elk-132 ssh --zone europe-west1-b e1
e1$ etcdctl mk /coreos.com/network/config '{"Network":"10.200.0.0/16"}'

We need a Kubernetes cloud-config script to configure the coreos box.

coreos:
  update:
    reboot-strategy: off
  fleet:
    etcd_servers: http://10.240.184.134:4001,http://10.240.198.84:4001
    metadata: public_ip=$public_ipv4,private_ip=$private_ipv4,role=kubernetes
  units:
    - name: etcd.service
      mask: true
    - name: fleet.service
      command: start
    - name: setup-network-environment.service
      command: start
      content: |
        [Unit]
        Description=Setup Network Environment
        Documentation=https://github.com/kelseyhightower/setup-network-environment
        Requires=network-online.target
        After=network-online.target
 
        [Service]
        ExecStartPre=-/usr/bin/mkdir -p /opt/bin
        ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/snenv/setup-network-environment
        ExecStartPre=/usr/bin/chmod +x /opt/bin/setup-network-environment
        ExecStart=/opt/bin/setup-network-environment
        RemainAfterExit=yes
        Type=oneshot

[Service]
ExecStartPre=-/usr/bin/mkdir -p /opt/bin
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/snenv/setup-network-environment
ExecStartPre=/usr/bin/chmod +x /opt/bin/setup-network-environment
ExecStart=/opt/bin/setup-network-environment
RemainAfterExit=yes
Type=oneshot

Save this as kubernetes.yml.

You should change the etcd_servers line to match your etcd server addresses (you can grab them by curl’ing the discovery.token you created in the previous post, and changing 7001 to 4001 – to match the port number in the etcd cloud config).

The setup-network-environment service writes out some network configuration to a handy file.

I’ve also disabled the auto-upgrade feature of CoreOS.

Time to create some kubernetes nodes.

local$ gcloud --project wavering-elk-132 \\
    compute instances create k1 k2 k3 \\
    --image https://www.googleapis.com/compute/v1/projects/coreos-cloud/global/images/coreos-alpha-457-0-0-v20141002 \\
    --zone europe-west1-b \\
    --machine-type g1-small \\
    --metadata-from-file user-data=kubernetes.yml \\
    --metadata role=kubernetes

This creates 3 nodes called k1, k2 and k3. They’ll need a bit of time to boot up, but once there you should log in and check they can see the cluster, and confirm that the network configuration is set up.

local$ gcloud compute --project wavering-elk-132 ssh --zone europe-west1-b k1
k1$  fleetctl list-machines
MACHINE		IP		METADATA
4b2b1ea5...	10.240.87.134	private_ip=10.240.87.134,public_ip=146.148.116.88,role=kubernetes
55519ede...	10.240.57.139	private_ip=10.240.57.139,public_ip=104.155.11.47,role=kubernetes
614ce136...	104.155.1.171	private_ip=10.240.184.134,public_ip=104.155.1.171,role=etcd
aa1bd69f...	104.155.1.67	private_ip=10.240.198.84,public_ip=104.155.1.67,role=etcd
d9f6aeec...	10.240.250.41	private_ip=10.240.250.41,public_ip=104.155.10.114,role=kubernetes
k1$  etcdctl get /coreos.com/network/config
{"Network":"10.200.0.0/16"}

Once you’ve done that, you’ll want to grab a copy of kubecfg

k1$ sudo wget https://storage.googleapis.com/kubernetes/kubecfg -O /opt/bin/kubecfg
k1$ sudo chmod 0755 /opt/bin/kubecfg

And to start the flannel network stack (replace the etcd-endpoint entry with one of the etcd servers you used previously)

k1$ export FLEETCTL_ENDPOINT=http://10.240.184.134:4001
k1$ sudo mkdir –p /opt/kubernetes/services
k1$ sudo touch /opt/kubernetes/services/flannel.service
k1$ sudo chmod 666 /opt/kubernetes/services/flannel.service
k1$ cat << EOF > /opt/kubernetes/services/flannel.service
[Unit]
Requires=network-online.target
After=network-online.target
Description=flannel is an etcd backed overlay network for containers
 
[Service]
ExecStartPre=-/usr/bin/mkdir -p /opt/bin
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/flannel/flanneld
ExecStartPre=/usr/bin/chmod +x /opt/bin/flanneld
ExecStart=/opt/bin/flanneld -etcd-endpoint http://10.240.184.134:4001
 
[X-Fleet]
Global=true
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/flannel.service
k1$ fleetctl start /opt/kubernetes/services/flannel.service
k1$ ifconfig flannel0

[Service]
ExecStartPre=-/usr/bin/mkdir -p /opt/bin
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/flannel/flanneld
ExecStartPre=/usr/bin/chmod +x /opt/bin/flanneld
ExecStart=/opt/bin/flanneld -etcd-endpoint http://10.240.184.134:4001

[X-Fleet]
Global=true
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/flannel.service
k1$ fleetctl start /opt/kubernetes/services/flannel.service
k1$ ifconfig flannel0

… which should show you network adapter details (if not, something went wrong!)

You should create and start the Docker service.

k1$ sudo touch /opt/kubernetes/services/docker.service
k1$ sudo chmod 666 /opt/kubernetes/services/docker.service
k1$ cat << EOF > /opt/kubernetes/services/docker.service
[Unit]
After=flannel.service
Wants=flannel.service
Description=Docker Application Container Engine
Documentation=http://docs.docker.io
 
[Service]
EnvironmentFile=/run/flannel/subnet.env
ExecStartPre=/bin/mount --make-rprivate /
ExecStart=/usr/bin/docker -d --bip=\${FLANNEL_SUBNET} --mtu=\${FLANNEL_MTU} -s=btrfs -H fd://
 
[Install]
WantedBy=multi-user.target
 
[X-Fleet]
Global=true
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/docker.service
k1$ fleetctl start /opt/kubernetes/services/docker.service
k1$ fleetctl list-units
UNIT		MACHINE				ACTIVE	SUB
docker.service	4b2b1ea5.../10.240.87.134	active	running
docker.service	55519ede.../10.240.57.139	active	running
docker.service	d9f6aeec.../10.240.250.41	active	running
flannel.service	4b2b1ea5.../10.240.87.134	active	running
flannel.service	55519ede.../10.240.57.139	active	running
flannel.service	d9f6aeec.../10.240.250.41	active	running

[Service]
EnvironmentFile=/run/flannel/subnet.env
ExecStartPre=/bin/mount –make-rprivate /
ExecStart=/usr/bin/docker -d –bip=\${FLANNEL_SUBNET} –mtu=\${FLANNEL_MTU} -s=btrfs -H fd://

[Install]
WantedBy=multi-user.target

[X-Fleet]
Global=true
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/docker.service
k1$ fleetctl start /opt/kubernetes/services/docker.service
k1$ fleetctl list-units
UNIT MACHINE ACTIVE SUB
docker.service 4b2b1ea5…/10.240.87.134 active running
docker.service 55519ede…/10.240.57.139 active running
docker.service d9f6aeec…/10.240.250.41 active running
flannel.service 4b2b1ea5…/10.240.87.134 active running
flannel.service 55519ede…/10.240.57.139 active running
flannel.service d9f6aeec…/10.240.250.41 active running

You’ll want to start the kube-proxy and kubelet services which run on each Kubernetes node, and are responsible for running the containers and forwarding network traffic to containers which can handle them.

k1$ sudo touch /opt/kubernetes/services/kube-proxy.service
k1$ sudo chmod 666 /opt/kubernetes/services/kube-proxy.service
k1$ cat << EOF > /opt/kubernetes/services/kube-proxy.service
[Unit]
Description=Kubernetes Proxy
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
 
[Service]
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/proxy
ExecStartPre=/usr/bin/chmod +x /opt/bin/proxy
ExecStart=/opt/bin/proxy --etcd_servers=http://10.240.198.84:4001 --logtostderr=true
Restart=always
RestartSec=10
 
[X-Fleet]
Global=true
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-proxy.service
k1$ fleetctl start /opt/kubernetes/services/kube-proxy.service
k1$ sudo touch /opt/kubernetes/services/kube-kubelet.service
k1$ sudo chmod 666 /opt/kubernetes/services/kube-kubelet.service
k1$ cat << EOF > /opt/kubernetes/services/kube-kubelet.service
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=setup-network-environment.service
After=setup-network-environment.service
 
[Service]
EnvironmentFile=/etc/network-environment
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/kubelet
ExecStartPre=/usr/bin/chmod +x /opt/bin/kubelet
ExecStart=/opt/bin/kubelet \
  --address=0.0.0.0 \
  --port=10250 \
  --hostname_override=\${DEFAULT_IPV4} \
  --etcd_servers=http://10.240.198.84:4001 \
  --logtostderr=true
Restart=always
RestartSec=10
 
[X-Fleet]
Global=true
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-kubelet.service
k1$ fleetctl start /opt/kubernetes/services/kube-kubelet.service
k1$ fleetctl list-units
UNIT			MACHINE				ACTIVE	SUB
docker.service		4b2b1ea5.../10.240.87.134	active	running
docker.service		55519ede.../10.240.57.139	active	running
docker.service		d9f6aeec.../10.240.250.41	active	running
flannel.service		4b2b1ea5.../10.240.87.134	active	running
flannel.service		55519ede.../10.240.57.139	active	running
flannel.service		d9f6aeec.../10.240.250.41	active	running
kube-kubelet.service	4b2b1ea5.../10.240.87.134	active	running
kube-kubelet.service	55519ede.../10.240.57.139	active	running
kube-kubelet.service	d9f6aeec.../10.240.250.41	active	running
kube-proxy.service	4b2b1ea5.../10.240.87.134	active	running
kube-proxy.service	55519ede.../10.240.57.139	active	running
kube-proxy.service	d9f6aeec.../10.240.250.41	active	running

[Service]
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/proxy
ExecStartPre=/usr/bin/chmod +x /opt/bin/proxy
ExecStart=/opt/bin/proxy –etcd_servers=http://10.240.198.84:4001 –logtostderr=true
Restart=always
RestartSec=10

[X-Fleet]
Global=true
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-proxy.service
k1$ fleetctl start /opt/kubernetes/services/kube-proxy.service
k1$ sudo touch /opt/kubernetes/services/kube-kubelet.service
k1$ sudo chmod 666 /opt/kubernetes/services/kube-kubelet.service
k1$ cat << EOF > /opt/kubernetes/services/kube-kubelet.service
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=setup-network-environment.service
After=setup-network-environment.service

[Service]
EnvironmentFile=/etc/network-environment
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/kubelet
ExecStartPre=/usr/bin/chmod +x /opt/bin/kubelet
ExecStart=/opt/bin/kubelet \
–address=0.0.0.0 \
–port=10250 \
–hostname_override=\${DEFAULT_IPV4} \
–etcd_servers=http://10.240.198.84:4001 \
–logtostderr=true
Restart=always
RestartSec=10

[X-Fleet]
Global=true
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-kubelet.service
k1$ fleetctl start /opt/kubernetes/services/kube-kubelet.service
k1$ fleetctl list-units
UNIT MACHINE ACTIVE SUB
docker.service 4b2b1ea5…/10.240.87.134 active running
docker.service 55519ede…/10.240.57.139 active running
docker.service d9f6aeec…/10.240.250.41 active running
flannel.service 4b2b1ea5…/10.240.87.134 active running
flannel.service 55519ede…/10.240.57.139 active running
flannel.service d9f6aeec…/10.240.250.41 active running
kube-kubelet.service 4b2b1ea5…/10.240.87.134 active running
kube-kubelet.service 55519ede…/10.240.57.139 active running
kube-kubelet.service d9f6aeec…/10.240.250.41 active running
kube-proxy.service 4b2b1ea5…/10.240.87.134 active running
kube-proxy.service 55519ede…/10.240.57.139 active running
kube-proxy.service d9f6aeec…/10.240.250.41 active running

Next we start the API Server, Scheduler and Controller Manager which run together on a Kubernetes node in the cluster, managing the jobs for the Kubernetes cluster.

k1$ sudo touch /opt/kubernetes/services/kube-apiserver.service
k1$ sudo chmod 666 /opt/kubernetes/services/kube-apiserver.service
k1$ cat << EOF > /opt/kubernetes/services/kube-apiserver.service
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=setup-network-environment.service
After=setup-network-environment.service
 
[Service]
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/apiserver
ExecStartPre=/usr/bin/chmod +x /opt/bin/apiserver
ExecStart=/opt/bin/apiserver \
  --address=0.0.0.0 \
  --port=8080 \
  --etcd_servers=http://10.240.198.84:4001 \
  --logtostderr=true
Restart=always
RestartSec=10
 
[X-Fleet]
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-apiserver.service
k1$ fleetctl start /opt/kubernetes/services/kube-apiserver.service
k1$ sudo touch /opt/kubernetes/services/kube-scheduler.service
k1$ sudo chmod 666 /opt/kubernetes/services/kube-scheduler.service
k1$ cat << EOF > /opt/kubernetes/services/kube-scheduler.service
[Unit]
Description=Kubernetes Scheduler Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=setup-network-environment.service
After=setup-network-environment.service
 
[Service]
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/scheduler
ExecStartPre=/usr/bin/chmod +x /opt/bin/scheduler
ExecStart=/opt/bin/scheduler --master=127.0.0.1:8080
Restart=always
RestartSec=10
 
[X-Fleet]
MachineOf=kube-apiserver.service
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-scheduler.service
k1$ fleetctl start /opt/kubernetes/services/kube-scheduler.service
k1$ sudo touch /opt/kubernetes/services/kube-controller-manager.service
k1$ sudo chmod 666 /opt/kubernetes/services/kube-controller-manager.service
k1$ cat << EOF > /opt/kubernetes/services/kube-controller-manager.service
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=setup-network-environment.service
After=setup-network-environment.service
 
[Service]
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/controller-manager
ExecStartPre=/usr/bin/chmod +x /opt/bin/controller-manager
ExecStart=/opt/bin/controller-manager \
  --master=127.0.0.1:8080 \
  --logtostderr=true
Restart=always
RestartSec=10
 
[X-Fleet]
MachineOf=kube-apiserver.service
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-controller-manager.service
k1$ fleetctl start /opt/kubernetes/services/kube-controller-manager.service
k1$ fleetctl list-units
UNIT				MACHINE				ACTIVE	SUB
docker.service			4b2b1ea5.../10.240.87.134	active	running
docker.service			55519ede.../10.240.57.139	active	running
docker.service			d9f6aeec.../10.240.250.41	active	running
flannel.service			4b2b1ea5.../10.240.87.134	active	running
flannel.service			55519ede.../10.240.57.139	active	running
flannel.service			d9f6aeec.../10.240.250.41	active	running
kube-apiserver.service		4b2b1ea5.../10.240.87.134	active	running
kube-controller-manager.service	4b2b1ea5.../10.240.87.134	active	running
kube-kubelet.service		4b2b1ea5.../10.240.87.134	active	running
kube-kubelet.service		55519ede.../10.240.57.139	active	running
kube-kubelet.service		d9f6aeec.../10.240.250.41	active	running
kube-proxy.service		4b2b1ea5.../10.240.87.134	active	running
kube-proxy.service		55519ede.../10.240.57.139	active	running
kube-proxy.service		d9f6aeec.../10.240.250.41	active	running
kube-scheduler.service		4b2b1ea5.../10.240.87.134	active	running

[Service]
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/apiserver
ExecStartPre=/usr/bin/chmod +x /opt/bin/apiserver
ExecStart=/opt/bin/apiserver \
–address=0.0.0.0 \
–port=8080 \
–etcd_servers=http://10.240.198.84:4001 \
–logtostderr=true
Restart=always
RestartSec=10

[X-Fleet]
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-apiserver.service
k1$ fleetctl start /opt/kubernetes/services/kube-apiserver.service
k1$ sudo touch /opt/kubernetes/services/kube-scheduler.service
k1$ sudo chmod 666 /opt/kubernetes/services/kube-scheduler.service
k1$ cat << EOF > /opt/kubernetes/services/kube-scheduler.service
[Unit]
Description=Kubernetes Scheduler Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=setup-network-environment.service
After=setup-network-environment.service

[Service]
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/scheduler
ExecStartPre=/usr/bin/chmod +x /opt/bin/scheduler
ExecStart=/opt/bin/scheduler –master=127.0.0.1:8080
Restart=always
RestartSec=10

[X-Fleet]
MachineOf=kube-apiserver.service
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-scheduler.service
k1$ fleetctl start /opt/kubernetes/services/kube-scheduler.service
k1$ sudo touch /opt/kubernetes/services/kube-controller-manager.service
k1$ sudo chmod 666 /opt/kubernetes/services/kube-controller-manager.service
k1$ cat << EOF > /opt/kubernetes/services/kube-controller-manager.service
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=setup-network-environment.service
After=setup-network-environment.service

[Service]
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/controller-manager
ExecStartPre=/usr/bin/chmod +x /opt/bin/controller-manager
ExecStart=/opt/bin/controller-manager \
–master=127.0.0.1:8080 \
–logtostderr=true
Restart=always
RestartSec=10

[X-Fleet]
MachineOf=kube-apiserver.service
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-controller-manager.service
k1$ fleetctl start /opt/kubernetes/services/kube-controller-manager.service
k1$ fleetctl list-units
UNIT MACHINE ACTIVE SUB
docker.service 4b2b1ea5…/10.240.87.134 active running
docker.service 55519ede…/10.240.57.139 active running
docker.service d9f6aeec…/10.240.250.41 active running
flannel.service 4b2b1ea5…/10.240.87.134 active running
flannel.service 55519ede…/10.240.57.139 active running
flannel.service d9f6aeec…/10.240.250.41 active running
kube-apiserver.service 4b2b1ea5…/10.240.87.134 active running
kube-controller-manager.service 4b2b1ea5…/10.240.87.134 active running
kube-kubelet.service 4b2b1ea5…/10.240.87.134 active running
kube-kubelet.service 55519ede…/10.240.57.139 active running
kube-kubelet.service d9f6aeec…/10.240.250.41 active running
kube-proxy.service 4b2b1ea5…/10.240.87.134 active running
kube-proxy.service 55519ede…/10.240.57.139 active running
kube-proxy.service d9f6aeec…/10.240.250.41 active running
kube-scheduler.service 4b2b1ea5…/10.240.87.134 active running

The final step is to run up the kube-register service, which automatically registers new Kubernetes nodes into the Kubernete cluster. This also runs as a single instance alongside the API Server.

k1$ export KUBERNETES_MASTER=http://$(/usr/bin/fleetctl list-units | /usr/bin/grep "^kube-apiserver.service" | /usr/bin/awk '{print $2;}' | /usr/bin/awk -F/ '{print $2;}'):8080
k1$ set | grep "KUBERNETES_MASTER"
KUBERNETES_MASTER=http://10.240.87.134:8080
k1$ sudo touch /opt/kubernetes/services/kube-register.service
k1$ sudo chmod 666 /opt/kubernetes/services/kube-register.service
k1$ cat << EOF > /opt/kubernetes/services/kube-register.service
[Unit]
Description=Kubernetes Registration Service
Documentation=https://github.com/kelseyhightower/kube-register
Requires=setup-network-environment.service
After=setup-network-environment.service
 
[Service]
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/kube-register
ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-register
ExecStart=/opt/bin/kube-register \
  --metadata=role=kubernetes \
  --fleet-endpoint=unix:///var/run/fleet.sock \
  --api-endpoint=http://127.0.0.1:8080
Restart=always
RestartSec=10
 
[X-Fleet]
MachineOf=kube-apiserver.service
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-register.service
k1$ fleetctl start /opt/kubernetes/services/kube-register.service
k1$ fleetctl list-units
UNIT				MACHINE				ACTIVE	SUB
docker.service			4b2b1ea5.../10.240.87.134	active	running
docker.service			55519ede.../10.240.57.139	active	running
docker.service			d9f6aeec.../10.240.250.41	active	running
flannel.service			4b2b1ea5.../10.240.87.134	active	running
flannel.service			55519ede.../10.240.57.139	active	running
flannel.service			d9f6aeec.../10.240.250.41	active	running
kube-apiserver.service		4b2b1ea5.../10.240.87.134	active	running
kube-controller-manager.service	4b2b1ea5.../10.240.87.134	active	running
kube-kubelet.service		4b2b1ea5.../10.240.87.134	active	running
kube-kubelet.service		55519ede.../10.240.57.139	active	running
kube-kubelet.service		d9f6aeec.../10.240.250.41	active	running
kube-proxy.service		4b2b1ea5.../10.240.87.134	active	running
kube-proxy.service		55519ede.../10.240.57.139	active	running
kube-proxy.service		d9f6aeec.../10.240.250.41	active	running
kube-register.service		4b2b1ea5.../10.240.87.134	active	running
kube-scheduler.service		4b2b1ea5.../10.240.87.134	active	running
k1$ kubecfg list minions
Minion identifier
----------
10.240.250.41
10.240.57.139
10.240.87.134

[Service]
ExecStartPre=/usr/bin/wget -N -P /opt/bin http://storage.googleapis.com/kubernetes/kube-register
ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-register
ExecStart=/opt/bin/kube-register \
–metadata=role=kubernetes \
–fleet-endpoint=unix:///var/run/fleet.sock \
–api-endpoint=http://127.0.0.1:8080
Restart=always
RestartSec=10

[X-Fleet]
MachineOf=kube-apiserver.service
MachineMetadata=role=kubernetes
EOF
k1$ sudo chmod 644 /opt/kubernetes/services/kube-register.service
k1$ fleetctl start /opt/kubernetes/services/kube-register.service
k1$ fleetctl list-units
UNIT MACHINE ACTIVE SUB
docker.service 4b2b1ea5…/10.240.87.134 active running
docker.service 55519ede…/10.240.57.139 active running
docker.service d9f6aeec…/10.240.250.41 active running
flannel.service 4b2b1ea5…/10.240.87.134 active running
flannel.service 55519ede…/10.240.57.139 active running
flannel.service d9f6aeec…/10.240.250.41 active running
kube-apiserver.service 4b2b1ea5…/10.240.87.134 active running
kube-controller-manager.service 4b2b1ea5…/10.240.87.134 active running
kube-kubelet.service 4b2b1ea5…/10.240.87.134 active running
kube-kubelet.service 55519ede…/10.240.57.139 active running
kube-kubelet.service d9f6aeec…/10.240.250.41 active running
kube-proxy.service 4b2b1ea5…/10.240.87.134 active running
kube-proxy.service 55519ede…/10.240.57.139 active running
kube-proxy.service d9f6aeec…/10.240.250.41 active running
kube-register.service 4b2b1ea5…/10.240.87.134 active running
kube-scheduler.service 4b2b1ea5…/10.240.87.134 active running
k1$ kubecfg list minions
Minion identifier
———-
10.240.250.41
10.240.57.139
10.240.87.134

And that’s it – you’ve got your Kubernetes cluster up and running, and can start scheduling jobs on it using kubecfg! If you add any new Kubernetes nodes, they should automatically start running the necessary services and be joined to the Kubernetes cluster (and show up in the “list minions” output).

I’ll sort out another blog post about how to run your Docker containers in this cluster covering Pods, Services and ReplicationControllers.

This is my personal blog - all views are my own.

Tagged with: , , , ,