Back to articles
DevOps & Systems

Guide to Leveraging Oracle Cloud Free Tier to Build a Fully Free and Stable k3s Kubernetes Cluster

This guide provides a step-by-step walkthrough of building a stable, free k3s Kubernetes cluster on Oracle Cloud Free Tier, ideal for development, testing, or small-scale...

DPTCloud Engineering5 min read
Guide to Leveraging Oracle Cloud Free Tier to Build a Fully Free and Stable k3s Kubernetes Cluster

This guide provides a step-by-step walkthrough of building a stable, free k3s Kubernetes cluster on Oracle Cloud Free Tier, ideal for development, testing, or small-scale application deployment. With free resources like 2 vCPU, 12GB RAM, and 200GB storage per instance, Oracle Cloud offers a cost-free platform for Kubernetes experimentation. The guide covers account setup, instance configuration, k3s installation, network setup, and cluster verification, suitable for both beginners and DevOps professionals.

Create Account and Configure Oracle Cloud Free Tier

To begin, create an Oracle Cloud account at https://cloud.oracle.com/. After logging in, select the "Free Tier" package and verify your account details. Oracle Cloud Free Tier provides two types of free resources: 1 AMD instance with 2 vCPU, 12GB RAM, and 200GB storage, and 1 ARM instance with 4 vCPU, 24GB RAM, and 200GB storage. We will use the AMD instance for compatibility with common applications. In the "Compute" section, click "Create Instance" and select the Ubuntu 22.04 LTS image. Name the instance, choose a region such as US East (Fremont), and select "Free Tier" in the "Instance Shape" section. Ensure "Enable SSH Keys" is selected for secure SSH access. After creating the instance, you will receive a public IP address and can connect via SSH.

Install k3s on Oracle Cloud Free Tier

To install k3s, SSH into the created instance and run the following command to update the system:

sudo apt update && sudo apt upgrade -y

Then install k3s using the following command:

curl -sfL https://get.k3s.io | sh -

This command downloads and installs k3s automatically. After installation, k3s will run as a service and create a single-node cluster. To check the cluster status, run:

kubectl get nodes

The output will show the active node. To manage the cluster, back up the k3s configuration file at /etc/rancher/k3s/k3s.yaml and copy it to your local machine. Then, install kubectl on your local machine and configure it to access the cluster:

export KUBECONFIG=/path/to/k3s.yaml

Replace /path/to/k3s.yaml with the actual path. After configuration, you can run kubectl get pods --all-namespaces to verify running pods.

Set Up Networking and Access the Cluster

Oracle Cloud Free Tier provides a public IP for each instance. To access the cluster from outside, open the required ports. Configure the Security List in Oracle Cloud to open ports 80, 443 (HTTP/HTTPS), 6443 (Kubernetes API), and 30000–32767 (NodePort). You can access the cluster via the public IP and port 6443. To deploy an application, use the kubectl apply -f deployment.yaml command with a deployment definition. For example, deploy a simple application:

apiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: nginx-deployment\nspec:\n  replicas: 2\n  selector:\n    matchLabels:\n      app: nginx\n  template:\n    metadata:\n      labels:\n        app: nginx\n    spec:\n      containers:\n      - name: nginx\n        image: nginx:latest\n        ports:\n        - containerPort: 80

Save this file as nginx-deployment.yaml and run kubectl apply -f nginx-deployment.yaml. Then, create a service to access the application:

apiVersion: v1\nkind: Service\nmetadata:\n  name: nginx-service\nspec:\n  selector:\n    app: nginx\n  ports:\n    - protocol: TCP\n      port: 80\n      targetPort: 80\n  type: NodePort

Run kubectl apply -f nginx-service.yaml and verify with kubectl get services. The IP and NodePort will allow external access to the application.

Advanced Solutions and Maintenance

To ensure cluster stability, configure log rotation, backup configurations, and regularly update k3s. Use a cron job to back up the /etc/rancher/k3s/k3s.yaml file and other critical configuration files. Additionally, monitor resource usage with kubectl top nodes and kubectl top pods. If you need to expand the cluster, add a new instance and run the k3s agent command with the token from the main node. However, with Oracle Cloud Free Tier, you can only create one free instance, so the cluster will always be single-node. To improve availability, consider integrating with storage services like Cloudflare R2 or deploying additional components on affordable VPS instances.

References and Verification

To ensure your configuration works correctly, perform the following checks:

  • Run kubectl get nodes to verify node status.
  • Run kubectl get pods --all-namespaces to check running pods.
  • Run kubectl get services to verify deployed services.
  • Access the public IP and NodePort to test the application.

For more information on automated VPS backups to Cloudflare R2, refer to the article Guide to Configuring Borgmatic for Automated Daily VPS Backups to Cloudflare R2.

Related infrastructure & engineering guides: NVMe Cloud VPS for Docker, Nginx & Databases

DPTCloud Tier III Infrastructure

Recommended NVMe Cloud VPS Plans to Deploy This Setup

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02

VPS-2E

94.600 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 2 GB
  • SSD: 30 GB NVMe
ECO · vn-02Recommended

VPS-3E

170.500 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 4 GB
  • SSD: 50 GB NVMe
BASIC · vn-01Recommended

VPS-05

457.600 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478