Saminnet-Search Article Wiki Forum Piwigo SNS Cloud vtiger Sugar
Clusterhat kubernetes k8s

Clusterhat kubernetes k8s


###Docker and Kubernetes on ARM and Linux This wiki contains the detailed steps necessary to setup a K8s cluster on a ClusterHAT RaspberryPi cluster.

Optional Setup Extras

Hardware List

  • 1x Raspberry Pi 2/3
  • 4x Raspberry Pi 0
  • 1x ClusterHAT
  • 5x 8GB+ MicroSD Cards
  • Power cable
  • Ethernet cable
  • USB to Ethernet adapter (optional)

Laptop Setup

The following section is optional. I used this setup to allow me to make the cluster fully portable, requiring only a laptop and the cluster. You can skip straight to the cluster setup if you are connecting the cluster and your laptop/desktop computer to a traditional dhcp enabled network. The laptop setup steps below is written for Fedora 25. If you're on something else, the steps may differ.

  • Install dnsmasq and bridge-utils

sudo dnf install -y dnsmasq bridge-utils

  • Replace /etc/dnsmasq.conf with config_files/dnsmasq.conf in DKAL repo and make changes specific to your devices where indicated in the file.
  • Copy the ifcfg_* files from config_files directory to /etc/sysconfig/network-scripts. Make sure to adjust the interface and file names to match your wireless and wired network adapter names where indicated.
  • Copy scripts/pibridge-setup to ~/bin or some other location in $PATH. Make sure you edit the script and replace your interface names where indicated.
  • run sysctl net.ipv4.ip_forward = 1

We also need to configure configure some fancy firewalld zones for the new PiBridge interface to be able to serve dhcp and dns to the cluster. I'll add these bits with some screenshots, etc. The gist is that you need to create a zone for the bridge, join the bridge to that new zone and permit dns and dhcp on that zone. Alternatively, you can enable those services on your default zone. I don't recommend this, however, as this is less secure (permitting these services on all interfaces. Not great for a laptop).

If you did the above correctly, you should be able to run the pibridge-setup script. This script will ensure the bridge for your wired interface is setup and that firewall NAT rules are present to allow the devices connected to the bridge to reach the internet, it will then start dnsmasq to serve dhcp and dns.

Setup the SD cards

  • Image sd cards with ClusterHAT Raspbian build
  • Follow ClusterHAT instructions for Pi Zero nodes to assign them P1 -> P4
  • Add the following to cmdline.txt after "rootfstype=ext4" on each sd card:

cgroup_enable=cpuset cgroup_enable=memory

Expand partitions and update packages

These next steps will require that the Pis in the cluster have Internet access. If you did the Laptop setup correctly and have the cluster plugged in to the interface you configured for dnsmasq and the bridge, the pis should pull a dhcp address from your laptop and once fully booted, you should be able to access them over ssh using the dns names, "controller.local" and "p{1,2,3,4}.local". If you chose to skip the laptop setup steps and are connecting the cluster to a switch on a dhcp enabled network, it may be the same but dns may not work depending on the network's dns configuration.

  • run raspi-config on each pi and follow prompts to expand the filesystem
  • reboot each pi
  • Update and upgrade all packages

$ sudo apt-get update && sudo apt-get upgrade -y

Setup Docker

  • Follow the instructions here for installing docker-engine.

Instead of installing docker-engine, however, you should define the version in the apt-get install command. I recommend using docker-engine version 1.12.6. 1.13.0 introduced some firewall rules that complicate things that I will not be covering how to work with in this document.

Setup k8s

  • Install the k8s repos on all nodes (including controller)

# curl -s | apt-key add - # echo "deb kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list

  • Install k8s packages on all nodes (including controller)

# apt-get update && apt-get install kubeadm -y

  • Init the cluster controller on the controller node:

`# kubeadm init --pod-network-cidr

This will take a while. Grab a coffee, lunch (...a short film, a nap).

Once the controller is done initializing, install Flannel:

# curl -sSL | sed 's/amd64/arm/g' | kubectl create -f -

  • You can monitor the above process with:

# watch -n30 "kubectl get pods"

  • Once at least a few of the Flannel pods are started, you can begin joining the other nodes to the controller:

# kubeadm join --token <token> <controller-ip>

Repeat this for each, P1-4 in the cluster. You should see them show up on the controller shortly after running the join command. You can see this on the controller with:

# kubectl get nodes

Setup the K8s dashboard

The K8s dashboard is optional but it's nice to be able to visualize what's going on in your cluster.

# curl -sSL | sed 's/amd64/arm/g' | kubectl create -f -

This will start the dashboard on a random port. You can find this port with:

# kubectrl -n kube-system get service kubernetes-dashboard

Watch the startup status (it's slow) with:

# kubectl -n kube-system get pods

Once it's started up, you can access it from http://controller.local:

Configure Local Access

You may want to access the cluster from you laptop directly. The steps below assume, again, that you're on Fedora 25.

Copy the kubernetes admin.conf to /tmp on the controller:

# cp /etc/kubernetes/admin.conf /tmp && chmod 644 /tmp/admin.conf

Copy it to your laptop:

# scp pi@controller.local:/tmp/admin.conf ~/kubeadmin.conf

Remove it from /tmp on the controller

# rm /tmp/admin.conf

Install kubectl:

$ sudo dnf install -y kubernetes-client

Set up a bash alias on your laptop:

$ echo 'alias kc="kubectl --kubeconfig ~/.kubeadmin.conf"' >> ~/.bashrc

Source ~/.bashrc

$ . ~/.bashrc

You should now be able to run any of the kubectl command options from your laptop:

$ kc get nodes

Remaining Steps

I have a rough draft of my steps outlined on my old wiki (you'll receive an ssl cert warning because I don't have a valid ssl cert). I will be moving this content to this wiki as time permits but I didn't want to leave people without any instructions until I had time to clean it up. This documentation is extremely rough draft and possibly missing steps. Beware.


0 #1 Guest 2018-06-05 05:30
Thanks for any other injformative website. Thee place
else may I get that kind of info written in such a perfect way?
I've a project that I'm simply now working on, and I'vebeen on the gance out laptop computers for sale online such information.

Articles by Date

TweetTweet Share on LinkedInShare on LinkedIn Share on Google+Google+ Submit to RedditReddit Publish on WordPress WordPress Send emailSend email