Skip to content

Instantly share code, notes, and snippets.

@marcoceppi
Last active June 1, 2017 22:07
Show Gist options
  • Save marcoceppi/4151a1070b9743953ff1cdb992d18168 to your computer and use it in GitHub Desktop.
Save marcoceppi/4151a1070b9743953ff1cdb992d18168 to your computer and use it in GitHub Desktop.
Mult-node manual deployment

Overture

This is a means to get a cluster running on a handful of machines. It's a very bespoke way to craft a deployment and trades a lot of automation features for the ability to deploy kubernetes /literally/ anywhere Ubuntu is running. As this is a manual deployment, we can't directly use conjure-up. We'll have to dip down into the lower level tooling and use Juju directly.

Prerequisites

You will need at least three VMs running Ubuntu 16.04. The size of the VM is up to you but 2 vcpu 4 gb ram and 40gb disk is a good starting point. Each of these VMs will need your SSH key added to them. For this guide we will assume the machines are as follows:

machine name machine ip
controller-0 xxx.xxx.xxx.xxx
machine-0 yyy.yyy.yyy.yyy
machine-1 zzz.zzz.zzz.zzz

While you can technically re use the controller-0 machine it is not recommended. It is assumed but not required for the username of each instance to be ubuntu.

Finally, you'll need either Juju or conjure-up installed. You can get both by issuing sudo snap install conjure-up --classic or brew install conjure-up.

Bootstrap Controller

As there's not "cloud" to dynamically provision us a machine for the controller, we'll need to build one manually. In Juju this is pretty straight forward, issue the following:

juju bootstrap manual/xxx.xxx.xxx.xxx kubernetes-dev

If you have proxy requirements, or other contstraints, see the manual bootstrap process for Juju.

Once the controller is bootstrapped, issue a juju status you should see an empty output, like below:

Model    Controller      Cloud/Region            Version
default  kubernetes-dev  manual/xxx.xxx.xxx.xxx  2.1.2

App  Version  Status  Scale  Charm  Store  Rev  OS  Notes

Unit  Workload  Agent  Machine  Public address  Ports  Message

Machine  State  DNS  Inst id  Series  AZ

If you don't have this output, see assistance.

Adding machines

Normally, at this point is when you'd invoke conjure-up. However, since there is no way to dynamically generate machines (no cloud provider) we need to first tell Juju about the machines you've pre-created. You can do this by running the add-machine command:

juju add-machine ssh:[email protected]
juju add-machine ssh:[email protected]

After a few moments time you should see two machines allocated in the output of juju status:

Model    Controller      Cloud/Region            Version
default  kubernetes-dev  manual/xxx.xxx.xxx.xxx  2.1.2

App  Version  Status  Scale  Charm  Store  Rev  OS  Notes

Unit  Workload  Agent  Machine  Public address  Ports  Message

Machine  State    DNS              Inst id       Series  AZ
0        started  yyy.yyy.yyy.yyy  manual        xenial 
1        started  zzz.zzz.zzz.zzz  manual        xenial 

Deploying Kubernetes

At this time we can deploy Kubernetes. If you wish to make arcitecture changes you'll need to do so by downloading the bundle and modifying the deployment yaml. That's a topic for another day.

juju deploy ~containers/kubernetes-master --to 0
juju deploy etcd --to 0
juju deploy ~containers/easyrsa --to lxd:0
juju deploy ~containers/kubernetes-worker --to 1
juju deploy ~containers/flannel

At this point you'll have the core components deployed, but will need to provide the configuration you want for your deployment.

juju config kubernetes-master channel=1.6/stable
juju config kubernetes-worker channel=1.6/stable

At this point you'll have the core components deployed and configured, but will need to create the required relations in order for each component to properly configure itself.

juju add-relation kubernetes-master:kube-api-endpoint kubernetes-worker:kube-api-endpoint
juju add-relation kubernetes-master:kube-control kubernetes-worker:kube-control
juju add-relation kubernetes-master:certificates easyrsa:client
juju add-relation kubernetes-master:etcd etcd:db
juju add-relation kubernetes-worker:certificates easyrsa:client
juju add-relation etcd:certificates easyrsa:client
juju add-relation flannel:etcd etcd:db
juju add-relation flannel:cni kubernetes-master:cni
juju add-relation flannel:cni kubernetes-worker:cni

You'll now have to wait upwards of 10 mins for the charms to complete their configuration. For most simply watching the juju status output until all lines report started and idle is a good signal things are complete.

watch -c juju status --color

Accessing the cluster

At this point the manual deployment is complete, and you can pick up from any one of the CDK guides. However, for completeness, you'll need to download the kubernetes configuration file and install the kubernetes control binary (kubectl).

juju scp kubernetes-master/0:config ~/.kube/config

This will download a copy of the Kubernetes configuraiton file to your workstation. At this point, if you haven't already, install kubectl. There are a number of ways to do this, but if you're on Ubuntu it's as simple as sudo snap install kubectl --classic. At this point, verify your deployment is complete with:

kubectl cluster-info
kubectl get nodes

Scalling Kubernetes

If you're looking to add more capacity to a cluster, you'll need to first follow the Adding Machines topic to add another empty Ubuntu 16.04 machine to Juju. Then issue the following:

juju add-unit kubernetes-worker --to 2

Where 2 is the machine number you just added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment