Kubeapps in AKS – Easily test apps in AKS
Kubeapps is a web-based UI for deploying and managing applications in Kubernetes clusters
I am here by explaining the following steps
- Deploy an AKS cluster in Azure using terraform
- Install Nginx ingress controller in AKS cluster using HELM chart, so that we can access the application through internet
- Install Kubeapps using HELM chart in same cluster
- Apply the Ingress configuration so that Kubeapps is accessible over internet by folder mapping
- Login Kubeapps UI and start deploying your favorite applications
- Edit Ingress file and add folder redirection for the new applications
Pre-Requisites for Windows 10
- Azure cli access is configured through PowerShell – How to install the Azure CLI | Microsoft Docs
- Terraform is deployed – Downloads | Terraform by HashiCorp
- HELM chart is deployed already. One of the pretty simple method is to install Chocolatey and Install HELM through Chocolaty
Install Chocolatey – Chocolatey Software | Installing Chocolatey
Install HELM using Chocolaty – Chocolatey Software | helm 3.8.0
Deploy an AKS cluster in Azure using terraform
Connect your Azure subscription using az cli and deploy AKS cluster using Terraform code – init/plan/deploy
I used the Following terraform code. Save as main.tf >terraform init > terraform plan and finally terraform apply
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.80.0"
}
}
}
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "aks" {
name = "aks"
location = "eastasia"
}
resource "azurerm_kubernetes_cluster" "aks-cluster" {
name = "aks-cluster"
location = azurerm_resource_group.aks.location
resource_group_name = azurerm_resource_group.aks.name
dns_prefix = "aks-cluster"
default_node_pool {
name = "default"
node_count = "2"
vm_size = "standard_d2_v2"
}
identity {
type = "SystemAssigned"
}
addon_profile {
http_application_routing {
enabled = true
}
}
}
Once the deployment is completed successfully , you will have a two node aks cluster ready for your application deployments
Install Nginx Ingress controller in AKS cluster using HELM chart
As the first step, I have created a new namespace so that all work loads can be deployed over there
kubectl create namespace ingress-namespace
I used the following commands to install a 2 node Nginx Ingress controller. We need to add the repository and update before start the install
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install nginx-ingress ingress-nginx/ingress-nginx --namespace ingress-namespace --set controller.replicaCount=2
Install Kubeapps using HELM chart
I used the following commands for this step. We need to add the repository and update before start the install
Note that the steps also include creating a service account, clusterrolebinding, and finally get the secret to connect the UI
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install kubeapps --namespace kubeapps bitnami/kubeapps
kubectl create serviceaccount kubeapps-operator
kubectl create clusterrolebinding kubeapps-operator --clusterrole=cluster-admin --serviceaccount=default:kubeapps-operator
kubectl get secret $(kubectl get serviceaccount kubeapps-operator -o jsonpath='{.secrets[].name}') -o jsonpath='{.data.token}' -o go-template='{{.data.token | base64decode}}'
Copy the secret printed for using it in UI login. Now the UI is ready with internal IP address. We need to create ingress route so that the UI is available over internet in cluster IP.
Apply the Ingress configuration so that Kubeapps is accessible over internet
I used the following yaml code. Copy it and create a yaml file out of it. It creates two ingress routes. the one with name *static is for the enabling the Kubeapps to see in root directory
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: aks
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- http:
paths:
- path: /kubeapps(/|$)(.*)
pathType: Prefix
backend:
service:
name: kubeapps
port:
number: 80
- path: /(.*)
pathType: Prefix
backend:
service:
name: kubeapps
port:
number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: aks-static
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /static/$2
spec:
rules:
- http:
paths:
- path:
pathType: Prefix
backend:
service:
name: kubeapps
port:
number: 80
path: /static(/|$)(.*)
Apply the Ingress route as follows
kubectl apply -f .\ingress_kubeapps.yaml --namespace ingress-namespace
Now, Kubeapps should be available to access through the LoadBalancer public IP address of the Nginx ingress. You can find the IP address by running the following command
kubectl get svc --namespace ingress-namespace
Login Kubeapps UI and start deploying your favorite applications
Browse the public IP address to start configuring the Kubeapps. At the first page, we have to enter the secret copied in the above step as the token
Up on logging to the UI, you will be able to see the two applications we deployed already – Nginx and Kubeapps as below. But, note that you have to switch the name space to the one we have created where the applications exists. Otherwise, make sure that you have enabled the slider to see everything as below
Now, we are ready to start deploying other applications in the cluster through Kubeapps. As an example, I am adding ‘aspcore’. Click Deploy at the right hand side of the UI and Search the required application as below:
The application is installing using Helm. Select the required package version, give a name to the instance and start the deployment
The deployment will take couple of seconds and have a look at the services enabled for the new application. In the application page you will see the pods created details as below:
kubectl get svc --namespace ingress-namespace
As you can see, the application is ready to be accessed internally through port 80. In the next step, we will add the application in our ingress route file and apply the yaml file so that the application is reachable through the folder map
Edit Ingress file and add folder redirection for the new applications
The following are the code changes. I have added a new path with the name of the service as you can see
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: aks
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- http:
paths:
- path: /kubeapps(/|$)(.*)
pathType: Prefix
backend:
service:
name: kubeapps
port:
number: 80
- path: /asp(/|$)(.*)
pathType: Prefix
backend:
service:
name: aspnet-aspnet-core
port:
number: 80
- path: /(.*)
pathType: Prefix
backend:
service:
name: kubeapps
port:
number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: aks-static
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /static/$2
spec:
rules:
- http:
paths:
- path:
pathType: Prefix
backend:
service:
name: kubeapps
port:
number: 80
path: /static(/|$)(.*)
Apply the new file with the same command we used before
kubectl apply -f .\ingress_kubeapps.yaml --namespace ingress-namespace
Now, you will see that the changes are applied as below:
Our asp application is ready to test under the <public ip>/asp folder
Now, you may try adding other packages available in Bitnami repository.
Hope the procedure helps you to test some of the containers in aks before you go for actual production deployment ! Enjoy Kubeapps !!!
No responses yet