In this article:

Installing Pods Metrics Service

Installing the Prometheus Application

Installing the Grafana Application

Installing Cluster Web Interface

Creating a Cluster Administrator Account

Installing Additional Components for Kubernetes Cluster

For the Kubernetes cluster install the following additional components on the first main node:

Installing Pods Metrics Service

To install pods metrics service:

  1. Execute commands:

helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/
helm upgrade --install metrics-server metrics-server/metrics-server -n monitoring --create-namespace

  1. Disable tls check if the certificate is not used:

    1. Execute the command:

kubectl edit deployment metrics-server -n monitoring

    1. Add the string to the spec containers args section:

- --kubelet-insecure-tls

  1. Check status of running pods:

kubectl get pods -n monitoring

After executing the operations the pods metrics service is installed on the main node.

Installing the Prometheus Application

To install the Prometheus application:

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm upgrade --install prometheus prometheus-community/kube-prometheus-stack \
-n monitoring \
--create-namespace \
--version 55.0.0

After executing the operations the Prometheus application is installed on the main node.

Installing the Grafana Application

To install the Grafana application:

  1. Create an ingress rule for the Grafana application. To do this, create the grafana-ingress.yaml file with contents:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 name: grafana-dashboard
 namespace: monitoring
spec:
 ingressClassName: nginx
 rules:
   - host: <host>
     http:
       paths:
         - path: /
           pathType: ImplementationSpecific
           backend:
             service:
               name: prometheus-grafana
               port:
                 number: 80

In the <host> substitution specify IP address or DNS name, by which the Grafana application is available. Make sure that the host corresponds to the IP addresses specified in the metalb-config.yaml file on metallb component installation. All hosts, with which Kubernetes communicates, should be resolved to these IP addresses.

  1. Apply the ingress rule:

kubectl apply -f grafana-ingress.yaml

After executing the operations and going to the specified host, the Grafana application is available on the main node.

Installing Cluster Web Interface

To install cluster web interface:

  1. Install the web interface component:

helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
helm repo update
helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard

  1. Create an ingress rule for the web interface component. To do this, create the ingress-dashboard.yaml file with contents:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 name: kubernetes-dashboard
 annotations:
   nginx.ingress.kubernetes.io/backend-protocol: HTTPS
spec:
 ingressClassName: nginx
 rules:
   - host: <host>
     http:
       paths:
         - path: /
           pathType: ImplementationSpecific
           backend:
             service:
               name: kubernetes-dashboard-kong-proxy
               port:
                 number: 443

In the <host> substitution specify IP address or DNS name, by which the Grafana application is available. Make sure that the host corresponds to the IP addresses specified in the metalb-config.yaml file on metallb component installation. All hosts, with which Kubernetes communicates, should be resolved to these IP addresses.

  1. Apply the ingress rule:

kubectl apply -f ingress-dashboard.yaml -n kubernetes-dashboard

After executing the operations and going to the specified host, the cluster web interface is available on the main node. The access requires a special key generated during cluster administrator account creation.

Creating a Cluster Administrator Account

To create a cluster administrator account:

  1. Create the cluster-admin-service-account.yaml file with contents:

apiVersion: v1
kind: ServiceAccount
metadata:
 name: cluster-admin
 namespace: kube-system

  1. Create an administrator based on the settings specified in the cluster-admin-service-account.yaml file:

kubectl apply -f cluster-admin-service-account.yaml

  1. Grant permissions to the administrator:

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

  1. Create a special key:

kubectl -n kube-system create token cluster-admin

After executing the operations the administrator account is created on the main node. The special key is used to access the cluster web interface.

Next, install the Docker image local storage.

See also:

Preparation and Deployment of Fault-Tolerant Cluster Based on Kubernetes | Installing Docker Image Local Storage