kops
Create, manage, and delete Kubernetes clusters
TLDR
Create a cluster from the configuration specification
Create a new SSH public key
Export the cluster configuration to the ~/.kube/config file
Get the cluster configuration as YAML
Delete a cluster
Validate a cluster
SYNOPSIS
kops command [flags]
Common commands include:
kops create cluster|instancegroup
kops update cluster
kops get cluster|instancegroup|clusters|instancegroups
kops edit cluster|instancegroup
kops delete cluster|instancegroup
kops validate cluster
kops export kubecfg
kops rolling-update cluster
PARAMETERS
--name
Specifies the name of the Kubernetes cluster to operate on. This is usually a fully qualified domain name (e.g., 'mycluster.k8s.local').
--state
Defines the location of the state store, typically an S3 or GCS bucket, where `kops` stores cluster configuration and state.
--cloud
Sets the cloud provider for the cluster (e.g., 'aws', 'gce', 'azure').
--zones
A comma-separated list of cloud zones where the cluster will be deployed (e.g., 'us-east-1a,us-east-1b').
--node-count
Specifies the number of worker nodes to create in the cluster's main instance group.
--yes
Bypasses interactive confirmation prompts for operations that modify the cluster.
--target
Specifies the output format for cluster configuration, such as 'terraform' to generate Terraform configuration files.
--dry-run
Shows what changes would be applied without actually performing them, useful for validating operations.
--out
Specifies the output directory for generated files, like Terraform configurations.
--kubeconfig
Overrides the default kubeconfig file location for accessing the cluster.
DESCRIPTION
kops (Kubernetes Operations) is an official Kubernetes project that provides a command-line tool for creating, destroying, upgrading, and maintaining production-grade Kubernetes clusters. It aims to automate the entire lifecycle of a Kubernetes cluster, from initial provisioning to ongoing management and updates. kops supports various cloud providers, including AWS, GCE, Azure, OpenStack, Alicloud, and DigitalOcean, with AWS being its most mature and widely used integration. It allows users to define their cluster configuration declaratively using YAML, enabling idempotent and reproducible cluster deployments. Key features include support for different networking plugins (e.g., Calico, Flannel, Weave, Cilium), multiple DNS options, and comprehensive management of master and worker node groups. kops significantly simplifies the complex task of setting up and operating Kubernetes clusters, making it a popular choice for self-hosting Kubernetes on cloud infrastructure. It manages all necessary cloud resources such as EC2 instances, VPCs, subnets, route tables, security groups, and load balancers.
CAVEATS
Using `kops` requires appropriate credentials and permissions configured for your chosen cloud provider. The cluster state is stored in a designated S3 or GCS bucket, which is critical for all `kops` operations; accidental deletion of this bucket can lead to data loss and inability to manage the cluster. While powerful, `kops` can have a steep learning curve for complex, highly customized cluster setups, especially when dealing with advanced networking or security configurations. It's generally not recommended for lightweight local development environments, where tools like Minikube or kind are more suitable. Upgrades can sometimes be challenging and require careful planning and backups.
STATE STORE IMPORTANCE
The state store (typically an S3 or GCS bucket) is fundamental to `kops`. It acts as the single source of truth for your cluster's configuration, including instance group definitions, network settings, and cluster details. All `kops` commands interact with this state store. It's crucial to protect this bucket and manage its lifecycle carefully, as its integrity directly impacts your ability to manage the Kubernetes cluster.
DECLARATIVE CLUSTER MANAGEMENT
`kops` promotes a declarative approach to cluster management. Instead of issuing imperative commands, you define your desired cluster state in YAML configuration files. `kops` then analyzes the difference between the desired state and the current state (as stored in the state store or observed in the cloud) and applies the necessary changes to reconcile them. This makes cluster configurations versionable, repeatable, and easier to manage across environments.
HISTORY
`kops` was initially developed to simplify the deployment of Kubernetes clusters on AWS. It began as a project within the Kubernetes Incubator and quickly gained traction due to its ability to provision production-ready clusters with ease. The project has evolved significantly alongside Kubernetes itself, continually adding support for new Kubernetes features, cloud providers, and best practices for cluster management. Its primary goal has always been to provide a robust, automated, and declarative way to manage Kubernetes clusters, making it a cornerstone for many organizations adopting self-managed Kubernetes on cloud infrastructure.