{"id":679,"date":"2020-12-02T10:21:30","date_gmt":"2020-12-02T09:21:30","guid":{"rendered":"https:\/\/www.ume.li\/blog\/?p=679"},"modified":"2020-12-02T15:57:35","modified_gmt":"2020-12-02T14:57:35","slug":"monitoring-component-pack-kubernetes-with-prometheus","status":"publish","type":"post","link":"https:\/\/www.ume.li\/blog\/2020\/12\/02\/monitoring-component-pack-kubernetes-with-prometheus\/","title":{"rendered":"Monitoring Component Pack \/ Kubernetes with Prometheus &#8211; Grafana"},"content":{"rendered":"<p>You have successfully installed HCL ComponentPack for HCL Connections. Now you want to know what is happening in that black box ?<br \/>\nThe goal is to see something like this<br \/>\n<a href=\"https:\/\/www.ume.li\/blog\/2020\/12\/02\/monitoring-component-pack-kubernetes-with-prometheus\/auswahl_002\/\" rel=\"attachment wp-att-683\"><img decoding=\"async\" src=\"https:\/\/www.ume.li\/blog\/wp-content\/uploads\/2020\/12\/Auswahl_002.png\" alt=\"\" width=\"560\" height=\"450 class=\"alignleft size-full wp-image-683\" srcset=\"https:\/\/www.ume.li\/blog\/wp-content\/uploads\/2020\/12\/Auswahl_002.png 967w, https:\/\/www.ume.li\/blog\/wp-content\/uploads\/2020\/12\/Auswahl_002-300x284.png 300w, https:\/\/www.ume.li\/blog\/wp-content\/uploads\/2020\/12\/Auswahl_002-768x727.png 768w, https:\/\/www.ume.li\/blog\/wp-content\/uploads\/2020\/12\/Auswahl_002-592x560.png 592w\" sizes=\"(max-width: 967px) 100vw, 967px\" \/><\/a><\/p>\n<p><strong>Steps to reproduce:<\/strong><br \/>\n&#8211; <a href=\"https:\/\/v1-18.docs.kubernetes.io\/docs\/tasks\/administer-cluster\/kubeadm\/kubeadm-upgrade\/\" rel=\"noopener noreferrer\" target=\"_blank\">Update Kubernetes to 1.18.12<\/a><br \/>\n&#8211; <a href=\"https:\/\/helm.sh\/docs\/intro\/install\/\" rel=\"noopener noreferrer\" target=\"_blank\">Install Helm3<\/a><br \/>\n&#8211; Install <a target=\"_blank\" href=\"https:\/\/github.com\/kubernetes-sigs\/nfs-subdir-external-provisioner.git\" title=\"nfs-client\" rel=\"noopener noreferrer\">nfs-client<\/a><br \/>\n&#8211; install metrics<br \/>\n&#8211; <a href=\"https:\/\/github.com\/traefik\/traefik-helm-chart\" rel=\"noopener noreferrer\" target=\"_blank\">Install Traefik<\/a><br \/>\n&#8211; Install Prometheus <\/p>\n<p>Disclaimer: use the following on your own risk.<\/p>\n<p>Update Kubernetes to 1.18 because it&#8217;s now supported for Component Pack. If you are still on 1.11 you will be surprised after the update to 1.16. The coredns will no longer start. Coredns removed the proxy plugin, you need to switch to the forward plugin:<br \/>\n<code>kubectl -n kube-system edit cm coredns<\/code><br \/>\nchange &#8216;proxy . \/etc\/resolv.conf&#8217; to &#8216;forward . \/etc\/resolv.conf&#8217;.<br \/>\nGoing to 1.19 has not been an option. Some of the helm charts provide incompatible ingresss or services due to the api changes between 1.18 and 1.19<\/p>\n<p><strong>Installing Helm 3<\/strong><br \/>\nAt the moment the Component Pack still requires Helm 2. But both versions can be used in parallel.<br \/>\nBefore installing Helm 3:<br \/>\n<code>mv \/usr\/local\/bin\/helm \/usr\/local\/bin\/helm2<\/code><br \/>\nand after installing Helm 3:<br \/>\n<code>mv \/usr\/local\/bin\/helm \/usr\/local\/bin\/helm3<\/code><br \/>\nNow my environment knows helm2 and helm3. It&#8217;s possible to migrate from helm 2 to helm 3 but I wanted an emergency option to be able to re-install Component Pack if needed. <code>helm2 list<\/code> shows the Component Pack installs. <code>helm3 list<\/code> will show all the new stuff.<\/p>\n<p><strong>nfs-client: <\/strong><br \/>\nI&#8217;m lazy. I already have a working nfs server in my environment. I don&#8217;t want to handle every single pv\/pvc manually. That&#8217;s why I use the nfs client provisioner. I cloned the repo and applied the 3 yaml files. I updated the deploy\\deployment.yaml with the values for my nfs server.<br \/>\n<code>kubectl apply -f deploy\\class.yaml<br \/>\nkubectl apply -f deploy\\deployment.yaml<br \/>\nkubectl apply -f deploy\\rbac.yaml<br \/>\nkubectl patch storageclass managed-nfs-storage -p '{\"metadata\": {\"annotations\":{\"storageclass.kubernetes.io\/is-default-class\":\"true\"}}}'<br \/>\n<\/code><br \/>\nThe last line defines the new storage class as default.<\/p>\n<p><strong> metrics: <\/strong><br \/>\nget the yaml and add the &#8211;kubelet-insecure-tls to the args.<br \/>\nI was not able to get the metrics pod up without this. Probably proper certificates with all the right SAN&#8217;s would help. But as this is only in my lab, I don&#8217;t care.<\/p>\n<p><code><br \/>\nwget https:\/\/github.com\/kubernetes-sigs\/metrics-server\/releases\/download\/v0.4.1\/components.yaml<br \/>\n<\/code><br \/>\n<code><br \/>\n  - args:<br \/>\n        - --cert-dir=\/tmp<br \/>\n        - --secure-port=4443<br \/>\n        - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname<br \/>\n        - --kubelet-use-node-status-port<br \/>\n        - --kubelet-insecure-tls<br \/>\nkubectl apply -f components.yaml<br \/>\n<\/code><br \/>\nNow you should get the metrics pod in the kube-system namespace.<\/p>\n<p><strong>Traefik: <\/strong><br \/>\n<code>helm3 show values traefik\/traefik > values.yml<\/code> to get the variables from the helm chart.<\/p>\n<p>In order to prevent conflicts between the different ingress controllers I added this ingressClass.<br \/>\nSave it in ic.yaml and <code>kubectl apply -f ic.yaml<\/code><\/p>\n<p><code>apiVersion: networking.k8s.io\/v1beta1<br \/>\nkind: IngressClass<br \/>\nmetadata:<br \/>\n  name: traefik-lb<br \/>\nspec:<br \/>\n  controller: traefik.io\/ingress-controller<br \/>\n<\/code><\/p>\n<p>There are 2 ingress controllers on my system now Traefik and cnx-ingress.<\/p>\n<p>I defined the listening ports for web and websecure as 31080 and 31443 with<br \/>\n<code>kubectl edit svc traefik<\/code>.<\/p>\n<p>There&#8217;s also a dashboard available for traefik.<br \/>\n<a href=\"https:\/\/www.ume.li\/blog\/2020\/12\/02\/monitoring-component-pack-kubernetes-with-prometheus\/auswahl_003\/\" rel=\"attachment wp-att-693\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ume.li\/blog\/wp-content\/uploads\/2020\/12\/Auswahl_003.png\" alt=\"\" width=\"570\" height=\"470\" class=\"aligncenter size-full wp-image-693\" \/><\/a><\/p>\n<p><strong>Prometheus\/Grafana<\/strong><br \/>\nThere are a lot of tutorials out there on how to install and configure prometheus.<\/p>\n<p>So the compressed version:<\/p>\n<p><code><br \/>\nhelm3 repo add stable https:\/\/charts.helm.sh\/stable<br \/>\nhelm3 repo add prometheus-community https:\/\/prometheus-community.github.io\/helm-charts<br \/>\nhelm3 repo update<br \/>\nhelm3 show values prometheus-community\/kube-prometheus-stack > values.yaml<br \/>\n<\/code><br \/>\nedit values.yaml file:<br \/>\n &#8211; enable the ingress creation, add the ingressClassName: traefik-lb and define the hostname<br \/>\n &#8211; assign the volumeclaimtemplates the storage class, managed-nfs-storage in my case<br \/>\n<code><br \/>\n    storage:<br \/>\n     volumeClaimTemplate:<br \/>\n       spec:<br \/>\n         storageClassName: managed-nfs-storage<br \/>\n         accessModes: [\"ReadWriteOnce\"]<br \/>\n         resources:<br \/>\n           requests:<br \/>\n             storage: 20Gi<br \/>\n    #   selector: {}<br \/>\n<\/code><\/p>\n<p><code><br \/>\nkubectl create namespace monitoring<br \/>\nhelm3 install  prometheus prometheus-community\/kube-prometheus-stack -n monitoring -f values.yaml<br \/>\nhelm3 install  metrics-adapter prometheus-community\/prometheus-adapter -n monitoring<\/p>\n<p><\/code><br \/>\nupdate the grafana ingress, add the ingressClassName<br \/>\n<code>kubectl -n monitoring edit ingress prometheus-grafana<\/code><br \/>\n<code><br \/>\nspec:<br \/>\n  ingressClassName: traefik-lb<br \/>\n  rules:<br \/>\n  - host: grafana.ume.li<br \/>\n<\/code><\/p>\n<p>If you are using more then one node, make sure that the appropriate network ports (9000\/9100 TCP) are open between the nodes.<\/p>\n<p>Next step is to create the routes on your front Proxy\/LoadBalancer so that the site is available under a nice url.<br \/>\nThe embedded grafana has already the prometheus configured. The only thing I added was <a href=\"https:\/\/grafana.com\/grafana\/dashboards\/6417\" rel=\"noopener noreferrer\" target=\"_blank\">this dashboard<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You have successfully installed HCL ComponentPack for HCL Connections. Now you want to know what is happening in that black<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54,23],"tags":[],"class_list":["post-679","post","type-post","status-publish","format-standard","hentry","category-component-pack","category-connections"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/posts\/679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/comments?post=679"}],"version-history":[{"count":23,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/posts\/679\/revisions"}],"predecessor-version":[{"id":706,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/posts\/679\/revisions\/706"}],"wp:attachment":[{"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/media?parent=679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/categories?post=679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ume.li\/blog\/wp-json\/wp\/v2\/tags?post=679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}