How to create a Kubernetes cluster on the cloud

Prev Next

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 easiest and 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 <project-name> with something meaningful):

export NAME="<project-name>"
export AZURE_RESOURCE_GROUP="${NAME}-rgroup"
az group create --name "${AZURE_RESOURCE_GROUP}"  -l centralus
az network vnet create --name xnic-vnet-centralus --resource-group "${AZURE_RESOURCE_GROUP}" --address-prefixes 10.128.0.0/12 --subnet-name xnic-subnet --subnet-prefixes 10.128.0.0/16
export SUBNET_ID="$(az network vnet subnet show -g ${AZURE_RESOURCE_GROUP} -n xnic-subnet --vnet-name xnic-vnet-centralus --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 very easily. As a requirement, first, the users have to download the EKSCTL utility. To that extent, 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 <xxx-name> 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 <xxx-name> 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 Ciilium:

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):

Click the Developer Services:

Click on Kubernetes Clusters (OKE):

Click on the Create cluster button:

Leave the Quick create selected and click on Proceed:

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

Choose the desired shape (for example, VM.Standard.E3.Flex, 4 OCPUs, 16GB RAM, Image: Oracle Linux 7.9 and select tne desired 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:

Then click on Next:

Finally, click on the Create cluster button: