Skip to content

How to create a Kubernetes cluster on the cloud

Last validated:
View as Markdown

WHAT TO EXPECT

In this article, users will learn how to create a simple Kubernetes cluster on each cloud provider. This is the first step needed to create a working environment where the agents can be Kubernetes pods.

Microsoft Azure (AKS)

In Azure, the fastest way to create a cluster is by using Cloud Shell. These lines can be used to create a simple Kubernetes cluster (users should change the , the node size and count accordingly):

export NAME="<project-name>"
export AZURE_RESOURCE_GROUP="${NAME}-rgroup"
az group create --name "${AZURE_RESOURCE_GROUP}"  -l centralus
az network vnet create --name <vnet-name> --resource-group "${AZURE_RESOURCE_GROUP}" --address-prefixes 10.128.0.0/12 --subnet-name <subnet-name> --subnet-prefixes 10.128.0.0/16
export SUBNET_ID="$(az network vnet subnet show -g ${AZURE_RESOURCE_GROUP} -n <subnet-name> --vnet-name <vnet-name> --query id --output tsv)"
az aks create --generate-ssh-keys --resource-group "${AZURE_RESOURCE_GROUP}" --network-plugin none --name "${NAME}" --vnet-subnet-id "${SUBNET_ID}" --node-vm-size Standard_Ds2_v2 --node-count 2
az aks get-credentials --resource-group "${AZURE_RESOURCE_GROUP}" --name "${NAME}"

This will create a resource group, and, inside, a VNet, and the Kubernetes cluster. All the names will have the NAME as part of the resource name.

Amazon AWS (EKS)

In AWS, users can create a Kubernetes cluster using Cloud Shell with a couple of commands. As a requirement, the users have to first download the EKSCTL utility. To that end, use:

echo "curl -sLO https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz
tar -xzf eksctl_$(uname -s)_amd64.tar.gz -C /tmp
rm eksctl_$(uname -s)_amd64.tar.gz
sudo mv /tmp/eksctl /usr/local/bin" > eksctl_simple.sh
chmod +x eksctl_simple.sh
./eksctl_simple.sh

Then, to create the cluster, use the following lines, changing the accordingly, setting the desiredCapacity to the desired number of nodes, and changing the publicKeyPath to the correct one:

cat <<EOF >eks-config.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: <cluster-name>
  region: <region-name>
managedNodeGroups:
- name: <nodegroup-name>
  desiredCapacity: 2
  privateNetworking: true
  ssh:
    allow: true
    publicKeyPath: ~/.ssh/id_rsa.pub
EOF
eksctl create cluster -f ./eks-config.yaml

Google GCP (GKE)

In GCP, the command line used in the Cloud Shell to create a Kubernetes cluster will vary depending on the CNI that will be used.

Traditional CNI (GKE default)

The command used when using the Traditional CNI is the following (remember to change the accordingly, and the number of nodes):

gcloud container clusters create <cluster-name> --zone <zone-name> --num-nodes 2

Cilium CNI

When using the Cilium CNI, the cluster is created using the tainted argument, and later the user should install Cilium:

gcloud container clusters create <cluster-name> --zone <zone-name> --num-nodes 2 --node-taints node.cilium.io/agent-not-ready=true:NoExecute

Oracle OCI (OKE)

Users can create a Kubernetes cluster in OKE using the OCI console.

Click on the menu button (top left):

OCI console home page with an arrow pointing to the navigation menu icon

Click the Developer Services:

OCI navigation menu with an arrow pointing to Developer Services

Click on Kubernetes Clusters (OKE):

OCI Developer Services menu with an arrow pointing to Kubernetes Clusters (OKE)

Click on the Create cluster button:

OCI Kubernetes Clusters (OKE) page, with no clusters yet, and an arrow pointing to the Create cluster button

Leave the Quick create selected and click on Proceed:

OCI Create cluster dialog with arrows pointing to Quick create and the Proceed button

Then:

  • Type a name
  • Choose a Compartment
  • Choose a version
  • Select the Public endpoint in the Kubernetes API endpoint
  • Select Managed in the Node Type
  • Select Private workers in the Kubernetes worker nodes

OCI Create cluster (quick) page with arrows pointing to the name, compartment, Kubernetes version, public API endpoint, managed node type and private workers

Choose the desired shape (for example, VM.Standard.E3.Flex, 4 OCPUs, 16GB RAM, Image: Oracle Linux 7.9) and select the desired Node count:

OCI Create cluster (quick) Shape and image section with arrows pointing to the node shape, number of OCPUs, memory and operating system, and the node count

Click on the Advanced options button and in the Add an SSH key choose your method, for example, Paste a public key and paste it in the box below:

OCI Create cluster (quick) advanced options with arrows pointing to the Advanced options heading, Paste a public key and the SSH key field

Then click on Next:

OCI Create cluster (quick) Kubernetes labels section with an arrow pointing to the Next button

Finally, click on the Create cluster button:

OCI Review and create page listing the cluster to be created, with an arrow pointing to the Create cluster button