Skip to content

Oracle cloud infraestructure kubernetes cluster free for life

Notifications You must be signed in to change notification settings

fernandobsb/ocik8sffl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ocik8sffl - Oracle cloud infraestructure kubernetes cluster free for life

This is a Terraform configuration to deploy a Kubernetes cluster on Oracle Cloud Infrastructure. It creates a few virtual machines and uses kubeadm to install a Kubernetes control plane on the first machine, and join the other machines as worker nodes.

By default, it deploys a 4-node cluster using ARM machines. Each machine has 1 OCPU and 6 GB of RAM, which means that the cluster fits within Oracle's (pretty generous if you ask me) free tier.

It is not meant to run production workloads, but it's great if you want to learn Kubernetes with a "real" cluster (i.e. a cluster with multiple nodes) without breaking the bank, and if you want to develop or test applications on ARM.

Getting started

  1. Create an Oracle Cloud Infrastructure account (just follow this link).
  2. After logging in, click on the cloud shell console.
  3. Download this project and enter its folder.
  4. Find the ID or OCID of your root compartment, you will need it to run terraform.
  5. terraform init
  6. terraform apply -var="root_compartment_id=ocid1.tenancy.oc1..aaa..."

That's it!

At the end of the terraform apply, a kubeconfig file is generated in this directory path generated-files. To use your new cluster, you can do:

export KUBECONFIG=$PWD/generated-files/kubeconfig
kubectl get nodes

The command above should show you 4 nodes, named node1 to node4.

You can also log into the VMs. At the end of the Terraform output you should see a command that you can use to SSH into the first VM (just copy-paste the command).

Windows

The kubeconfig.tf file currently uses UNIX-specific commands which don't work on Windows. (See #2.) I'm going to try and find a better way to get the kubeconfig file; but meanwhile, you could try to run it in WSL2. (Sorry!)

Availability Domain

If you get a message like the following:

Error: 500-InternalError
│ ...
│ Service: Core Instance
│ Error Message: Out of host capacity.

...then you can try to switch to a different availability domain. This can be done by changing the availability_domain input variable. (Thanks @uknbr for the contribution!)

Customization

Check variables.tf to see tweakable parameters. You can change the number of nodes, the size of the nodes, or switch to Intel/AMD instances if you'd like. Keep in mind that if you switch to Intel/AMD instances, you won't get advantage of the free tier.

Stopping the cluster

terraform destroy

Implementation details

This Terraform configuration:

  • generates an OpenSSH keypair and a kubeadm token
  • deploys 4 VMs using Ubuntu 20.04
  • uses cloud-init to install and configure everything
  • installs Docker and Kubernetes packages
  • runs kubeadm init on the first VM
  • runs kubeadm join on the other VMs
  • installs the Weave CNI plugin
  • transfers the kubeconfig file generated by kubeadm
  • patches that file to use the public IP address of the machine

Caveats

There is no cloud controller manager, which means that you cannot create services with type: LoadBalancer; or rather, if you create such services, their EXTERNAL-IP will remain <pending>.

To expose services, use NodePort.

Likewise, there is no ingress controller and no storage class.

(These might be added in a later iteration of this project.)

Remarks

Oracle Cloud also has a managed Kubernetes service called Container Engine for Kubernetes (or OKE). That service doesn't have the caveats mentioned above; however, it's not part of the free tier.

Creditos

jpetazzo - Projeto original > https://github.com/jpetazzo/ampernetacle

About

Oracle cloud infraestructure kubernetes cluster free for life

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages