kubeadm QuickStart - Ubuntu

This is an extra guide added for the benefit of newcomers to Kubernetes, which will install K8s 1.8.x on an Ubuntu 16.04 (xenial) cluster. You can skip this if you already have a running K8s cluster.

Adapted from the official K8s documentation: Installing kubeadm and Using kubeadm to Create Cluster.

  • Ensure that your nodes can accept inbound connections on these ports (by revising firewall rules, updating EC2 security groups, etc.):

    • Intended master node: 6443, 2379, 2380, 10250-10252, 10255

    • Intended worker nodes: 10250, 10255, 30000-32767

    On AWS EC2, you can simply enable inbound traffic for all protocols among only your instances, by selecting the instance security group as the source of the ingress rule, instead of an IP address or CIDR (assuming all your instances are in the same security group).
  • On all nodes, switch to privileged (root) prompt (otherwise you’ll have to prepend almost all of the subsequent commands with sudo):

    sudo -i
  • Update package repositories:

    apt-get update
  • Install Docker on all nodes (including master):

    apt-get install -y docker.io
  • Install kubeadm and related utilities:

    apt-get install -y apt-transport-https
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
    
    cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
    deb http://apt.kubernetes.io/ kubernetes-xenial main
    EOF
    
    apt-get update
    apt-get install -y \
        kubelet=1.8.6-00 \
        kubeadm=1.8.6-00 \
        kubectl=1.8.6-00 \
        kubernetes-cni=0.5.1-00
  • Initialize one node as master (with Flannel as the overlay network), using:

    kubeadm init --kubernetes-version stable-1.8 --pod-network-cidr=10.244.0.0/16
    Note down the kubeadm join command (output at the end of kubeadm init) for future use.
  • On master, exit the privileged (root) prompt, and enable kubectl CLI for non-root users (as suggested in the kubeadm init output):

    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
  • On master, install the Flannel overlay network configurations:

    kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml
  • On other nodes, run the kubeadm join command (output earlier by kubeadm init):

    kubeadm join \
        --token <token> \
        <master-ip>:<master-port> \
        --discovery-token-ca-cert-hash sha256:<hash>
  • If your cluster is small or has limited resources, you may also need to enable scheduling of worker pods on all nodes (including master), using:

    kubectl taint nodes --all node-role.kubernetes.io/master-
    If you follow the above, ensure that you open up inbound connections on ports 30000-32767 on the master, as it will now be acting as a worker as well.

Thanks to kubeadm, now you have a running K8s cluster. Congratulations!

If you came here as a prerequisite for an AdroitLogic IPS installation, you can now head back to the guide and resume the installation.

In this topic
In this topic
Contact Us