To follow the coding examples in the workshop, you can either use a Visual Studio Code Dev Container, which will run an embedded Kubernetes cluster, or you can install the softare locally.
The minimum hardware requirements for the tutorial are:
- Quad-core CPU
- 8 GB of RAM
Please install the following software:
-
After cloning this repository, open it is Visual Studio code.
-
A notification should appear, asking if you want to "Reopen in Container". Click on that button to reopen the workspace in a dev container. If the notification does not appear, press F1 and search for "Dev Containers: Reopen in Container".
-
Building the container image and starting the container takes several minutes. It involves pulling various container images, starting a Minikube Kubernetes cluster and installing Prometheus in it. You can open the log to see the current progress.
-
Once the setup has completed, you can start working. To stop the container, simply close VS Code and the container will stop a few seconds later.
This workshop uses the Kubernetes resource-consumer as the target workload. To deploy it, open a terminal in the dev container run the following command:
kubectl apply -f ./prerequisites/resource-consumer.yaml
Please install the following software:
-
Configure minikube to use 4 CPUs and 4 GB of RAM for the cluster node. Minikube offers various methods fro creating a node, called drivers. The following snippet assumes that you are using Docker as the driver, but you may change to another one, if desired.
minikube config set cpus 4 minikube config set memory 4096 minikube config set driver docker
-
Create a cluster:
minikube start --kubernetes-version=v1.27.4
-
Verify that the cluster is running:
kubectl get nodes
-
Add the Prometheus helm chart repository to your helm configuration:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update
-
Install the kube-prometheus stack in the
monitoring
namespace. This may take a few minutes.kubectl create namespace monitoring helm install prometheus prometheus-community/kube-prometheus-stack \ --set namespaceOverride=monitoring --set grafana.namespaceOverride=monitoring \ --set kube-state-metrics.namespaceOverride=monitoring \ --set prometheus-node-exporter.namespaceOverride=monitoring
-
Wait for all Prometheus pods to be ready. You can check this with the following command:
kubectl get pods -n monitoring
-
Check if the Prometheus UI is available by forwarding a local port to its service.
# Forward local port 9090 to the Prometheus service kubectl port-forward -n monitoring services/prometheus-kube-prometheus-prometheus 9090:9090 # Go to http://localhost:9090 in your browser. # If you see the Prometheus query UI, everything is fine. # Stop the port forwarding using Ctrl-C
This workshop uses the Kubernetes resource-consumer as the target workload. To deploy it, run the following command in a terminal in this folder:
kubectl apply -f ./resource-consumer.yaml
To temporarily stop the minikube cluster, run the following:
minikube stop
You can resume the cluster operation using:
minikube start
# Wait for all pods to be running again
watch kubectl get pods -A
To delete the cluster, run:
minikube stop
minikube delete