Skip to content

Instantly share code, notes, and snippets.

@alexellis
Last active June 28, 2025 05:44
Show Gist options
  • Save alexellis/fdbc90de7691a1b9edb545c17da2d975 to your computer and use it in GitHub Desktop.
Save alexellis/fdbc90de7691a1b9edb545c17da2d975 to your computer and use it in GitHub Desktop.

Revisions

  1. alexellis revised this gist Dec 27, 2018. 1 changed file with 3 additions and 342 deletions.
    345 changes: 3 additions & 342 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -1,344 +1,5 @@
    # Kubernetes on (vanilla) Raspbian Lite
    This guide has moved to a GitHub repository to enable collaboration and community input via pull-requests.

    Yes - you can create a Kubernetes cluster with Raspberry Pis with the default operating system called Raspbian. This means you can carry on using all the tools and packages you're used to with the officially-supported OS.
    https://github.com/alexellis/k8s-on-raspbian

    This is part of a blog post [Serverless Kubernetes home-lab with your Raspberry Pis
    ](https://blog.alexellis.io/serverless-kubernetes-on-raspberry-pi/) written by [Alex Ellis](https://twitter.com/alexellisuk).

    > Copyright disclaimer: Please provide a link to the post and give attribution to the author if you plan to use this content in your own materials.
    ## Pre-reqs:

    * You must use an RPi 2 or 3 for use with Kubernetes
    * I'm assuming you're using wired ethernet (Wi-Fi also works, but it's not recommended)

    ## Master node setup

    You can either follow the steps below, or use my flashing script which automates the below. The automated flashing script must be run on a Linux computer with an SD card writer or an RPi.

    ### Flash with a Linux host

    [Provision a Raspberry Pi SD card](https://gist.github.com/alexellis/a7b6c8499d9e598a285669596e9cdfa2)

    Then run:

    ```
    curl -sLSf https://gist.github.com/alexellis/fdbc90de7691a1b9edb545c17da2d975/raw/125ad6eae27e40a235412c2b623285a089a08721/prep.sh | sudo sh
    ```

    ### Continue to flash manually

    * Flash Raspbian to a fresh SD card.

    You can use [Etcher.io](https://etcher.io) to burn the SD card.

    Before booting set up an empty file called `ssh` in /boot/ on the SD card.

    Use Raspbian Stretch Lite

    > Update: I previously recommended downloading Raspbian Jessie instead of Stretch. At time of writing (3 Jan 2018) Stretch is now fully compatible.
    https://www.raspberrypi.org/downloads/raspbian/

    * Change hostname

    Use the `raspi-config` utility to change the hostname to k8s-master-1 or similar and then reboot.

    * Set a static IP address

    It's not fun when your cluster breaks because the IP of your master changed. The master's certificates will be bound to the IP address, so let's fix that problem ahead of time:

    ```
    cat >> /etc/dhcpcd.conf
    ```

    Paste this block:

    ```
    profile static_eth0
    static ip_address=192.168.0.100/24
    static routers=192.168.0.1
    static domain_name_servers=8.8.8.8
    ```

    Hit Control + D.

    Change 100 for 101, 102, 103 etc.

    You may also need to make a reservation on your router's DHCP table so these addresses don't get given out to other devices on your network.

    * Install Docker

    This installs 17.12 or newer.

    ```
    $ curl -sSL get.docker.com | sh && \
    sudo usermod pi -aG docker
    newgrp docker
    ```

    * Disable swap

    For Kubernetes 1.7 and onwards you will get an error if swap space is enabled.

    Turn off swap:

    ```
    $ sudo dphys-swapfile swapoff && \
    sudo dphys-swapfile uninstall && \
    sudo update-rc.d dphys-swapfile remove
    ```

    This should now show no entries:

    ```
    $ sudo swapon --summary
    ```

    * Edit `/boot/cmdline.txt`

    Add this text at the end of the line, but don't create any new lines:

    ```
    cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
    ```

    Now reboot - do not skip this step.

    * Add repo lists & install `kubeadm`

    ```
    $ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
    echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
    sudo apt-get update -q && \
    sudo apt-get install -qy kubeadm
    ```

    > I realise this says 'xenial' in the apt listing, don't worry. It still works.
    ### Initialize your master node

    * You now have two new commands installed:
    * kubeadm - used to create new clusters or join an existing one
    * kubectl - the CLI administration tool for Kubernetes

    If using Weave Net

    * Initialize your master node:

    ```
    $ sudo kubeadm init --token-ttl=0
    ```

    If using Flannel:

    * Initialize your master node with a Pod network CIDR:

    ```
    $ sudo kubeadm init --token-ttl=0 --pod-network-cidr=10.244.0.0/16
    ```

    We pass in `--token-ttl=0` so that the token never expires - do not use this setting in production. The UX for `kubeadm` means it's currently very hard to get a join token later on after the initial token has expired.

    > Optionally also pass `--apiserver-advertise-address=192.168.0.27` with the IP of the Pi as found by typing `ifconfig`.
    Note: This step can take a long time, even up to 15 minutes.

    Sometimes this stage can fail, if it does then you should patch the API Server to allow for a higher failure threshold during initialization around the time you see `[controlplane] wrote Static Pod manifest for component kube-apiserver to "/etc/kubernetes/manifests/kube-apiserver.yaml"`

    ```
    sudo sed -i 's/failureThreshold: 8/failureThreshold: 20/g' /etc/kubernetes/manifests/kube-apiserver.yaml
    ```

    After the `init` is complete run the snippet given to you on the command-line:

    ```
    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
    ```

    This step takes the key generated for cluster administration and makes it available in a default location for use with `kubectl`.

    * Now save your join-token

    Your join token is valid for 24 hours, so save it into a text file. Here's an example of mine:

    ```
    $ kubeadm join --token 9e700f.7dc97f5e3a45c9e5 192.168.0.27:6443 --discovery-token-ca-cert-hash sha256:95cbb9ee5536aa61ec0239d6edd8598af68758308d0a0425848ae1af28859bea
    ```

    * Check everything worked:

    ```
    $ kubectl get pods --namespace=kube-system
    NAME READY STATUS RESTARTS AGE
    etcd-of-2 1/1 Running 0 12m
    kube-apiserver-of-2 1/1 Running 2 12m
    kube-controller-manager-of-2 1/1 Running 1 11m
    kube-dns-66ffd5c588-d8292 3/3 Running 0 11m
    kube-proxy-xcj5h 1/1 Running 0 11m
    kube-scheduler-of-2 1/1 Running 0 11m
    weave-net-zz9rz 2/2 Running 0 5m
    ```

    You should see the "READY" count showing as 1/1 for all services as above. DNS uses three pods, so you'll see 3/3 for that.

    ### Setup networking with Weave Net or Flannel

    Some users have reported stability issues with Weave Net on ARMHF. These issues do not appear to affect x86_64 (regular PCs/VMs). You may want to try Flannel instead of Weave Net for your RPi cluster.

    #### Weave Net

    Install [Weave Net](https://www.weave.works/oss/net/) network driver

    ```
    $ kubectl apply -f \
    "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
    ```

    If you run into any issues with Weaveworks' networking then [flannel](https://github.com/coreos/flannel) is also a popular choice for the ARM platform.

    #### Flannel (alternative)

    Apply the Flannel driver on the master:

    ```
    $ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/c5d10c8/Documentation/kube-flannel.yml
    ```

    On each node that joins including the master:

    ```
    $ sudo sysctl net.bridge.bridge-nf-call-iptables=1
    ```

    ### Join other nodes

    On the other RPis, repeat everything apart from `kubeadm init`.

    * Change hostname

    Use the `raspi-config` utility to change the hostname to `k8s-worker-1` or similar and then reboot.

    * Join the cluster

    Replace the token / IP for the output you got from the master node, for example:

    ```
    $ sudo kubeadm join --token 1fd0d8.67e7083ed7ec08f3 192.168.0.27:6443
    ```

    You can now run this on the master:

    ```
    $ kubectl get nodes
    NAME STATUS AGE VERSION
    k8s-1 Ready 5m v1.7.4
    k8s-2 Ready 10m v1.7.4
    ```

    ## Deploy a container

    This container will expose a HTTP port and convert Markdown to HTML. Just post a body to it via `curl` - follow the instructions below.

    *function.yml*

    ```yaml
    apiVersion: v1
    kind: Service
    metadata:
    name: markdownrender
    labels:
    app: markdownrender
    spec:
    type: NodePort
    ports:
    - port: 8080
    protocol: TCP
    targetPort: 8080
    nodePort: 31118
    selector:
    app: markdownrender
    ---
    apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1
    kind: Deployment
    metadata:
    name: markdownrender
    spec:
    replicas: 1
    template:
    metadata:
    labels:
    app: markdownrender
    spec:
    containers:
    - name: markdownrender
    image: functions/markdownrender:latest-armhf
    imagePullPolicy: Always
    ports:
    - containerPort: 8080
    protocol: TCP
    ```
    Deploy and test:
    ```
    $ kubectl create -f function.yml
    ```

    Once the Docker image has been pulled from the hub and the Pod is running you can access it via `curl`:

    ```
    $ curl -4 http://127.0.0.1:31118 -d "# test"
    <p><h1>test</h1></p>
    ```

    If you want to call the service from a remote machine such as your laptop then use the IP address of your Kubernetes master node and try the same again.

    ## Start up the Kubernetes dashboard

    The dashboard can be useful for visualising the state and health of your system, but it does require the equivalent of "root" in the cluster. If you want to proceed you should first run in a [ClusterRole from the docs](https://github.com/kubernetes/dashboard/wiki/Access-control#admin-privileges).

    ```
    echo -n 'apiVersion: rbac.authorization.k8s.io/v1beta1
    kind: ClusterRoleBinding
    metadata:
    name: kubernetes-dashboard
    labels:
    k8s-app: kubernetes-dashboard
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: cluster-admin
    subjects:
    - kind: ServiceAccount
    name: kubernetes-dashboard
    namespace: kube-system' | kubectl apply -f -
    ```

    This is the development/alternative dashboard which has TLS disabled and is easier to use.

    ```
    $ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/alternative/kubernetes-dashboard-arm.yaml
    ```

    You can then find the IP and port via `kubectl get svc -n kube-system`. To access this from your laptop you will need to use `kubectl proxy` and navigate to `http://localhost:8001/` on the master, or tunnel to this address with `ssh`.

    See also: [Kubernetes Dashboard](https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/) docs.

    ## Remove the test deployment

    Now on the Kubernetes master remove the test deployment:

    ```
    $ kubectl delete -f function.yml
    ```

    ### Wrapping up

    You should now have an operational Kubernetes master and several worker nodes ready to accept workloads.

    Now let's head back [over to the tutorial and deploy OpenFaaS](https://blog.alexellis.io/serverless-kubernetes-on-raspberry-pi/) to put the cluster through its paces with Serverless functions.

    See also: [Kubernetes documentation](https://kubernetes.io/docs/home/?path=users&persona=app-developer&level=foundational)
    Alex
  2. alexellis revised this gist Sep 15, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,12 @@ You can either follow the steps below, or use my flashing script which automates

    [Provision a Raspberry Pi SD card](https://gist.github.com/alexellis/a7b6c8499d9e598a285669596e9cdfa2)

    Then run:

    ```
    curl -sLSf https://gist.github.com/alexellis/fdbc90de7691a1b9edb545c17da2d975/raw/125ad6eae27e40a235412c2b623285a089a08721/prep.sh | sudo sh
    ```

    ### Continue to flash manually

    * Flash Raspbian to a fresh SD card.
  3. alexellis revised this gist Sep 15, 2018. 2 changed files with 47 additions and 6 deletions.
    49 changes: 45 additions & 4 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,14 @@ This is part of a blog post [Serverless Kubernetes home-lab with your Raspberry

    ## Master node setup

    You can either follow the steps below, or use my flashing script which automates the below. The automated flashing script must be run on a Linux computer with an SD card writer or an RPi.

    ### Flash with a Linux host

    [Provision a Raspberry Pi SD card](https://gist.github.com/alexellis/a7b6c8499d9e598a285669596e9cdfa2)

    ### Continue to flash manually

    * Flash Raspbian to a fresh SD card.

    You can use [Etcher.io](https://etcher.io) to burn the SD card.
    @@ -86,11 +94,9 @@ $ sudo swapon --summary
    Add this text at the end of the line, but don't create any new lines:

    ```
    cgroup_enable=cpuset cgroup_enable=memory
    cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
    ```

    > Some people in the comments suggest `cgroup_memory=memory` should now be: `cgroup_memory=1`.
    Now reboot - do not skip this step.

    * Add repo lists & install `kubeadm`
    @@ -104,23 +110,40 @@ $ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key a

    > I realise this says 'xenial' in the apt listing, don't worry. It still works.
    ### Initialize your master node

    * You now have two new commands installed:
    * kubeadm - used to create new clusters or join an existing one
    * kubectl - the CLI administration tool for Kubernetes

    If using Weave Net

    * Initialize your master node:

    ```
    $ sudo kubeadm init --token-ttl=0
    ```

    If using Flannel:

    * Initialize your master node with a Pod network CIDR:

    ```
    $ sudo kubeadm init --token-ttl=0 --pod-network-cidr=10.244.0.0/16
    ```

    We pass in `--token-ttl=0` so that the token never expires - do not use this setting in production. The UX for `kubeadm` means it's currently very hard to get a join token later on after the initial token has expired.

    > Optionally also pass `--apiserver-advertise-address=192.168.0.27` with the IP of the Pi as found by typing `ifconfig`.
    Note: This step can take a long time, even up to 15 minutes.

    Sometimes this stage can fail, if it does then you should patch the API Server to allow for a higher failure threshold during initialization around the time you see `[controlplane] wrote Static Pod manifest for component kube-apiserver to "/etc/kubernetes/manifests/kube-apiserver.yaml"`

    ```
    sudo sed -i 's/failureThreshold: 8/failureThreshold: 20/g' /etc/kubernetes/manifests/kube-apiserver.yaml
    ```

    After the `init` is complete run the snippet given to you on the command-line:

    ```
    @@ -155,7 +178,11 @@ weave-net-zz9rz 2/2 Running 0 5m

    You should see the "READY" count showing as 1/1 for all services as above. DNS uses three pods, so you'll see 3/3 for that.

    * Setup networking
    ### Setup networking with Weave Net or Flannel

    Some users have reported stability issues with Weave Net on ARMHF. These issues do not appear to affect x86_64 (regular PCs/VMs). You may want to try Flannel instead of Weave Net for your RPi cluster.

    #### Weave Net

    Install [Weave Net](https://www.weave.works/oss/net/) network driver

    @@ -166,6 +193,20 @@ $ kubectl apply -f \

    If you run into any issues with Weaveworks' networking then [flannel](https://github.com/coreos/flannel) is also a popular choice for the ARM platform.

    #### Flannel (alternative)

    Apply the Flannel driver on the master:

    ```
    $ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/c5d10c8/Documentation/kube-flannel.yml
    ```

    On each node that joins including the master:

    ```
    $ sudo sysctl net.bridge.bridge-nf-call-iptables=1
    ```

    ### Join other nodes

    On the other RPis, repeat everything apart from `kubeadm init`.
    4 changes: 2 additions & 2 deletions prep.sh
    Original file line number Diff line number Diff line change
    @@ -14,10 +14,10 @@ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
    sudo apt-get update -q && \
    sudo apt-get install -qy kubeadm

    echo Adding " cgroup_enable=cpuset cgroup_memory=1" to /boot/cmdline.txt
    echo Adding " cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory" to /boot/cmdline.txt

    sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_memory=1"
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory"
    echo $orig | sudo tee /boot/cmdline.txt

    echo Please reboot
  4. alexellis revised this gist Aug 26, 2018. 1 changed file with 20 additions and 14 deletions.
    34 changes: 20 additions & 14 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ Yes - you can create a Kubernetes cluster with Raspberry Pis with the default op
    This is part of a blog post [Serverless Kubernetes home-lab with your Raspberry Pis
    ](https://blog.alexellis.io/serverless-kubernetes-on-raspberry-pi/) written by [Alex Ellis](https://twitter.com/alexellisuk).

    > Copyright disclaimer: Please provide a link to the post and give attribution to the author if you wish to use this material in a follow-up post.
    > Copyright disclaimer: Please provide a link to the post and give attribution to the author if you plan to use this content in your own materials.
    ## Pre-reqs:

    @@ -32,7 +32,7 @@ Use the `raspi-config` utility to change the hostname to k8s-master-1 or similar

    * Set a static IP address

    It's not fun when your cluste breaks because the IP of your master changed. Let's fix that problem ahead of time:
    It's not fun when your cluster breaks because the IP of your master changed. The master's certificates will be bound to the IP address, so let's fix that problem ahead of time:

    ```
    cat >> /etc/dhcpcd.conf
    @@ -60,11 +60,12 @@ This installs 17.12 or newer.
    ```
    $ curl -sSL get.docker.com | sh && \
    sudo usermod pi -aG docker
    newgrp docker
    ```

    * Disable swap

    For Kubernetes 1.7 and newer you will get an error if swap space is enabled.
    For Kubernetes 1.7 and onwards you will get an error if swap space is enabled.

    Turn off swap:

    @@ -92,7 +93,7 @@ cgroup_enable=cpuset cgroup_enable=memory
    Now reboot - do not skip this step.

    * Add repo lists & install kubeadm
    * Add repo lists & install `kubeadm`

    ```
    $ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
    @@ -116,9 +117,9 @@ $ sudo kubeadm init --token-ttl=0

    We pass in `--token-ttl=0` so that the token never expires - do not use this setting in production. The UX for `kubeadm` means it's currently very hard to get a join token later on after the initial token has expired.

    > Optionally also pass `--apiserver-advertise-address=192.168.0.27` with the IP of the Pi.
    > Optionally also pass `--apiserver-advertise-address=192.168.0.27` with the IP of the Pi as found by typing `ifconfig`.
    Note: This step will take a long time, even up to 15 minutes.
    Note: This step can take a long time, even up to 15 minutes.

    After the `init` is complete run the snippet given to you on the command-line:

    @@ -156,7 +157,7 @@ You should see the "READY" count showing as 1/1 for all services as above. DNS u

    * Setup networking

    Install Weave network driver
    Install [Weave Net](https://www.weave.works/oss/net/) network driver

    ```
    $ kubectl apply -f \
    @@ -171,11 +172,11 @@ On the other RPis, repeat everything apart from `kubeadm init`.

    * Change hostname

    Use the `raspi-config` utility to change the hostname to k8s-worker-1 or similar and then reboot.
    Use the `raspi-config` utility to change the hostname to `k8s-worker-1` or similar and then reboot.

    * Join the cluster

    Replace the token / IP for the output you got from the master node:
    Replace the token / IP for the output you got from the master node, for example:

    ```
    $ sudo kubeadm join --token 1fd0d8.67e7083ed7ec08f3 192.168.0.27:6443
    @@ -196,7 +197,7 @@ This container will expose a HTTP port and convert Markdown to HTML. Just post a

    *function.yml*

    ```
    ```yaml
    apiVersion: v1
    kind: Service
    metadata:
    @@ -248,9 +249,9 @@ $ curl -4 http://127.0.0.1:31118 -d "# test"

    If you want to call the service from a remote machine such as your laptop then use the IP address of your Kubernetes master node and try the same again.

    ## Start up the dashboard
    ## Start up the Kubernetes dashboard

    The dashboard can be useful for visualising the state and health of your system but it does require the equivalent of "root" in the cluster. If you want to proceed you should first run in a [ClusterRole from the docs](https://github.com/kubernetes/dashboard/wiki/Access-control#admin-privileges).
    The dashboard can be useful for visualising the state and health of your system, but it does require the equivalent of "root" in the cluster. If you want to proceed you should first run in a [ClusterRole from the docs](https://github.com/kubernetes/dashboard/wiki/Access-control#admin-privileges).

    ```
    echo -n 'apiVersion: rbac.authorization.k8s.io/v1beta1
    @@ -277,6 +278,8 @@ $ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master

    You can then find the IP and port via `kubectl get svc -n kube-system`. To access this from your laptop you will need to use `kubectl proxy` and navigate to `http://localhost:8001/` on the master, or tunnel to this address with `ssh`.

    See also: [Kubernetes Dashboard](https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/) docs.

    ## Remove the test deployment

    Now on the Kubernetes master remove the test deployment:
    @@ -285,7 +288,10 @@ Now on the Kubernetes master remove the test deployment:
    $ kubectl delete -f function.yml
    ```

    ### Moving on
    ### Wrapping up

    You should now have an operational Kubernetes master and several worker nodes ready to accept workloads.

    Now head back [over to the tutorial and deploy OpenFaaS](https://blog.alexellis.io/serverless-kubernetes-on-raspberry-pi/) to put the cluster through its paces with Serverless functions at scale.
    Now let's head back [over to the tutorial and deploy OpenFaaS](https://blog.alexellis.io/serverless-kubernetes-on-raspberry-pi/) to put the cluster through its paces with Serverless functions.

    See also: [Kubernetes documentation](https://kubernetes.io/docs/home/?path=users&persona=app-developer&level=foundational)
  5. alexellis revised this gist Aug 26, 2018. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,11 @@

    Yes - you can create a Kubernetes cluster with Raspberry Pis with the default operating system called Raspbian. This means you can carry on using all the tools and packages you're used to with the officially-supported OS.

    This is part of a blog post [Serverless Kubernetes home-lab with your Raspberry Pis
    ](https://blog.alexellis.io/serverless-kubernetes-on-raspberry-pi/) written by [Alex Ellis](https://twitter.com/alexellisuk).

    > Copyright disclaimer: Please provide a link to the post and give attribution to the author if you wish to use this material in a follow-up post.
    ## Pre-reqs:

    * You must use an RPi 2 or 3 for use with Kubernetes
  6. alexellis revised this gist Aug 26, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -158,6 +158,8 @@ $ kubectl apply -f \
    "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
    ```

    If you run into any issues with Weaveworks' networking then [flannel](https://github.com/coreos/flannel) is also a popular choice for the ARM platform.

    ### Join other nodes

    On the other RPis, repeat everything apart from `kubeadm init`.
    @@ -280,4 +282,5 @@ $ kubectl delete -f function.yml

    ### Moving on

    Now head back over to the tutorial and deploy OpenFaaS to put the cluster through its paces.
    Now head back [over to the tutorial and deploy OpenFaaS](https://blog.alexellis.io/serverless-kubernetes-on-raspberry-pi/) to put the cluster through its paces with Serverless functions at scale.

  7. alexellis revised this gist Mar 17, 2018. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    # K8s on (vanilla) Raspbian Lite
    # Kubernetes on (vanilla) Raspbian Lite

    Yes - you can create a Kubernetes cluster with Raspberry Pis with the default operating system Raspbian. Carry on using all the tools and packages you're used to with the officially-supported OS.
    Yes - you can create a Kubernetes cluster with Raspberry Pis with the default operating system called Raspbian. This means you can carry on using all the tools and packages you're used to with the officially-supported OS.

    ## Pre-reqs:

    * You must use an RPi2 or 3 for Kubernetes
    * I'm assuming you're using wired ethernet (Wi-Fi also works)
    * You must use an RPi 2 or 3 for use with Kubernetes
    * I'm assuming you're using wired ethernet (Wi-Fi also works, but it's not recommended)

    ## Master node setup

  8. alexellis revised this gist Mar 17, 2018. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -153,12 +153,6 @@ You should see the "READY" count showing as 1/1 for all services as above. DNS u

    Install Weave network driver

    ```
    $ kubectl apply -f https://git.io/weave-kube-1.6
    ```

    If you run into an issue use this script instead:

    ```
    $ kubectl apply -f \
    "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
    @@ -189,9 +183,10 @@ k8s-1 Ready 5m v1.7.4
    k8s-2 Ready 10m v1.7.4
    ```


    ## Deploy a container

    This container will expose a HTTP port and convert Markdown to HTML. Just post a body to it via `curl` - follow the instructions below.

    *function.yml*

    ```
    @@ -235,11 +230,16 @@ Deploy and test:

    ```
    $ kubectl create -f function.yml
    $ curl -4 http://localhost:31118 -d "# test"
    ```

    Once the Docker image has been pulled from the hub and the Pod is running you can access it via `curl`:

    ```
    $ curl -4 http://127.0.0.1:31118 -d "# test"
    <p><h1>test</h1></p>
    ```

    From a remote machine such as your laptop use the IP address of your Kubernetes master and try the same again.
    If you want to call the service from a remote machine such as your laptop then use the IP address of your Kubernetes master node and try the same again.

    ## Start up the dashboard

    @@ -280,4 +280,4 @@ $ kubectl delete -f function.yml

    ### Moving on

    Now head back over to the tutorial and deploy OpenFaaS
    Now head back over to the tutorial and deploy OpenFaaS to put the cluster through its paces.
  9. alexellis revised this gist Jan 18, 2018. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -157,6 +157,13 @@ Install Weave network driver
    $ kubectl apply -f https://git.io/weave-kube-1.6
    ```

    If you run into an issue use this script instead:

    ```
    $ kubectl apply -f \
    "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
    ```

    ### Join other nodes

    On the other RPis, repeat everything apart from `kubeadm init`.
  10. alexellis revised this gist Jan 13, 2018. 1 changed file with 22 additions and 3 deletions.
    25 changes: 22 additions & 3 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -236,13 +236,32 @@ From a remote machine such as your laptop use the IP address of your Kubernetes

    ## Start up the dashboard

    This is the development dashboard which has TLS disabled and is easier to use.
    The dashboard can be useful for visualising the state and health of your system but it does require the equivalent of "root" in the cluster. If you want to proceed you should first run in a [ClusterRole from the docs](https://github.com/kubernetes/dashboard/wiki/Access-control#admin-privileges).

    ```
    $ curl -sSL https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard-arm.yaml | kubectl create -f -
    echo -n 'apiVersion: rbac.authorization.k8s.io/v1beta1
    kind: ClusterRoleBinding
    metadata:
    name: kubernetes-dashboard
    labels:
    k8s-app: kubernetes-dashboard
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: cluster-admin
    subjects:
    - kind: ServiceAccount
    name: kubernetes-dashboard
    namespace: kube-system' | kubectl apply -f -
    ```

    This is the development/alternative dashboard which has TLS disabled and is easier to use.

    ```
    $ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/alternative/kubernetes-dashboard-arm.yaml
    ```

    You can then find the IP and port via `kubectl get svc -n kube-system`. To access this from your laptop you will need to use `kubectl proxy`.
    You can then find the IP and port via `kubectl get svc -n kube-system`. To access this from your laptop you will need to use `kubectl proxy` and navigate to `http://localhost:8001/` on the master, or tunnel to this address with `ssh`.

    ## Remove the test deployment

  11. alexellis revised this gist Jan 3, 2018. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -15,9 +15,11 @@ You can use [Etcher.io](https://etcher.io) to burn the SD card.

    Before booting set up an empty file called `ssh` in /boot/ on the SD card.

    Use Raspbian Jessie
    Use Raspbian Stretch Lite

    https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-07-05/
    > Update: I previously recommended downloading Raspbian Jessie instead of Stretch. At time of writing (3 Jan 2018) Stretch is now fully compatible.
    https://www.raspberrypi.org/downloads/raspbian/

    * Change hostname

    @@ -48,7 +50,7 @@ You may also need to make a reservation on your router's DHCP table so these add

    * Install Docker

    This installs 17.05 - the latest release for Jessie.
    This installs 17.12 or newer.

    ```
    $ curl -sSL get.docker.com | sh && \
  12. alexellis revised this gist Dec 23, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -104,9 +104,11 @@ $ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key a
    * Initialize your master node:

    ```
    $ sudo kubeadm init
    $ sudo kubeadm init --token-ttl=0
    ```

    We pass in `--token-ttl=0` so that the token never expires - do not use this setting in production. The UX for `kubeadm` means it's currently very hard to get a join token later on after the initial token has expired.

    > Optionally also pass `--apiserver-advertise-address=192.168.0.27` with the IP of the Pi.
    Note: This step will take a long time, even up to 15 minutes.
  13. alexellis revised this gist Dec 23, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion quick.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ Use this to setup quickly

    ```
    # curl -sL \
    https://gist.github.com/alexellis/fdbc90de7691a1b9edb545c17da2d975/raw/6eb4ebdb52b69c7c4fa9b35723d6e84b919dcedb/prep.sh \
    https://gist.github.com/alexellis/fdbc90de7691a1b9edb545c17da2d975/raw/b04f1e9250c61a8ff554bfe3475b6dd050062484/prep.sh \
    | sudo sh
    ```

  14. alexellis revised this gist Dec 23, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions prep.sh
    Original file line number Diff line number Diff line change
    @@ -14,10 +14,10 @@ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
    sudo apt-get update -q && \
    sudo apt-get install -qy kubeadm

    echo Adding " cgroup_enable=cpuset cgroup_enable=memory" to /boot/cmdline.txt
    echo Adding " cgroup_enable=cpuset cgroup_memory=1" to /boot/cmdline.txt

    sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_enable=memory"
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_memory=1"
    echo $orig | sudo tee /boot/cmdline.txt

    echo Please reboot
  15. alexellis revised this gist Dec 23, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions prep.sh
    Original file line number Diff line number Diff line change
    @@ -14,10 +14,10 @@ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
    sudo apt-get update -q && \
    sudo apt-get install -qy kubeadm

    echo Adding " cgroup_enable=cpuset cgroup_enable=1" to /boot/cmdline.txt
    echo Adding " cgroup_enable=cpuset cgroup_enable=memory" to /boot/cmdline.txt

    sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_enable=1"
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_enable=memory"
    echo $orig | sudo tee /boot/cmdline.txt

    echo Please reboot
  16. alexellis revised this gist Dec 23, 2017. 1 changed file with 23 additions and 0 deletions.
    23 changes: 23 additions & 0 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,29 @@ https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-07-05/

    Use the `raspi-config` utility to change the hostname to k8s-master-1 or similar and then reboot.

    * Set a static IP address

    It's not fun when your cluste breaks because the IP of your master changed. Let's fix that problem ahead of time:

    ```
    cat >> /etc/dhcpcd.conf
    ```

    Paste this block:

    ```
    profile static_eth0
    static ip_address=192.168.0.100/24
    static routers=192.168.0.1
    static domain_name_servers=8.8.8.8
    ```

    Hit Control + D.

    Change 100 for 101, 102, 103 etc.

    You may also need to make a reservation on your router's DHCP table so these addresses don't get given out to other devices on your network.

    * Install Docker

    This installs 17.05 - the latest release for Jessie.
  17. alexellis revised this gist Dec 23, 2017. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions quick.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    Use this to setup quickly

    ```
    # curl -sL \
    https://gist.github.com/alexellis/fdbc90de7691a1b9edb545c17da2d975/raw/6eb4ebdb52b69c7c4fa9b35723d6e84b919dcedb/prep.sh \
    | sudo sh
    ```

  18. alexellis revised this gist Dec 23, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions prep.sh
    Original file line number Diff line number Diff line change
    @@ -14,10 +14,10 @@ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
    sudo apt-get update -q && \
    sudo apt-get install -qy kubeadm

    echo Adding " cgroup_enable=cpuset cgroup_enable=memory" to /boot/cmdline.txt
    echo Adding " cgroup_enable=cpuset cgroup_enable=1" to /boot/cmdline.txt

    sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_enable=memory"
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_enable=1"
    echo $orig | sudo tee /boot/cmdline.txt

    echo Please reboot
  19. alexellis revised this gist Dec 23, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -58,6 +58,8 @@ Add this text at the end of the line, but don't create any new lines:
    cgroup_enable=cpuset cgroup_enable=memory
    ```

    > Some people in the comments suggest `cgroup_memory=memory` should now be: `cgroup_memory=1`.
    Now reboot - do not skip this step.

    * Add repo lists & install kubeadm
  20. alexellis revised this gist Oct 25, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion prep.sh
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add

    echo Adding " cgroup_enable=cpuset cgroup_enable=memory" to /boot/cmdline.txt

    cp /boot/cmdline.txt /boot/cmdline_backup.txt
    sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_enable=memory"
    echo $orig | sudo tee /boot/cmdline.txt

  21. alexellis revised this gist Oct 25, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion prep.sh
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,6 @@ echo Adding " cgroup_enable=cpuset cgroup_enable=memory" to /boot/cmdline.txt

    cp /boot/cmdline.txt /boot/cmdline_backup.txt
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_enable=memory"
    echo $orig > /boot/cmdline.txt
    echo $orig | sudo tee /boot/cmdline.txt

    echo Please reboot
  22. alexellis revised this gist Oct 25, 2017. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion prep.sh
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,10 @@ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
    sudo apt-get update -q && \
    sudo apt-get install -qy kubeadm

    echo Add " cgroup_enable=cpuset cgroup_enable=memory" to /boot/cmdline.txt, then reboot
    echo Adding " cgroup_enable=cpuset cgroup_enable=memory" to /boot/cmdline.txt

    cp /boot/cmdline.txt /boot/cmdline_backup.txt
    orig="$(head -n1 /boot/cmdline.txt) cgroup_enable=cpuset cgroup_enable=memory"
    echo $orig > /boot/cmdline.txt

    echo Please reboot
  23. alexellis revised this gist Oct 25, 2017. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions prep.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/bin/sh

    # This installs the base instructions up to the point of joining / creating a cluster

    curl -sSL get.docker.com | sh && \
    sudo usermod pi -aG docker

    sudo dphys-swapfile swapoff && \
    sudo dphys-swapfile uninstall && \
    sudo update-rc.d dphys-swapfile remove

    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \
    echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \
    sudo apt-get update -q && \
    sudo apt-get install -qy kubeadm

    echo Add " cgroup_enable=cpuset cgroup_enable=memory" to /boot/cmdline.txt, then reboot
  24. alexellis revised this gist Oct 25, 2017. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -207,12 +207,13 @@ From a remote machine such as your laptop use the IP address of your Kubernetes

    ## Start up the dashboard

    This is the development dashboard which has TLS disabled and is easier to use.

    ```
    $ curl -sSL https://rawgit.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard-arm.yaml | \
    sed "s/amd64/arm/" | kubectl create -f -
    $ curl -sSL https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard-arm.yaml | kubectl create -f -
    ```

    You can then find the IP and port via `kubectl get svc -n kube-system`
    You can then find the IP and port via `kubectl get svc -n kube-system`. To access this from your laptop you will need to use `kubectl proxy`.

    ## Remove the test deployment

  25. alexellis revised this gist Oct 25, 2017. 1 changed file with 22 additions and 5 deletions.
    27 changes: 22 additions & 5 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,9 @@ For Kubernetes 1.7 and newer you will get an error if swap space is enabled.
    Turn off swap:

    ```
    $ sudo dphys-swapfile swapoff
    $ sudo dphys-swapfile swapoff && \
    sudo dphys-swapfile uninstall && \
    sudo update-rc.d dphys-swapfile remove
    ```

    This should now show no entries:
    @@ -196,15 +198,30 @@ spec:
    Deploy and test:

    ```
    $ kubectl create -f function.yml
    $ curl localhost:31118 -d "# test"
    $ kubectl create -f function.yml
    $ curl -4 http://localhost:31118 -d "# test"
    <p><h1>test</h1></p>
    ```

    From a remote machine such as your laptop use the IP address of your Kubernetes master and try the same again.

    ## Start up the dashboard

    ```
    $ curl -sSL https://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml | \
    $ curl -sSL https://rawgit.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard-arm.yaml | \
    sed "s/amd64/arm/" | kubectl create -f -
    ```

    You can then find the IP and port via `kubectl get svc -n kube-system`
    You can then find the IP and port via `kubectl get svc -n kube-system`

    ## Remove the test deployment

    Now on the Kubernetes master remove the test deployment:

    ```
    $ kubectl delete -f function.yml
    ```

    ### Moving on

    Now head back over to the tutorial and deploy OpenFaaS
  26. alexellis revised this gist Oct 24, 2017. 1 changed file with 8 additions and 7 deletions.
    15 changes: 8 additions & 7 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -106,13 +106,14 @@ $ kubeadm join --token 9e700f.7dc97f5e3a45c9e5 192.168.0.27:6443 --discovery-tok

    ```
    $ kubectl get pods --namespace=kube-system
    NAME READY STATUS RESTARTS AGE
    etcd-k8s-1 1/1 Running 0 4m
    kube-apiserver-k8s-1 1/1 Running 0 4m
    kube-controller-manager-k8s-1 1/1 Running 0 4m
    kube-dns-2459497834-63fw6 3/3 Pending 0 3m
    kube-proxy-jzt2r 1/1 Running 0 3m
    kube-scheduler-k8s-1 1/1 Running 0 4m
    NAME READY STATUS RESTARTS AGE
    etcd-of-2 1/1 Running 0 12m
    kube-apiserver-of-2 1/1 Running 2 12m
    kube-controller-manager-of-2 1/1 Running 1 11m
    kube-dns-66ffd5c588-d8292 3/3 Running 0 11m
    kube-proxy-xcj5h 1/1 Running 0 11m
    kube-scheduler-of-2 1/1 Running 0 11m
    weave-net-zz9rz 2/2 Running 0 5m
    ```

    You should see the "READY" count showing as 1/1 for all services as above. DNS uses three pods, so you'll see 3/3 for that.
  27. alexellis revised this gist Oct 24, 2017. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -36,14 +36,15 @@ sudo usermod pi -aG docker

    For Kubernetes 1.7 and newer you will get an error if swap space is enabled.

    Use the `swapoff` tool to turn off any swap files set up by the system. Make this permanent by editing `/etc/fstab` and commenting out the swap line.
    Turn off swap:

    ```
    $ sudo swapon --summary
    Filename Type Size Used Priority
    /var/swap file 102396 0 -1
    $ sudo dphys-swapfile swapoff
    ```

    $ sudo swapoff /var/swap
    This should now show no entries:

    ```
    $ sudo swapon --summary
    ```

  28. alexellis revised this gist Oct 24, 2017. 1 changed file with 24 additions and 14 deletions.
    38 changes: 24 additions & 14 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -32,6 +32,21 @@ $ curl -sSL get.docker.com | sh && \
    sudo usermod pi -aG docker
    ```

    * Disable swap

    For Kubernetes 1.7 and newer you will get an error if swap space is enabled.

    Use the `swapoff` tool to turn off any swap files set up by the system. Make this permanent by editing `/etc/fstab` and commenting out the swap line.

    ```
    $ sudo swapon --summary
    Filename Type Size Used Priority
    /var/swap file 102396 0 -1
    $ sudo swapoff /var/swap
    $ sudo swapon --summary
    ```

    * Edit `/boot/cmdline.txt`

    Add this text at the end of the line, but don't create any new lines:
    @@ -78,6 +93,14 @@ After the `init` is complete run the snippet given to you on the command-line:

    This step takes the key generated for cluster administration and makes it available in a default location for use with `kubectl`.

    * Now save your join-token

    Your join token is valid for 24 hours, so save it into a text file. Here's an example of mine:

    ```
    $ kubeadm join --token 9e700f.7dc97f5e3a45c9e5 192.168.0.27:6443 --discovery-token-ca-cert-hash sha256:95cbb9ee5536aa61ec0239d6edd8598af68758308d0a0425848ae1af28859bea
    ```

    * Check everything worked:

    ```
    @@ -86,26 +109,13 @@ NAME READY STATUS RESTARTS AGE
    etcd-k8s-1 1/1 Running 0 4m
    kube-apiserver-k8s-1 1/1 Running 0 4m
    kube-controller-manager-k8s-1 1/1 Running 0 4m
    kube-dns-2459497834-63fw6 0/3 Pending 0 3m
    kube-dns-2459497834-63fw6 3/3 Pending 0 3m
    kube-proxy-jzt2r 1/1 Running 0 3m
    kube-scheduler-k8s-1 1/1 Running 0 4m
    ```

    You should see the "READY" count showing as 1/1 for all services as above. DNS uses three pods, so you'll see 3/3 for that.

    * Troubleshooting

    If you get a warning or error about swap space, then use the `swapoff` tool to turn off any swap files set up by the system. Make this permanent by editing /etc/fstab and commenting out the swap line.

    ```
    $ sudo swapon --summary
    Filename Type Size Used Priority
    /var/swap file 102396 0 -1
    $ sudo swapoff /var/swap
    $ sudo swapon --summary
    ```

    * Setup networking

    Install Weave network driver
  29. alexellis revised this gist Oct 24, 2017. 1 changed file with 21 additions and 6 deletions.
    27 changes: 21 additions & 6 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -55,9 +55,8 @@ $ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key a

    * You now have two new commands installed:

    * kubeadm - used to create new clusters or join an existing one
    * kubectl - the CLI administration tool for Kubernetes
    * kubeadm - used to create new clusters or join an existing one
    * kubectl - the CLI administration tool for Kubernetes

    * Initialize your master node:

    @@ -67,17 +66,18 @@ $ sudo kubeadm init

    > Optionally also pass `--apiserver-advertise-address=192.168.0.27` with the IP of the Pi.
    This will take some time.
    Note: This step will take a long time, even up to 15 minutes.

    Run the snippet given to you on the command-line:
    After the `init` is complete run the snippet given to you on the command-line:

    ```
    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
    ```

    This step takes the key generated for cluster administration and makes it available in a default location for use with `kubectl`.

    * Check everything worked:

    ```
    @@ -91,6 +91,21 @@ kube-proxy-jzt2r 1/1 Running 0 3m
    kube-scheduler-k8s-1 1/1 Running 0 4m
    ```

    You should see the "READY" count showing as 1/1 for all services as above. DNS uses three pods, so you'll see 3/3 for that.

    * Troubleshooting

    If you get a warning or error about swap space, then use the `swapoff` tool to turn off any swap files set up by the system. Make this permanent by editing /etc/fstab and commenting out the swap line.

    ```
    $ sudo swapon --summary
    Filename Type Size Used Priority
    /var/swap file 102396 0 -1
    $ sudo swapoff /var/swap
    $ sudo swapon --summary
    ```

    * Setup networking

    Install Weave network driver
  30. alexellis revised this gist Oct 24, 2017. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions k8s-pi.md
    Original file line number Diff line number Diff line change
    @@ -28,18 +28,20 @@ Use the `raspi-config` utility to change the hostname to k8s-master-1 or similar
    This installs 17.05 - the latest release for Jessie.

    ```
    $ curl -sSL get.docker.com | sh
    $ sudo usermod pi -aG docker
    $ curl -sSL get.docker.com | sh && \
    sudo usermod pi -aG docker
    ```

    * Edit `cmdline.txt`
    * Edit `/boot/cmdline.txt`

    Add this text, but don't create any new lines:
    Add this text at the end of the line, but don't create any new lines:

    ```
    cgroup_enable=cpuset cgroup_enable=memory
    cgroup_enable=cpuset cgroup_enable=memory
    ```

    Now reboot - do not skip this step.

    * Add repo lists & install kubeadm

    ```
    @@ -52,12 +54,10 @@ $ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key a
    > I realise this says 'xenial' in the apt listing, don't worry. It still works.

    * Check commands exist:
    * You now have two new commands installed:

    ```
    $ kubeadm
    $ kubectl
    ```
    * kubeadm - used to create new clusters or join an existing one
    * kubectl - the CLI administration tool for Kubernetes

    * Initialize your master node: