Skip to content

Commit

Permalink
Add check-mk chart (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhgriffith-uofu authored May 10, 2022
1 parent 7c657e4 commit 1f8c172
Show file tree
Hide file tree
Showing 12 changed files with 308 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/applications-onboarding/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: "v1"
name: "applications-onboarding"
version: 1.0.2
version: 1.0.3
appVersion: 1.0.0
description: "A simple tutorial for learning kubernetes and helm basics to begin contributing to SLATE"
maintainers:
Expand Down
2 changes: 1 addition & 1 deletion charts/applications-onboarding/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
spec:
containers:
- name: applications-onboarding
image: slateci/applications-onboarding:latest
image: "{{ .Values.harbor.hostname }}/{{ .Values.harbor.projectID }}/{{ template "applications-onboarding.name" . }}:{{ .Chart.AppVersion }}"
imagePullPolicy: Always
ports:
- name: http
Expand Down
5 changes: 5 additions & 0 deletions charts/applications-onboarding/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# The label to apply to this deployment,
# used to manage multiple instances of the same application
Instance: default

# harbor is the set of hostname, project id, etc. related to OSG Harbor
harbor:
hostname: 'hub.opensciencegrid.org'
projectID: 'slate'
21 changes: 21 additions & 0 deletions charts/check-mk/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
18 changes: 18 additions & 0 deletions charts/check-mk/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
description: check_mk monitoring
engine: gotpl
home: https://mathias-kettner.de/check_mk.html
icon: http://git.mathias-kettner.de/git/?p=check_mk.git;a=blob_plain;f=web/htdocs/images/logo_mk.png;h=f41c2227828b79c035fa2e2d3fba5ec939c6f2c3;hb=HEAD
keywords:
- check_mk
- nagios
- monitoring
maintainers:
- email: [email protected]
name: junaid18183
name: check-mk
sources:
- https://github.com/kubernetes/charts
- http://git.mathias-kettner.de/git/
version: 0.2.3
appVersion: 1.4.0p26
90 changes: 90 additions & 0 deletions charts/check-mk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Monitoring Kubernetes in Check-mk
This project provides monitoring services for a kubernetes cluster within [SLATE](http://slateci.io/). It will also be beneficial to read over the [Checkmk-Official Guide](https://checkmk.com/cms.html) as a reference to using the online dashboard.

## Getting Started
Install the [SLATE CLI Client](https://slateci.io/docs/tools/#installing-the-slate-client)

## Deploying Check-mk through the SLATE CLI (Recommended)
If you wish to install an instance of check-mk manually through Helm skip down to the following header.

Otherwise, Make sure your [cluster is registered as part of SLATE](https://slateci.io/docs/cluster/index.html) before proceeding. You can confirm that your cluster is registered in SLATE by running `slate cluster list` through the SLATE client. Identify your cluster in the list. You also need to make sure you are part of a group in order to install check-mk.

To install check-mk in your cluster run the following command:

`slate app install check-mk --dev --cluster <cluster_name> --group <group_name>`

You will need the instance number of the check-mk installation by running

`slate instance list --cluster <cluster_name> --group <group_name>`

In order to get the URL of the dashboard for check-mk run the following commands:

`export NODE_IP=$(slate instance info <instance_ID> | grep 'Host IP: ' | awk -F '[ -]*' '$0=$NF')`

`export NODE_PORT=$(slate instance info <instance_ID> | grep -m 1 $NODE_IP | awk -F '[ -]*' '$0=$NF')`

`echo http://$NODE_PORT/cmk/check_mk`

Once opening the url in your browser you can find the username and password by running the command:

`slate instance logs <instance_ID>`

Continue to the header at 'Setting up Monitoring on your Kubernetes Cluster'



## Deploying Check-mk in your kubernetes cluster with helm and kubectl

This will allow you to install check-mk onto any Kubernetes cluster, even if it is not part of the SLATE federation. Clone the [slateci/slate-catalog](https://github.com/slateci/slate-catalog) repository on the machine you are running your Kubernestes cluster on.

cd into your slate-catalog/incubator/check-mk/check-mk directory. At this point you will need to deploy the check-mk application within Kubernetes. To do this run `helm install check-mk`. Helm manages the deployement of check-mk on kubernetes.

If you need to install helm refer to [Helm Installation](https://helm.sh/docs/intro/install/)

Run `kubectl get pods` to ensure that the check-mk application is now running on your cluster. You should see a pod that has been deployed and is running check-mk. If you have multiple namespaces and have install check-mk in to a different namespace other than default than you may need to run `kubectl get pods --all-namespaces` in order to find the check-mk deployment

In order to set up the dashboard that you will be running to monitor your cluster you need to run the following commands:

`export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services check-mk-global)`

`export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")`

`echo http://$NODE_IP:$NODE_PORT/cmk/check_mk`

Open the URL that is given to you in your default web browser which will lead you to the login for you check-mk dashboard.

To access the login information you will need to run the following commands:

`kubectl get pods`

Copy the name of the check-mk pod which will be in the form 'check-mk-global-ID'. An example is check-mk-global-4d2f86d99c-swdnt. With this information run the following command, pasting in the name you just received:

`kubectl logs <checkmk_pod_name>`

The logs provides the given username and password. Enter those into your dashboard in your web browser you opened up earlier and you will have access to start monitoring from the dashboard. Note that you have the ability to change the password by following the instructions provided in the logs.

## Setting up Monitoring on your Kubernetes Cluster

Check-mk provides the necessary steps for setting up monitoring on your kubernetes cluster. There are some additional steps needed that aren't provided in check-mk's documentation so make sure to read the provided guidelines before starting because they work in tandem with check-mk's steps.


While logged into your cluster download the source code provided at [Check-mk Downloads](https://checkmk.com/download-source.php?). Make sure to download the most recent version. Also, make sure it is the complete source code of Check-mk with OMD. This will coincide with the version that is provided in Helm's earlier deployment and will help prevent further issues. Once the dowload is complete, extract all the files through the command:

`tar -zxvf <your_checkmk-rawedition-1.6.tar.gz>`

Now that you have downloaded the source code you are ready to start check-mk's walk through for [Monitoring Kubernetes](https://checkmk.com/cms_monitoring_kubernetes.html). Again, make sure to refer to the guidelines below to simplify the process.



## Additional guidelines for setting up Check-mk:

The rbac.yaml file will be found in the check-mk-raw-1.6.0p6.cre/doc/treasures/kubernetes directory. Not the path it lists on the walk-through.

In section 2.4. Adding a Kubernetes-Cluster to the Monitoring you will be putting in a password token. The documentation doesn't specify to to click the Port button, but it is necessary to do so, otherwise the cluster can not be accessed. Make sure to define the port as 6443.

In section 2.5 is mentions the new version of check-mk-1.6. The configuration looks different than they show in the walk-through. Simply put in the token received from the secrets into the token value. Click on the port button and make sure to spcify port 6443. Leave all the other boxes clear. Again, do not click the Custom URL prefix, the Custom path prefix, or Disable certificate verification. Those will only come in to play if you are monitoring multiple clusters from this same dashboard. The documentation on how to do that will be updated shortly.

After defining the port number and saving the password token you need to add a host, which will be the actual kubernetes cluster. You are going to be adding the kubernetes cluster to your monitoring topology. To accomplish this go to your dashboard, then to "WATO" in the left side bar and click "Hosts". Once there click "Create new host". The host name is the IP adress that the cluster is running on. You can get this information by running the command: `kubectl cluster-info`. It is the given IP address associated with the application running on port 6443. Make sure to leave the port number off since it was already definied in the data-source rule. In the "Data Sources" portion check the "Use Check-MK Agent or Data-Source program". Now click "Save & go the Services" at the bottom of the page. At this point you will now recognize the services offered by check-mk on your cluster.

Determine which services you would like to monitor and click the "Monitor" button at the top. The changes you have made have not been saved and applied to your monitoring topology as a whole. To do this you need to click the "changes" button at the top with a warning sign. It will indicate the number of changes you have made. it is important to click "Activate affected" or your changes will not be monitored.

19 changes: 19 additions & 0 deletions charts/check-mk/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.hostname }}
http://{{- .Values.ingress.hostname }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "check-mk.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT/mva/check_mk
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ template "check-mk.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "check-mk.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}/mva/check_mk
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "check-mk.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:5000 to use your application"
kubectl port-forward $POD_NAME 5000:{{ .Values.service.externalPort }}/mva/check_mk
{{- end }}

The username/password are omdadmin/omd
28 changes: 28 additions & 0 deletions charts/check-mk/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "check-mk.name" -}}
{{- default .Chart.Name .Values.Instance | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "check-mk.fullname" -}}
{{- $name := default .Chart.Name .Values.Instance -}}
{{- if contains $name .Chart.Name -}}
{{- .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Chart.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- define "namespace" -}}
{{- .Release.Namespace | trimPrefix "slate-vo-" | printf " %s" -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "check-mk.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
41 changes: 41 additions & 0 deletions charts/check-mk/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "check-mk.fullname" . }}
labels:
app: {{ template "check-mk.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "check-mk.name" . }}
instance: {{ .Values.Instance }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "check-mk.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: checkmk/check-mk-raw:1.6.0-latest
imagePullPolicy: Always
ports:
- containerPort: {{ .Values.service.internalPort }}
livenessProbe:
httpGet:
path: /
port: {{ .Values.service.internalPort }}
readinessProbe:
httpGet:
path: /
port: {{ .Values.service.internalPort }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/check-mk/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.ingress.enabled -}}
{{- $serviceName := include "check-mk.fullname" . -}}
{{- $servicePort := .Values.service.externalPort -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "check-mk.fullname" . }}
labels:
app: {{ template "check-mk.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
rules:
{{- range $host := .Values.ingress.hosts }}
- host: {{ $host }}
http:
paths:
- path: /
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}
18 changes: 18 additions & 0 deletions charts/check-mk/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "check-mk.fullname" . }}
labels:
app: {{ template "check-mk.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app: {{ template "check-mk.name" . }}
release: {{ .Release.Name }}
34 changes: 34 additions & 0 deletions charts/check-mk/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Default values for check-mk.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.\
Instance: global
replicaCount: 1
service:
name: check-mk
type: NodePort
externalPort: 80
internalPort: 5000
ingress:
enabled: false
# Used to create Ingress record (should used with service.type: ClusterIP).
hosts:
- monitor.ijuned.com
annotations:
kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
tls:
# Secrets must be manually created in the namespace.
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

0 comments on commit 1f8c172

Please sign in to comment.