CDK installation with LXD on Ubuntu 18.04 (Bionic)— Cheat Sheet

Prachi More
FAUN — Developer Community 🐾
6 min readJan 10, 2019

--

Quick & crisp guide to install the Canonical Distribution of Kubernetes on AWS and localhost linux

CDK is ideally installed best using conjure-up utility. It is a packaging and deploying tool which bundles the k8s installation as processed scripts called as ‘Spells’. This is a turnkey solution to install k8s cluster quickly.

CDK installation on localhost

If you’re constrained with resources and wish to install a k8s cluster on your local machine/instance, follow this process.

Goes without saying..let’s start with —

$ sudo apt update$ sudo apt upgrade

Ok. So the installation flow is:

Install snapd → snapd will help install conjure-up → conjure-up will be used for Kubernetes installation → juju will be used to check the cluster status and other tasks later

Install snapd.

$ sudo apt install snapd

Check the service status and snap version.

ubuntu@ip-xxxx:~$ systemctl status snapd
● snapd.service - Snappy daemon
Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-01-08 08:17:12 UTC; 2min 10s ago
Main PID: 1497 (snapd)
Tasks: 10
Memory: 47.6M
CPU: 1.252s
CGroup: /system.slice/snapd.service
└─1497 /usr/lib/snapd/snapd
ubuntu@ip-xxxx:~$ sudo snap --version
snap 2.35
snapd 2.35
series 16
ubuntu 16.04
kernel 4.4.0-1067-aws
272}

Now install conjure-up using snapd.

ubuntu@ip-xxxx:~$ sudo snap install conjure-up --classicconjure-up 2.6.4-20181213.2312 from Canonical✓ installed

Since we are planning to spin a cluster on localhost which is my Ubuntu 18.04 EC2 instance, we need to configure LXD first.

Install LXD.

ubuntu@ip-xxxx:~$ sudo snap install lxd
lxd 3.8 from Canonical✓ installed

Check if your user is in the lxd group.

ubuntu@ip-xxxx:~$ id
uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),110(lxd)

Initialize it.

ubuntu@ip-xxxx:~$ /snap/bin/lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: no
Do you want to configure a new storage pool? (yes/no) [default=yes]: yes
Name of the new storage pool [default=default]: default
Name of the storage backend to use (btrfs, ceph, dir, lvm, zfs) [default=zfs]: zfs
Create a new ZFS pool? (yes/no) [default=yes]: yes
Would you like to use an existing block device? (yes/no) [default=no]: no
Size in GB of the new loop device (1GB minimum) [default=15GB]: 15GB
Would you like to connect to a MAAS server? (yes/no) [default=no]: no
Would you like to create a new local network bridge? (yes/no) [default=yes]: yes
What should the new bridge be called? [default=lxdbr0]: lxdbr1
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: auto
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: none
Would you like LXD to be available over the network? (yes/no) [default=no]: no
Would you like stale cached images to be updated automatically? (yes/no) [default=yes] yes
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: no
$

Time to spin our k8s cluster!

ubuntu@ip-xxxx:~$ conjure-up kubernetes

As soon as the above command is fired, conjure-up GUI utility will be displayed to help us configure our cluster. The advantage of conjure-up over juju is it’s very simple to modify the custom configurations.

Select the basic installation ‘Canonical Distribution of Kubernetes’.

We’ll install Kubeflow here. There are multiple out of the box options like installing Helm alongside or a Prometheus stack etc. Choose as per your requirement.

Let us select localhost since we are deploying this on our Ubuntu box. If you wish to spin a cluster on AWS or any other public cloud select the appropriate option. The installer will ask for credentials like AWS Access Key/Secret Key in the further steps.

Select the network bridge created during LXD installation earlier.

We’ll select Flannel plugin.

Enter sudo password or else leave it blank if you have passwordless authentication set-up. I have SSH key pair based authentication, so I’ll leave it blank.

Provide the GitHub API access token here.

Enter the ksonnet version or let it select for you.

It will now show a list of all the components that will be deployed as a part of your cluster.

You can select each component and customize it eg: instance type, memory/vCPU cores etc.

Now let it bootstrap. This step will take some minutes.

Here we have initiated the conjuring up of all the spells! It will give a pretty verbose output of all the configuration steps happening in the backend on each of the component. Just watch the magic unfolding.

You’ll have status updating every now and then.

Finally after all the components are installed you can go back to your console and check the status of the cluster using juju.

Juju will also give you the status of your controller and other controllers if you have configured any. I have an AWS EC2 cluster of as well here which I spun it for testing.

Quickly install kubectl if it wasn’t installed with conjure-up.

ubuntu@ip-xxxx:~$ mkdir -p ~/.kubeubuntu@ip-xxxx:~$ juju scp kubernetes-master/0:config ~/.kube/configubuntu@ip-xxxx:~$ snap install kubectl --classic
error: access denied (try with sudo)
ubuntu@ip-xxxx:~$ sudo snap install kubectl --classic
kubectl 1.13.1 from Canonical✓ installed
ubuntu@ip-xxxx:~$ kubectl cluster-info
Kubernetes master is running at https://x.x.x.x:443
Heapster is running at https://x.x.x.x:443/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at https://x.x.x.x:443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://x.x.x.x:443/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
Grafana is running at https://x.x.x.x:443/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
InfluxDB is running at https://x.x.x.x:443/api/v1/namespaces/kube-system/services/monitoring-influxdb:http/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Set-up the dashboard.

ubuntu@ip-x.x.x.x:~$ juju config kubernetes-master enable-dashboard-addons=true
WARNING the configuration setting "enable-dashboard-addons" already has the value "true"
ubuntu@ip-x.x.x.x:~$ kubectl proxy --address=0.0.0.0 --accept-hosts='.*'
Starting to serve on [::]:8001
Or start it in nohup.

You can now start accessing, interacting and deploying your services in your k8s cluster!

Please leave comments if the guide was cheat sheet enough and if you need clarification on any steps/components above!

Join our community Slack and read our weekly Faun topics ⬇

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author! ⬇

--

--