Skip to content
Hüseyin Deniz KIVRAK edited this page Nov 17, 2024 · 2 revisions

What is DOKS?

DigitalOcean Kubernetes Service (DOKS) is a managed Kubernetes service provided by DigitalOcean. It simplifies the deployment, management, and scaling of Kubernetes clusters on DigitalOcean's infrastructure.

In this setup, DOKS clusters are created and managed using Terraform, with the doctl CLI tool facilitating authentication and integration with the DigitalOcean platform.


Key Points About the doctl CLI Tool

  • Purpose: The doctl CLI is the command-line interface for managing DigitalOcean resources.
  • Use Cases:
    • Authenticate with DigitalOcean to grant Terraform the necessary permissions for creating and managing DOKS clusters.
    • Retrieve DOKS cluster credentials and configure the local kubectl context for interaction with the Kubernetes API.

Configuring kubectl Context for DOKS

To set up kubectl to interact with a DOKS cluster, follow these steps:

  1. Authenticate with DigitalOcean:

    doctl auth init

    This command initializes doctl with your DigitalOcean account credentials.

  2. List Available Kubernetes Clusters:

    doctl kubernetes cluster list

    This command displays all Kubernetes clusters associated with your DigitalOcean account.

  3. Retrieve and Save Cluster Credentials:

    doctl kubernetes cluster kubeconfig save <CLUSTER_NAME>

    Replace <CLUSTER_NAME> with the name of your DOKS cluster. This command fetches the cluster's kubeconfig and merges it into your local kubeconfig file, enabling kubectl to interact with the cluster.

  4. Verify the Context:

    kubectl config get-contexts

    This command lists all contexts available in your kubeconfig file, allowing you to confirm the addition of your DOKS cluster.

  5. Switch to the DOKS Cluster Context:

    kubectl config use-context do-<REGION>-<CLUSTER_NAME>

    Replace <REGION> and <CLUSTER_NAME> with your cluster's region and name, respectively. This sets the current context to your DOKS cluster.


Terraform Files

The Terraform configuration for creating and managing DOKS clusters is located in the following directory within this repository:

/terraform/doks

Additional Resources