Skip to content

Commit

Permalink
Merge pull request #315 from kahootali/add-helm-chart
Browse files Browse the repository at this point in the history
Add helm chart for operator based implementation
  • Loading branch information
ahmedwaleedmalik committed May 3, 2021
2 parents 6c4a6a6 + 3c189ee commit 6a6c858
Show file tree
Hide file tree
Showing 14 changed files with 502 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.26.0
golangci-lint run --timeout=10m ./...
- name: Helm Lint
run: |
helm lint deploy/chart/ingressmonitorcontroller
- name: Install kubectl
run: |
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl"
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
OPERATOR_SDK_VERSION: "0.15.2"
KUBERNETES_VERSION: "1.18.0"
KIND_VERSION: "0.7.0"
HELM_REGISTRY_URL: "https://stakater.github.io/stakater-charts"

jobs:
build:
Expand All @@ -36,6 +37,10 @@ jobs:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.26.0
golangci-lint run --timeout=10m ./...
- name: Helm Lint
run: |
helm lint deploy/chart/ingressmonitorcontroller
- name: Install kubectl
run: |
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl"
Expand Down Expand Up @@ -135,6 +140,21 @@ jobs:
VERSION: ${{ steps.generate_operator_tag.outputs.new_tag }}
run: make update-resources-ci

# Publish helm chart
- name: Publish Helm chart
uses: stefanprodan/helm-gh-pages@master
with:
branch: master
repository: stakater-charts
target_dir: docs
token: ${{ secrets.STAKATER_GITHUB_TOKEN }}
charts_dir: deploy/chart/
charts_url: ${{ env.HELM_REGISTRY_URL }}
owner: stakater
linting: on
commit_username: stakater-user
commit_email: stakater@gmail.com

# Commit back changes
- name: Commit files
run: |
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ NOTE: For provider specific additional configuration refer to [Docs](./docs) and

The following quickstart let's you set up Ingress Monitor Controller to register uptime monitors for endpoints:

## Helm Chart

If you have configured helm on your cluster, you can deploy IngressMonitorController via helm using below mentioned commands. For details on chart, see [IMC Helm Chart](https://github.com/stakater/IngressMonitorController/tree/master/deploy/chart/ingressmonitorcontroller)

```sh
# Install CRDs
kubectl apply -f https://raw.githubusercontent.com/stakater/IngressMonitorController/master/deploy/crds/endpointmonitor.stakater.com_endpointmonitors_crd.yaml

# Install chart
helm repo add stakater https://stakater.github.io/stakater-charts

helm repo update

helm install stakater/ingressmonitorcontroller
```

## Vanilla Manifests

1) Clone this repository
```terminal
$ git clone git@github.com:stakater/IngressMonitorController.git
Expand Down
12 changes: 12 additions & 0 deletions deploy/chart/ingressmonitorcontroller/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
name: ingressmonitorcontroller
version: v2.0.15
description: IngressMonitorController Operator chart that runs on kubernetes
keywords:
- IngressMonitorController
- IngressMonitorController Operator
- kubernetes
home: https://github.com/stakater/IngressMonitorController
icon: https://raw.githubusercontent.com/stakater/IngressMonitorController/master/assets/web/IMC-round-100px.png
sources:
- https://github.com/stakater/IngressMonitorController
53 changes: 53 additions & 0 deletions deploy/chart/ingressmonitorcontroller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# IngressMonitorController Helm Chart


Helm chart for the new IngressMonitorController operator that runs on kubernetes

This chart supports v2.x.x as IMC has been shifted to operator from that version. For controller based approach, refer to [release-v1](https://github.com/stakater/IngressMonitorController/tree/release-v1/deployments/kubernetes)

Source code can be found [here](https://github.com/stakater/IngressMonitorController)

## Installation

To install IMC helm chart run the following

```sh
# Install CRDs
kubectl apply -f https://raw.githubusercontent.com/stakater/IngressMonitorController/master/deploy/crds/endpointmonitor.stakater.com_endpointmonitors_crd.yaml

# Install Chart
helm repo add stakater https://stakater.github.io/stakater-charts

helm repo update

helm install stakater/ingressmonitorcontroller
```

## Chart Values

| Key | Default | Description |
|-----|---------|-------------|
| global.labels | `` | Labels to be added to all components |
| watchNamespaces | `` | comma separated namespace names, set empty to watch all namespaces |
| useFullName | `false` | |
| deployment.annotations | `"configmap.reloader.stakater.com/reload": "ingressmonitorcontroller"` | Additional annotations on deployment |
| deployment.labels | `` | Additional labels on deployment |
| deployment.replicas | `1` | Replicas for deployment |
| deployment.revisionHistoryLimit | `2` | Limit on rollout history |
| deployment.operatorName | `ingressmonitorcontroller` | |
| deployment.logLevel | `info` | Log Level |
| deployment.logFormat | `text` | Formatting logs |
| deployment.image.name | `"stakater/ingressmonitorcontroller"` | Image repository |
| deployment.image.tag | `LATEST_CHART_VERSION` | Tag of the Image |
| deployment.image.pullPolicy | `Always` | Pull policy for the image |
| rbac.create | `true` | Whether to create RBAC (Role/Cluster & RoleBinding/ClusterRoleBinding) |
| rbac.serviceAccount.create | `true` | Whether to create serviceAccount |
| rbac.serviceAccount.name | `""` | Name for ServiceAccount, if empty the default chart name will be used |
| rbac.serviceAccount.labels | `{}` | Additional labels on ServiceAccount |
| rbac.serviceAccount.annotations | `{}` | Additional annotations on ServiceAccount|
| secret.useExisting | `false` | Whether to use an existing secret, if true, this chart will not create secret |
| secret.name | `""` | Name used for secret, either already existing secret or created from this chart, if empty the default chart name will be used |
| secret.labels | `{}` | Additional labels on Secret |
| secret.annotations | `{}` | Additional annotations on Secret|
| secret.data."config.yaml" | `"providers:\n- name: UptimeRobot\n apiKey: your-api-key\n apiURL: https://google.com\n alertContacts: some-alert-contacts\nenableMonitorDeletion: true\nmonitorNameTemplate: \"{{.Namespace}}-{{.IngressName}}\"\n# how often (in seconds) monitors should be synced to their Kubernetes resources (0 = disabled)\nresyncPeriod: 0\n# creationDelay is a duration string to add a delay before creating new monitor (e.g., to allow DNS to catch up first)\n# https://golang.org/pkg/time/#ParseDuration\ncreationDelay: 0"` | Config for secret used for IMC |

37 changes: 37 additions & 0 deletions deploy/chart/ingressmonitorcontroller/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- if .Values.useFullName -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" | lower -}}
{{- end -}}
{{- end -}}

{{/*
Define the name of the service account to use
*/}}
{{- define "serviceAccountName" -}}
{{- if .Values.rbac.serviceAccount.create -}}
{{ default (include "name" .) .Values.rbac.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.rbac.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Define the default labels for the resources
*/}}
{{- define "labels" -}}
provider: stakater
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
version: {{ .Values.deployment.image.tag }}
{{- if .Values.global.labels }}
{{ toYaml .Values.global.labels }}
{{- end }}
{{- end -}}
82 changes: 82 additions & 0 deletions deploy/chart/ingressmonitorcontroller/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{{- if and ( .Values.rbac.create ) (eq .Values.watchNamespaces "") }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "name" . }}-cluster-role
labels:
{{ include "labels" $ | indent 4 }}
rules:
- apiGroups:
- ""
- "extensions"
- "route.openshift.io"
resources:
- ingresses
- routes
- secrets
verbs:
- list
- get
- watch
- apiGroups:
- ""
resources:
- events
- services
- configmaps
- services/finalizers
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- deployments
- daemonsets
- replicasets
- statefulsets
verbs:
- "list"
- "get"
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- get
- create
- list
- apiGroups:
- apps
resourceNames:
- ingressmonitorcontroller
resources:
- deployments/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- list
- watch
- apiGroups:
- endpointmonitor.stakater.com
resources:
- '*'
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if and ( .Values.rbac.create ) (eq .Values.watchNamespaces "") }}
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ template "name" . }}-role-binding
labels:
{{ include "labels" $ | indent 4 }}
roleRef:
kind: ClusterRole
name: {{ template "name" . }}-cluster--role
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: {{ template "serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
66 changes: 66 additions & 0 deletions deploy/chart/ingressmonitorcontroller/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{- if .Values.deployment.annotations }}
{{ toYaml .Values.deployment.annotations | indent 4 }}
{{- end }}
labels:
{{ include "labels" $ | indent 4 }}
{{- if .Values.deployment.labels }}
{{ toYaml .Values.deployment.labels | indent 4 }}
{{- end }}
name: {{ template "name" . }}
spec:
replicas: {{ .Values.deployment.replicas }}
revisionHistoryLimit: {{ .Values.deployment.revisionHistoryLimit }}
selector:
matchLabels:
{{ include "labels" $ | indent 6 }}
{{- if .Values.deployment.labels }}
{{ toYaml .Values.deployment.labels | indent 6 }}
{{- end }}
template:
metadata:
labels:
{{ include "labels" $ | indent 8 }}
{{- if .Values.deployment.labels }}
{{ toYaml .Values.deployment.labels | indent 8 }}
{{- end }}
spec:
containers:
- env:
- name: WATCH_NAMESPACE
{{- if .Values.watchNamespaces }}
value: {{ .Values.watchNamespaces | quote }}
{{- else }}
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{{- end }}
- name: POD_NAME
{{- if .Values.deployment.podName }}
value: {{ .Values.deployment.podName | quote }}
{{- else }}
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- end }}
- name: CONFIG_SECRET_NAME
{{- if .Values.secret.name }}
value: {{ .Values.secret.name | quote }}
{{- else }}
value: {{ template "name" . }}
{{- end }}
- name: OPERATOR_NAME
value: {{ .Values.deployment.operatorName | quote }}
- name: LOG_LEVEL
value: {{ .Values.deployment.logLevel | quote }}
- name: LOG_FORMAT
value: {{ .Values.deployment.logFormat | quote }}
image: "{{ .Values.deployment.image.name }}:{{ .Values.deployment.image.tag }}"
command:
- IngressMonitorController
imagePullPolicy: {{ .Values.deployment.image.pullPolicy }}
name: {{ template "name" . }}
serviceAccountName: {{ template "serviceAccountName" . }}

0 comments on commit 6a6c858

Please sign in to comment.