Now that the demo application is up and running on our Kubernetes cluster, let's install the Elastic Agent to gather logs and metrics from the cluster. We will configure the Elastic Agent to gather this information and send it to our deployment in Elastic Cloud.
The Elastic Agent will run as a DaemenSet on our Kubernetes cluster. This means every Kubernetes node will have 1 Elastic Agent pod running. Your Minikube cluster only consists of one Kubernetes node which means you will only have 1 Elastic Agent pod running in total.
Start by creating a new agent policy in Kibana.
In Kibana, navigate to Management > Fleet
Click on Add agent
Name the new policy "kubernetes-policy" (you might have to click "Create new agent policy" first)
Click Create policy
Under Install Elastic Agent on your host, select "Kubernetes"
Copy the manifest to clipboard
Now, let's save the manifest file on our machine.
Go back to your machine in Strigo and open the editor by clicking on the Editor tab or navigate to http://<public-ip>:3022 in your browser. If the editor in the Strigo tab is not showing up, click Reload this view.
Select the empty elastic-agent.yaml file and paste the manifest you just copied. Make sure to save the file (⌘+S).
If you prefer using the command line, you can also edit the file using vim or nano.
vim ~/workshop/elastic-agent.yaml
nano ~/workshop/elastic-agent.yaml
Go back to your first terminal, execute the following command to roll out the manifest
kubectl apply -f ~/workshop/elastic-agent.yaml
In Kibana, wait for the confirmation of agent enrolment and incoming data.
You can see your Elastic Agent pod running in the kube-system namespace
kubectl get pods -n kube-system
When the Elastic Agent is enrolled and data is coming in, you can go to the next step: adding the Kubernetes integration!
The Kubernetes integration requires kube-state-metrics to gather metrics and populate the out-of-the-box Kubernetes dashboards. Let's start by installing kube-state-metrics before enabling the Kubernetes integration in our policy.
Add the kube-state-metrics helm repo
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
Update the information of available charts locally from the chart repositories
helm repo update
We'll install the kube-state-metrics to your Kubernetes cluster into the same namespace as Elastic Agent (which, using the manifest file from Kibana, defaults to “kube-system”)
helm install --set namespaceOverride=kube-system kube-state-metrics prometheus-community/kube-state-metrics
Check if the kube-state-metrics pod is running
kubectl get pods -n kube-system
Now we can go ahead and add the Kubernetes integration in Kibana, this integration will import Kubernetes metrics and logs into Elasticsearch.
Navigate in Kibana to Management > Integrations
Search for "Kubernetes"
Select Kubernetes
Click Add Kubernetes
Leave everything on default and scroll al the way down, set Where to add this integration to "Existing hosts" and set Agent policy to "kubernetes-policy"
Click Save and continue
Click Save and deploy changes
The Elastic Kubernetes dashboards provide both an overview and detailed look at the operations of your Kubernetes cluster. You can use it to monitor metrics across clusters, nodes, pods, DaemonSets, services, and more.
In the navigation sidebar of Kibana, select Analytics > Dashboard
Search "kubernetes overview" and select the dashboard [Metrics Kubernetes] Cluster Overview