Installing Kubernetes with kops
This quickstart shows you how to easily install a Kubernetes cluster on AWS.
It uses a tool called
kops is an automated provisioning system: Download kops from the
Download the latest release with the command: To download a specific version, replace the following portion of the command with the specific kops version. For example, to download kops version v1.20.0 type: Make the kops binary executable. Move the kops binary in to your PATH. You can also install kops using Homebrew. Download the latest release with the command: To download a specific version of kops, replace the following portion of the command with the specific kops version. For example, to download kops version v1.20.0 type: Make the kops binary executable Move the kops binary in to your PATH. You can also install kops using
kops uses DNS for discovery, both inside the cluster and outside, so that you can reach the kubernetes API server
from clients. kops has a strong opinion on the cluster name: it should be a valid DNS name. By doing so you will
no longer get your clusters confused, you can share clusters with your colleagues unambiguously,
and you can reach them without relying on remembering an IP address. You can, and probably should, use subdomains to divide your clusters. As our example we will use
A Route53 hosted zone can serve subdomains. Your hosted zone could be Let's assume you're using You must then set up your NS records in the parent domain, so that records in the domain will resolve. Here,
you would create NS records in Verify your route53 domain setup (it is the #1 cause of problems!). You can double-check that
your cluster is configured correctly if you have the dig tool by running: You should see the 4 NS records that Route53 assigned your hosted zone. kops lets you manage your clusters even after installation. To do this, it must keep track of the clusters
that you have created, along with their configuration, the keys they are using etc. This information is stored
in an S3 bucket. S3 permissions are used to control access to the bucket. Multiple clusters can use the same S3 bucket, and you can share an S3 bucket between your colleagues that
administer the same clusters - this is much easier than passing around kubecfg files. But anyone with access
to the S3 bucket will have administrative access to all your clusters, so you don't want to share it beyond
the operations team. So typically you have one S3 bucket for each ops team (and often the name will correspond
to the name of the hosted zone above!) In our example, we chose Export Create the S3 bucket using You can Run kops will create the configuration for your cluster. Note that it only creates the configuration, it does
not actually create the cloud resources - you'll do that in the next step with a It prints commands you can use to explore further: If this is your first time using kops, do spend a few minutes to try those out! An instance group is a
set of instances, which will be registered as kubernetes nodes. On AWS this is implemented via auto-scaling-groups.
You can have several instance groups, for example if you wanted nodes that are a mix of spot and on-demand instances, or
GPU and non-GPU instances. Run "kops update cluster" to create your cluster in AWS: That takes a few seconds to run, but then your cluster will likely take a few minutes to actually be ready.
For example, after you Without See the list of add-ons to explore other add-ons, including tools for logging, monitoring, network policy, visualization, and control of your Kubernetes cluster.
Before you begin
Creating a cluster
(1/5) Install kops
Installation
curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-darwin-amd64
$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)
curl -LO https://github.com/kubernetes/kops/releases/download/v1.20.0/kops-darwin-amd64
chmod +x kops-darwin-amd64
sudo mv kops-darwin-amd64 /usr/local/bin/kops
brew update && brew install kops
curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)
curl -LO https://github.com/kubernetes/kops/releases/download/v1.20.0/kops-linux-amd64
chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops
brew update && brew install kops
(2/5) Create a route53 domain for your cluster
useast1.dev.example.com
. The API server endpoint will then be api.useast1.dev.example.com
.useast1.dev.example.com
,
but also dev.example.com
or even example.com
. kops works with any of these, so typically
you choose for organization reasons (e.g. you are allowed to create records under dev.example.com
,
but not under example.com
).dev.example.com
as your hosted zone. You create that hosted zone using
the aws route53 create-hosted-zone --name dev.example.com --caller-reference 1.example.com
for dev
. If it is a root domain name you would configure the NS
records at your domain registrar (e.g. example.com
would need to be configured where you bought example.com
).dig NS dev.example.com
(3/5) Create an S3 bucket to store your clusters state
dev.example.com
as our hosted zone, so let's pick clusters.dev.example.com
as
the S3 bucket name.
AWS_PROFILE
(if you need to select a profile for the AWS CLI to work)aws s3 mb s3://clusters.dev.example.com
export KOPS_STATE_STORE=s3://clusters.dev.example.com
and then kops will use this location by default.
We suggest putting this in your bash profile or similar.(4/5) Build your cluster configuration
kops create cluster
to create your cluster configuration:kops create cluster --zones=us-east-1c useast1.dev.example.com
kops update cluster
. This
give you an opportunity to review the configuration or change it.
kops get cluster
kops edit cluster useast1.dev.example.com
kops edit ig --name=useast1.dev.example.com nodes
kops edit ig --name=useast1.dev.example.com master-us-east-1c
(5/5) Create the cluster in AWS
kops update cluster useast1.dev.example.com --yes
kops update cluster
will be the tool you'll use whenever you change the configuration of your cluster; it
applies the changes you have made to the configuration to your cluster - reconfiguring AWS or kubernetes as needed.kops edit ig nodes
, then kops update cluster --yes
to apply your configuration, and
sometimes you will also have to kops rolling-update cluster
to roll out the configuration immediately.--yes
, kops update cluster
will show you a preview of what it is going to do. This is handy
for production clusters!Explore other add-ons
Cleanup
kops delete cluster useast1.dev.example.com --yes
What's next
kubectl
.kops
kops
community discussions on Slack: kops
by addressing or raising an issue