Skip to content

A free k8s cluster on Oracle Cloud via Terraform and Ansible - Part 2, Working, but not IaC

Updated: at 07:29 AM (3 min read)

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.

  1. 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.
  2. Name the cluster, this is also used as part of the name for a lot of the other resources that are automagically created.
  3. Assign it to your new compartment
  4. choose the latest version
  5. I chose Public endpoint
  6. Managed node type
  7. Private worker nodes
  8. For the shape, we want to create 2 of the 2 core, 12GB ram ARM VMs.
    1. shape is VM.Standard.A1.Flex
    2. OCPUs = 2
    3. memory = 12
    4. image = Oracle Linux 8
    5. node count = 2
  9. IMPORTANT: you will need to select the checkbox to make it a basic cluster, not enhanced. Only the basic type is free!
  10. 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.

  1. Create the traefik namespace with kubectl create ns traefik-v2. (This can also be done with the GUI)
  2. 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!

Resources

Adding some basic auth to the Trafik Dash