Skip to content

CloudNativeWales/K8s-Workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spin Up Kubernetes Cluster in AKS

If you need to create a trial Azure account sign up here

Follow these steps to spin up a Kubernetes Cluster in AKS with 2 nodes.

You can use Shell in Azure Portal or Azure CLI

Create ResourceGroup

az group create --name k8sWorkshop --location westeurope

If the response includes the following then the ResourceGroup has been created successfully

"properties": {
    "provisioningState": "Succeeded"
  },

Create a 2-node cluster

az aks create --resource-group k8sWorkshop --name myAKSCluster --node-count 2 --enable-addons monitoring --generate-ssh-keys

Leave this running, might take a few minutes (10-15 mins) to create the cluster. When running you should see this:

 - Running ..

Connect to cluster

If you are using Azure Cloud Shell, you are good to go

If you are using Azure CLI then install kubectl:

az aks install-cli

Connect to cluster using:

az aks get-credentials --resource-group k8sWorkshop --name myAKSCluster

You should get a response like this:

Merged "myAKSCluster" as current context in /home/salman/.kube/config

Run the following command to get nodes:

kubectl get nodes

You should see the nodes

NAME                       STATUS    ROLES     AGE       VERSION
aks-nodepool1-35631116-0   Ready     agent     23m       v1.12.7
aks-nodepool1-35631116-1   Ready     agent     23m       v1.12.7

Deploy a sample app

We will deploy a simple voting app with the following command

kubectl apply -f https://raw.githubusercontent.com/CloudNativeWales/K8s-Workshop/master/azure-vote.yaml

You should get a message that says a front end and a back end service has been created

Website is currently deploying and is not yet ready to be accessed externally yet.

Run the following command and you will see that EXTERNAL-IP is in 'pending' state

kubectl get service azure-vote-front --watch

It might take some time for the application to get externally available. Once it is, you will be able to navigate to website.

If the azure-vote-front takes more than 5 minutes to be assigned an external ip, delete the deployment and try again.

kubectl delete -f https://raw.githubusercontent.com/CloudNativeWales/K8s-Workshop/master/azure-vote.yaml

Kubernetes Dashboard

If you have Azure CLI installed you can access your cluster's k8s dashboard. Gives you a host of information and functionality. Run the following commands:

ONLY FOR AZURE CLI

az aks get-credentials --resource-group k8sWorkshop --name myAKSCluster

az aks browse --resource-group k8sWorkshop --name myAKSCluster

If you are getting errors when accessing dashboard, use the following:

kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard

Try some of the features from the dashboard. Can you scale one of your deployments?

Be careful with the dashboard though, you don't want to end up like Tesla

Issues

If you have issue regarding duplicate names that exist in aks, delete the kubeconfig and start again

rm -r ~/.kube

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published