Install flannel on Raspberry Pi for use with Docker and Kubernetes

Download Flannel and zip up

FLANNEL_VERSION="v0.10.0"

wget -o flannel-${FLANNEL_VERSION}-linux-arm.tar.gz https://github.com/coreos/flannel/releases/download/${FLANNEL_VERSION}/flannel-${FLANNEL_VERSION}-linux-arm.tar.gz
mkdir -p opt/flannel
tar zxf flannel-${FLANNEL_VERSION}-linux-arm.tar.gz -C opt/flannel
rm opt/flannel/README.md
zip -9r flannel-${FLANNEL_VERSION}-linux-arm.zip opt


sudo su -
cd /

unzip ~devon/flannel-v0.10.0-linux-arm.zip
unzip ~devon/kubernetes-linux-arm-v1.9.1.zip

chmod 0755 opt/flannel/*
chmod 0755 opt/kubernetes/*
chmod 0644 opt/kubernetes/*docker_tag
chmod 0644 opt/kubernetes/*tar


cat > flannel-network-config.json
{
    "Network":   "192.168.100.0/24",
    "SubnetLen": 20,
    "SubnetMin": "192.168.100.50",
    "SubnetMax": "192.168.100.250",
    "Backend": {
        "Type": "vxlan",
        "VNI":  100,
        "Port": 8472
    }
}
EOF

etcdctl set /coreos.com/network/config < flannel-network-config.json
etcdctl get /coreos.com/network/config | jq .





flanneld -etcd-endpoints=http://192.168.122.173:4001 -etcd-prefix=kubernetes-cluster/network
flanneld -iface=192.168.100.10
flanneld -iface=192.168.100.20
flanneld -iface=192.168.100.30



# Starting from Docker 1.13
# Default iptables policy for FORWARDING is DROP
# Make sure that containers will receive traffic from other hosts
iptables -P FORWARD ACCEPT


cat << EOF > /etc/sysconfig/flanneld
FLANNEL_ETCD="http://192.168.122.173:4001"
FLANNEL_ETCD_KEY="/kubernetes-cluster/network"
EOF

cat << EOF > /lib/systemd/system/flanneld.service
[Unit]
Description=Flanneld overlay address etcd agent
After=network.target
After=network-online.target
Wants=network-online.target
After=etcd.service
Before=docker.service

[Service]
Type=notify
EnvironmentFile=-/etc/default/flanneld
ExecStart=/usr/bin/flanneld -etcd-endpoints=${FLANNEL_ETCD} -etcd-prefix=${FLANNEL_ETCD_KEY} $FLANNEL_OPTIONS
Restart=on-failure

[Install]
WantedBy=multi-user.target
RequiredBy=docker.service
EOF
categories: flannel | golang | raspberrypi | kubernetes | devops |