Contents

How to setup kubernetes on Azure

Step 1. How to set AKS Cluster in Azure

This step could reference the official documents as below, https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal

Step 2 Open the could shell

https://cdn.jsdelivr.net/gh/Gethin1990/gsblogResources/how-to-setup-kubernetes-on-azure/Cloud%20Shell_2019-07-25_21-12-58.png)

The link as https://shell.azure.com/

And input the Command as below

1
az aks get-credentials --resource-group AKSGroup --name AKSCluster

Step 3 install Prometheus

How to create change nampspace :

1
2
kuebctl create ns monitoring
kubectl config set-context --current --namespace=monitoring

The install command as below,

1
helm install stable/prometheus --name kube-prometheus --set rbac.create=true --namespace monitoring

If you met the issue like

Error: namespaces “monitoring” is forbidden: User “system:serviceaccount:kube-system:default” cannot get resource “namespaces” in API group "” in the namespace “monitoring”

Solution: rbac-config.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tiller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: tiller
    namespace: kube-system
1
2
kubectl create -f rbac-config.yaml
helm init --service-account tiller --history-max 200

Step 4 install Grafana

1
helm install stable/grafana --set persistence.enabled=true --set persistence.accessModes={ReadWriteOnce} --set persistence.size=8Gi -n grafana --namespace monitoring

You can mark the service as LoadBalancer,

1
kubectl edit svc grafana

Get the password,

1
kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

step 5 Access the Kubernetes web dashboard in AKS

The shell script as below.

1
az aks browse --resource-group AKSGroup --name AKSCluster

For RBAC-enabled clusters.

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

setp 6 install traekit

install htpasswd.

1
apt-get install apache2-utils

generate password.

1
htpasswd -nbm admin password1234

install traefik.

1
helm install stable/traefik --set dashboard.enabled=true,serviceType=LoadBalancer,rbac.enabled=true,dashboard.auth.basic.admin='$apr1$ZywpxeoS$6U80kYPG116slxBceEsVz0',dashboard.domain=traefik.dashboard --name=traefik --namespace=kube-system

helm delete.

1
helm del --purge traefik

step 7 install kubeapps

1. Install Kubeapps.

1
kubectl create namespace kubeapps
1
helm repo add bitnami https://charts.bitnami.com/bitnami

Helm 2 command

1
helm install --name kubeapps --namespace kubeapps bitnami/kubeapps

Helm 3 command

1
helm install kubeapps --namespace kubeapps bitnami/kubeapps --set useHelm3=true

2. Create a Kubernetes API token.

Create service account,

1
kubectl create serviceaccount kubeapps-operator -n kubeapps

Create cluster role binding,

1
kubectl create clusterrolebinding kubeapps-operator --clusterrole=cluster-admin --serviceaccount=kubeapps:kubeapps-operator

Get the secret,

1
kubectl get secret -n kubeapps $(kubectl get serviceaccount kubeapps-operator -n kubeapps -o jsonpath='{.secrets[].name}') -o jsonpath='{.data.token}' | base64 --decode && echo

- End -
「 Thanks for sponsor 」