Practice Kubernetes without setup on actual cluster for less than dollar for 10 hours

Rahul Metangale
3 min readJul 22, 2020

--

If you are learning Kubernetes development and want to practice Kubernetes without spending time in setting up Kubernetes then this article will walk you through the steps.

Environment:

Azure AKS: Use this link to understand cost per 10 hrs. Its 0.96$ per 10 hours for single node cluster

Visual Studio Codespaces : This is optional. If you have Windows 10 with WSL2 then that can be used. This will be used to interact with cluster using kubectl. Visit this link for codespaces pricing.

Steps to setup environment:

Azure Kubernetes Setup

From Azure portal, search for “Kubernetes Services”. Click on Add — Add Kubernetes Cluster — Fill in the required details. Important points highlighted in screen shot below

Node size and Node count

On next screen “Node Pool” disable VM scaleset (for practice we don’t need it)

Disable VM Scale Set

On next screens “Authentication” and “Networking” keep defaults. On Integration screen, disable container monitor

Disable Container Monitor

Now click on “Review and Create”

This will create Azure AKS cluster.

Now from Azure portal, click on cloudshell. Select PowerShell and run following command

Get cluster credentials

This will add cluster related information to config file. And display path to file as an output.

Next run following command from cloudshell .

cat <path to config file. This path is displayed when get-credentials command is run>

Copy the YAML config output. Output will be used in later stage to make development environment aware about kubernetes cluster

Visual Studio Codespaces:

If you don’t want to use codespaces then you can use Visual studio code with WSL2 on windows 10 and skip to “Connect to AKS Cluster steps”. If you are using mac or linux already with VS code i think you can directly skip to next step. For this article we will stick to code spaces.

To setup code spaces, please log in to https://online.visualstudio.com. You can use the same account that was used to access Azure Portal.

Then select create new plan option. Select the subscription, location and from advanced options select the default instance type. Once plan is created click on option “Create Codespace” fill the mandatory details and click on create.

Once codespaces is created you can use “Visual code insider” that vs code in browser or you can connect to your local vs code instance.

From visual studio code open terminal.

Connect to AKS Cluster

Steps given below are common steps, so even if you are using windows 10 with WSL2 or mac with vs code follow steps given below. From VS code terminal run following command:

code ~/.kube/config
# Now paste the yaml config output (last step from AKS setup) here and save the file using `ctrl + s`

Now you are all set and you can interact with the cluster and run kubectl commands example:

kubectl get nodes

If you get en error indicating kubectl is not installed then follow steps given here.

Finally once you are done you can either delete the entire AKS environment or you can stop the node VM. Stopping VM will still incur some cost related to storage.

I hope you find this useful.

--

--

Rahul Metangale
Rahul Metangale

Written by Rahul Metangale

Solution Architect @AWS | GIS expert | Deep Learning enthusiast

No responses yet