Skip to content

Instantly share code, notes, and snippets.

@gintsgints
Last active April 13, 2019 18:02
Show Gist options
  • Save gintsgints/2166437f3dd235d77362a92af2b6e898 to your computer and use it in GitHub Desktop.
Save gintsgints/2166437f3dd235d77362a92af2b6e898 to your computer and use it in GitHub Desktop.

Nano PI Kubernetes install

Nano PI as base

http://wiki.friendlyarm.com/wiki/index.php/NanoPi_NEO2#UbuntuCore_16.04

Follow instructions to download image - nanopi-neo2_sd_friendlycore-xenial_4.14_arm64_20181011.img

Write it to SD card (8 GB Min) with Win32 disk imager and put it into NanoPi. Connect to network, boot up and login with root/fa

I do not like root with known password

adduser username
# ^^ Do not forget to assign this user to sudoers.
usermod -a -G sudo username
usermod -a -G ssh username
# change root password
passwd
# change hostname of node. With NanoPi you can do it with utility:
sudo npi-config
# from your workstation
ssh-copy-id username@node

Next you have to assign your node fixed IP address. Make sure you write this address in file - /etc/hosts

Install kubeadm

Use instructions here - https://kubernetes.io/docs/setup/independent/install-kubeadm/ (ubuntu install)

# as root user
apt-get update && apt-get install -y apt-transport-https curl
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 https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl

And also install docker:

apt-get install -y docker.io

And set docker to be started by default:

systemctl enable docker

Config

Disable swap:

swapoff -a

and remove from /etc/fstab swap row - /mnt/512MB.swa ......

Create master

Then I can create kubertnetes master with command:

sudo kubeadm init --pod-network-cidr=10.10.0.0/16 --apiserver-advertise-address=$(ifconfig eth0 | grep 'inet addr'| cut -d':' -f2 | awk '{print $1}')

or you can try do it in steps utilising (preflight phases)[https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init-phase/]

kubeadm init phase preflight --config kubeadm-config.yml
kubeadm init phase certs all
kubeadm init phase kubeconfig all
kubeadm init phase kubelet-start --config kubeadm-config.yml
kubeadm init phase control-plane all
etc

When kubernetes initialized you can add config to your account:

sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf

Network configuration

You can add Weave Net with next command:

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

Notes

Kubernetes install recomends not use cgroups with docker. so I found: openshift/origin#18776

To edit /lib/systemd/system/docker.service:

ExecStart=/usr/bin/dockerd \
          --exec-opt native.cgroupdriver=systemd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment