-
Notifications
You must be signed in to change notification settings - Fork 0
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.
-
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.
To set up kubectl
to interact with a DOKS cluster, follow these steps:
-
Authenticate with DigitalOcean:
doctl auth init
This command initializes
doctl
with your DigitalOcean account credentials. -
List Available Kubernetes Clusters:
doctl kubernetes cluster list
This command displays all Kubernetes clusters associated with your DigitalOcean account.
-
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, enablingkubectl
to interact with the cluster. -
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.
-
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.
The Terraform configuration for creating and managing DOKS clusters is located in the following directory within this repository:
/terraform/doks