Kubernetes with Contiv plugin in VM
An easy way to setup Contiv on a pair of nodes, is to use the demo installer that is on Github (https://github.com/contiv/install/tree/master/cluster). I did this on a Macbook Pro, with 16 GB of RAM by using these commands:
cd ~/workspace/k8s git clone https://github.com/contiv/install.git contiv-install cd contiv-install BUILD_VERSION=1.0.0-beta.3 make demo-k8s
The make command, will move to the cluster directory and invoke a Vagrantfile to bring up two nodes with Contiv. It uses KubeAdm, starts up a cluster, builds and applies a YAML file, and creates a VXLAN based network. You only need to create pods, once that is completed.
Once the make command has completed, you can access the master node with:
cd cluster CONTIV_KUBEADM=1 vagrant ssh contiv-node1
From there, you can issue kubectl commands to view the nodes, pods, and apply YAML files for starting up pods. The worker node can be accessed the same way, by using “contiv-node2” as the host name. Use the netctl command to view/manipulate the networks. For example, commands like:
netctl network ls netctl net create -t default --subnet=22.214.171.124/24 default-net netctl group create -t default default-net default-epg netctl net create vlan5 -s 192.168.5.0/24 -g 192.168.5.1 -pkt-tag 5 --encap vlan
Note: if you want to create a pod that uses a non-default network, you can use the following syntax in the pod spec:
cat > busybox.yaml <<EOT apiVersion: v1 kind: Pod metadata: name: busybox-harmony-net labels: app: demo-labels io.contiv.network: vlan100 spec: containers: - name: bbox image: contiv/nc-busybox command: - sleep - "7200" EOT
This uses VLAN100 network that was previously created with:
netctl network create --encap=vlan --pkt-tag=100 --subnet=10.100.100.215-10.100.100.220/27 --gateway=10.100.100.193 vlan100
I found that this procedure did not work, when my Mac was connected via VPN to the network. It appears that the VPN mechanism was preventing the VM to ping the (mac) host, and vice versa. Could not even ping the vboxnet interface’s IP from the Mac. Once disconnected from VPN, everything worked fine.
With the default VXLAN that is created by the makefile, you cannot (yet) ping from the node to a VM (or vice versa). Pod to pod pings work, even across nodes.
When done, you can use the cluster-destroy make target to destroy the VMs that are created.