Skip to content

Instantly share code, notes, and snippets.

@lukemarsden
Last active February 28, 2019 14:22
Show Gist options
  • Select an option

  • Save lukemarsden/24f5892a4ca56e39e922b283aa481062 to your computer and use it in GitHub Desktop.

Select an option

Save lukemarsden/24f5892a4ca56e39e922b283aa481062 to your computer and use it in GitHub Desktop.
Short demo of `kubeadm`

Per https://www.youtube.com/watch?v=Bv3JmHKlA0I&feature=youtu.be

workstation$ export K8S_1=<k8s_1_ip>
workstation$ export K8S_2=<k8s_2_ip>
workstation$ export K8S_3=<k8s_3_ip>

Common

workstation$ ssh root@$K8S_1

cat <<EOF > /etc/apt/sources.list.d/k8s.list
deb [arch=amd64] http://apt.dockerproject.org/repo ubuntu-xenial main
deb [arch=amd64] http://apt.k8s.io xenial main 
EOF
apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys F76221572C52609D 81A45CB679084BD1
apt-get update
apt-get install -y kubelet docker-engine=1.11.2-0~xenial


# --- everything between these lines won't be necessary eventually ---

curl -sSL -o /usr/bin/kubelet https://kubeadm.lukemarsden.net/kubelet
curl -sSL -o /usr/bin/kubectl https://kubeadm.lukemarsden.net/kubectl

curl -sSL -o /usr/bin/kubeadm https://kubeadm.lukemarsden.net/kubeadm
chmod +x /usr/bin/kube{let,ctl,adm}

sed -i '4iStartLimitInterval=0' /etc/systemd/system/kubelet.service

echo KUBELET_OPTS=\"--network-plugin=cni --network-plugin-dir=/etc/cni/net.d --kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true --pod-manifest-path=/etc/kubernetes/manifests\" > /etc/default/kubelet

# ---------------------------------------------------------------------

systemctl enable kubelet && systemctl start kubelet

Kubelet will now wait in a crash-loop until it receives instructions from kubeadm.

Now go and run this on the other two nodes.

Master

workstation$ ssh root@$K8S_1
kubeadm manual bootstrap init-master

Make a note of the command which was just printed, you'll need it as <command-from-init-with-path-to-ca-cert-replaced-with-/tmp/ca.pem> below.

Check that the master came up (may take 30 seconds or so):

kubectl get nodes

As a demo of installing a CNI network as an add-on, let's also install Weave as a pod network. This will get automatically deployed to new nodes as DaemonSets:

kubectl apply -f \
  https://raw.github.com/weaveworks/weave-kube/master/weave-daemonset.yaml
exit

workstation$ scp root@$K8S_1:/etc/kubernetes/pki/ca.pem .
workstation$ scp ca.pem root@$K8S_2:/tmp/ca.pem
workstation$ scp ca.pem root@$K8S_3:/tmp/ca.pem

Nodes

workstation$ ssh root@$K8S_2 <command-from-init-with-path-to-ca-cert-replaced-with-/tmp/ca.pem>
workstation$ ssh root@$K8S_3 <command-from-init-with-path-to-ca-cert-replaced-with-/tmp/ca.pem>
@ali-sh1363
Copy link

how can we install kubernetes on top of the openstack?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment