Building on the theme of recent posts, I want to use Terraform and Ansible to automate the provisioning and setup of a free k8s cluster on Oracle Cloud. But, it did not work out. Some Googling later, there was the option of Oracle Kubernetes Engine (OKE) and using the free VMs as nodes! Lets do it manually.
Table of contents
Open Table of contents
One small step for mankind, one giant leap for a new DevOps engineer
After logging into the dashboard, I recommend creating a new compartment to house this all in. I would also recommend creating a new one each time you recreate the cluster as there are bits that don’t seem to be removed when you delete the cluster and it would be easier to clean up with it all logically separate.
- From here, search for the kubernetes cluster screen and click ‘Create cluster’. I chose quick create so that it had all the resources we need.
- Name the cluster, this is also used as part of the name for a lot of the other resources that are automagically created.
- Assign it to your new compartment
- choose the latest version
- I chose Public endpoint
- Managed node type
- Private worker nodes
- For the shape, we want to create 2 of the 2 core, 12GB ram ARM VMs.
- shape is VM.Standard.A1.Flex
- OCPUs = 2
- memory = 12
- image = Oracle Linux 8
- node count = 2
- IMPORTANT: you will need to select the checkbox to make it a basic cluster, not enhanced. Only the basic type is free!
- Then click create and wait.
I have a cluster, now what?
If you click on the cluster name you get access to the ‘Access Cluster’ button that will give you the CLI commands to connect to your cluster and copy the .kube/config
file to allow you to administer the cluster via kubectl
or a GUI like Lens.
I used the Lens GUI to help me see what was going on in the cluster.
Traffic, Traefik
Now that you have a cluster, how do you route things through it? Traefik is a solution that worked for me. On my local machine I installed Helm and then used this to install and configure Traefik.
- Create the traefik namespace with
kubectl create ns traefik-v2
. (This can also be done with the GUI) - Add the traefik helm repo with
helm repo add traefik https://traefik.github.io/charts
.
kubectl create ns traefik-v2
helm repo add traefik https://traefik.github.io/charts
Now if you reconnect the Lens application you can see there is a new helm chart in that section for traefik.
Clicking on it gives you the full details and allows you to install it. This will pull up a code window with the values file.
The only values I needed to set were spec.routes.match
and spec.entryPoints
. I added Host('MY.DOMAIN)
and changed the entrypoint from traefik
to websecure
.
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: dashboard
spec:
entryPoints:
- web
routes:
- match: Host(`traefik.localhost`) && (PathPrefix(`/dashboard`) || PathPrefix(`/api`))
kind: Rule
services:
- name: api@internal
kind: TraefikService
Finshed
And we are done, that is a working K8s cluster running for free!