LinuxCommandLibrary

doctl-kubernetes-cluster

Create and manage Kubernetes clusters

TLDR

Create a Kubernetes cluster

$ doctl [[k|kubernetes]] [[c|cluster]] [[c|create]] --count [3] --region [nyc1] --size [s-1vcpu-2gb] --version [latest] [cluster_name]
copy

List all Kubernetes clusters
$ doctl [[k|kubernetes]] [[c|cluster]] [[ls|list]]
copy

Fetch and save the kubeconfig
$ doctl [[k|kubernetes]] [[c|cluster]] [[cfg|kubeconfig]] [[s|save]] [cluster_name]
copy

Check for available upgrades
$ doctl [[k|kubernetes]] [[c|cluster]] [[gu|get-upgrades]] [cluster_name]
copy

Upgrade a cluster to a new Kubernetes version
$ doctl [[k|kubernetes]] [[c|cluster]] upgrade [cluster_name]
copy

Delete a cluster
$ doctl [[k|kubernetes]] [[c|cluster]] [[d|delete]] [cluster_name]
copy

SYNOPSIS

The doctl kubernetes cluster command is a group of subcommands that enable various operations. Here are common usage patterns:

Create a new cluster:
doctl kubernetes cluster create <cluster-name> --region <slug> --version <k8s-version> --node-pool <name>:<size>:<count>

List all clusters:
doctl kubernetes cluster list

Retrieve details of a specific cluster:
doctl kubernetes cluster get <cluster-id|name>

Delete a cluster:
doctl kubernetes cluster delete <cluster-id|name>

PARAMETERS

--output, -o <format>
    Specifies the output format for command results. Supported formats include json, csv, text (default), and pretty. This is a global doctl flag.

--access-token <token>
    Authenticates with the DigitalOcean API using the provided access token. Overrides environment variables or config file settings. This is a global doctl flag.

--config <path>
    Specifies the path to the doctl configuration file, overriding the default location (~/.config/doctl/config.yaml). This is a global doctl flag.

--trace
    Enables tracing of HTTP requests made by doctl for debugging purposes. This is a global doctl flag.

--help, -h
    Displays help information for the kubernetes cluster subcommand group or its specific subcommands. This is a standard flag.

Subcommand specific options
    Each subcommand within doctl kubernetes cluster (e.g., create, update) has its own distinct set of flags for configuration. Common examples include --region (DigitalOcean datacenter slug), --version (Kubernetes version), --node-pool (configuration for cluster worker nodes), --auto-upgrade, and --ha-control-plane.

DESCRIPTION

The doctl kubernetes cluster command provides the official command-line interface for managing DigitalOcean Kubernetes (DOKS) clusters. As a core subcommand group of the broader doctl utility, it streamlines the creation, retrieval, listing, updating, and deletion of Kubernetes clusters on the DigitalOcean cloud platform.

This command simplifies interaction with the DigitalOcean API, allowing users to automate DOKS lifecycle management, integrate cluster operations into scripts, and perform tasks more efficiently than through the web interface. It serves as the primary tool for developers and operators to provision and control their Kubernetes infrastructure on DigitalOcean, offering granular control over cluster versions, node pools, regions, and other configuration parameters.

CAVEATS

Using doctl kubernetes cluster requires an active DigitalOcean account and a valid API token with appropriate permissions. Creating Kubernetes clusters and node pools incurs costs on your DigitalOcean account, so monitor your usage. Deleting resources is permanent and irreversible. Always verify the cluster name or ID before performing destructive operations like deletion. Ensure network connectivity to the DigitalOcean API endpoint for successful command execution.

SUBCOMMANDS OVERVIEW

The doctl kubernetes cluster command acts as a parent for several crucial subcommands, each performing a specific action on Kubernetes clusters:

  • create: Provisions a new DigitalOcean Kubernetes cluster with specified configurations.
  • list: Displays a list of all existing Kubernetes clusters in your DigitalOcean account.
  • get: Retrieves detailed information about a specific Kubernetes cluster using its ID or name.
  • update: Modifies the configuration of an existing Kubernetes cluster, such as adding or updating node pools, or enabling auto-upgrade.
  • delete: Permanently removes a Kubernetes cluster and all its associated resources. This action is irreversible.
  • kubeconfig: Generates or updates the kubeconfig file for a cluster, enabling tools like kubectl to connect and manage workloads within the cluster.

AUTHENTICATION

doctl authenticates with the DigitalOcean API using an access token. This token can be provided in several ways, in order of precedence: via the --access-token command-line flag, as an environment variable (DO_API_TOKEN), or configured within the doctl configuration file (typically located at ~/.config/doctl/config.yaml). It is paramount to keep your API token secure as it grants full programmatic access to your DigitalOcean account resources.

HISTORY

The doctl CLI was developed by DigitalOcean to provide a programmatic interface for managing their cloud resources. As DigitalOcean Kubernetes (DOKS) evolved into a core offering, the kubernetes cluster subcommand group was integrated into doctl, allowing users to provision and manage DOKS clusters directly from the command line. Its development tracks the continuous enhancements and new features rolled out for the DOKS service, making it an essential and up-to-date tool for DOKS users.

SEE ALSO

doctl(1), kubectl(1), terraform(1), helm(1)

Copied to clipboard