Kubernetes provides excellent container orchestration, but setting up a Kubernetes cluster from scratch can be painful. One solution is to use Kubernetes Operations, or kOps.
What is kOps?
kOps, also known as Kubernetes operations, is an open-source project which helps you create, destroy, upgrade, and maintain a highly available, production-grade Kubernetes cluster. Depending on the requirement, kOps can also provision cloud infrastructure.
kOps is mostly used in deploying AWS and GCE Kubernetes clusters. But officially, the tool only supports AWS. Support for other cloud providers (such as DigitalOcean, GCP, and OpenStack) are in the beta stage at the time of writing this article. The developers of this open source project describe it as “kubectl for clusters” on their Github homepage which may be confusing for some but helpful for others. Let’s start by reviewing its benefits.
Benefits of kOps
Automates the provisioning of AWS and GCE Kubernetes clusters
Deploys highly available Kubernetes masters
Supports rolling cluster updates
Autocompletion of command in the command line
Generates Terraform and CloudFormation configurations
Manages cluster add-ons
Supports state-sync model for dry-runs and automatic idempotency
Creates instance groups to support heterogeneous clusters
How to Install kOps
Use the following steps to install kOps on your Linux machine. In this example, we are using Ubuntu 18.04.
Download kOps from the releases package.
Give executable permission to the downloaded kOps file and move it to /usr/local/bin/
Run the kOps command to verify the installation.
Check the kOps version.
You like our article?
Follow our LinkedIn monthly digest to receive more free educational content like this.
Below are the most widely-used kOps commands you should know.
This kOps command is used to register a cluster:
kOps create cluster <clustername>
There are many other parameters which you can add in addition to the default command, like zone, region, instance type, and number of nodes.
This kOps command is used to update the cluster with the specified cluster specification:
kOps update cluster --name <clustername>
We recommend running this command in preview mode when you need to triangulate your desired output. Run the command with the --yes flag to apply your changes to the cluster.
This kOps command is used to list all the clusters.
kOps get clusters
This command deletes a specified cluster from the registry along with all of its cloud resources.
kOps delete cluster --name <clustername>
You can also run this command in preview mode, just like update.
This kOps command is used to update a Kubernetes cluster to match the cloud and kOps specifications.
kOps rolling-update cluster --name <clustername>
You can run this command also in the preview mode just like update.
This command validates if the created cluster is up or not. If the nodes and pods are still in the pending state, the validate command returns that the cluster is not healthy yet.
kOps validate cluster --wait <specified_time>
This command waits and validates the cluster for 10 minutes.
Now that you know the basics of kOps commands, let’s look at how to create a Kubernetes cluster on AWS using kOps.
How to Set Up Kubernetes on AWS using kOps
Give the executable permission to the downloaded file and move it to /usr/local/bin/
Create an S3 Bucket using the AWS CLI where kOps will save all the cluster's state information. Use LocationConstraint to avoid any error with the region.
List the aws s3 bucket to see the bucket you have created.
Enable the version for the s3 bucket.
Generate ssh key for which will be used by kOps for cluster login and password generation.
Expose the cluster name and s3 bucket as environment variables. This is only applicable for the current session. The suffix ‘.k8s.local’ is used because we are not using any pre-configured DNS.
Use the kOps create command to create the cluster. Below are the parameters we used:
tells which cloud provider I am using
is the zone where the cluster instance will get deployed
is the number of nodes I want in the Kubernetes cluster I am deploying
--node-size / --master-size
are the ec2 instance types, I am using the micro instances
is the name of the cluster
Verify that the cluster was created.
Apply the specified cluster specifications to the cluster.
If you immediately check the Kubernetes nodes are running or not, you will get an error. You need to be a little patient and wait for a few minutes (5-10) till the cluster is created.
Validate the Cluster.
List the Nodes and Pods to check if all the nodes are ready and running. You can see both master and node are ready status.
You can check all the pods running in the Kubernetes cluster.
How to Delete a Cluster
Just like creating a Kubernetes cluster, deleting a Kubernetes cluster also using kOps is very simple. This will remove all the cloud resources of the cluster and the cluster registry itself.
In this article, you’ve learned that kOps is a great tool to use for managing Kubernetes clusters hosted on various public cloud platforms because of the ways it can reduce the complexity. You’ve also learned the top kOps commands to know when working with Kubernetes, as well as and how to set up kubernetes containers on AWS.
Automated, Intelligent Container Sizing
Kubernetes Vertical Pod Autoscaling doesn’t recommend pod limit values or consider I/O. Densify identifies mis-provisioned containers at a glance and prescribes the optimal configuration.