The repository contains the necessary Terraform configuration for creating a multi-node Kubernetes cluster on Oracle Cloud.
The repo is based on this article by Arnold Galovic.
- Get the following data from your Oracle Cloud account
- User OCID
- Tenancy OCID
- Compartment OCID
You can get these automatically, based on your OCI configuration, and export them as environment variables for Terraform to consume, using
source scripts/oci_env.sh
- Initialise the Terraform working directory
terraform init
- Execute a
terraform apply
terraform apply
- Once done, run
source scripts/oci_env.sh
to expose a few convenience bash wrapper functions. These functions are wrappers aroundoci
commands, including generating kube config or create a bastion forwarding session. - Create the kube config using
oci_cluster_kubeconfig
This command with generate a kubeconfig using the cluster APIs private IP and then replace it with
127.0.0.1
/localhost
so that port-forwarding can be used. - Run
export KUBECONFIG="${HOME}/.kube/ociconfig"
to set the kube config to the generated config - Run
oci_bastion_session_kube_api -v
to create a bastion session (if one doesn't exist) and establish a port-forwarding session.I have noticed that if you create the session, the first ssh connection fails. Just re-run the script to connect.
- To verify cluster access, do a
kubectl get nodes
- Enjoy
There are some useful oci wrapper commands in the scripts directory.
You can run source scripts/oci_env.sh
to expose a few convenience bash wrapper functions
in the terminal.