Deploy a Kubernetes cluster on OCI Free Tier using Terraform & Ansible
Table of Contents
Oracle has started restricting Free Tier accounts from launching new instances in most Regions. If you get a Resouce Capacity error the only solution so far is to upgrade your account to Pay As You Go. You should then be able to launch the resources. As long as you use the Always Free resources you still won't be charged even though your account is now upgraded.
The following must already be present on your system
-
Clone this repository
git clone https://github.com/solamarpreet/kubernetes-on-oci.git
cd kubernetes-on-oci/terraform
-
Change the values in
terraform.tfvars
as per your needsnano terraform.tfvars
-
Rename
secret.tfvars.example
tosecret.tfvars
and populate it with valuesmv secret.tfvars.example secret.tfvars
nano secret.tfvars
-
Configure Remote Backend by adding your Terraform Cloud Backend details in the backend.tf file
nano backend.tf
terraform login
or delete the backend.tf file if Remote Backend is not needed
rm backend.tf
-
Initialize terraform
terraform init
-
Apply terraform configuration
terraform apply --var-file=secret.tfvars
-
Install either Microk8s or K3s on the created infrastructure depending on your preference
cd ../ansible
# Recommended ansible-playbook playbooks/microk8s.yml
or
ansible-playbook playbooks/k3s.yml
-
Copy the kubeconfig file to ~/.kube/config
mkdir -p ~/.kube && cp kubeconfig ~/.kube/config
-
Start using kubectl commands
kubectl get nodes
Check the open issues for a list known issues and open a new issue if necessary.
- Add Ansible playbook for provisioning a private container registry on the VM.Standard.E2.1.Micro instance
Please create pull requests in the dev
branch. You can also give your ideas by opening a new issue and describing the features you would like to see added.
Distributed under the MIT License. See LICENSE
for more information.
Amarpreet Singh - solamarpreet@gmail.com
Blog & Portfolio : https://solamarpreet.github.io