Skip to content
This repository was archived by the owner on Jan 19, 2024. It is now read-only.

Commit 01e7679

Browse files
feat(install): use helm charts for installing (#231)
Signed-off-by: Christian Kreuzberger <[email protected]>
1 parent fc104df commit 01e7679

File tree

8 files changed

+275
-282
lines changed

8 files changed

+275
-282
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Please always double-check the version of Keptn you are using compared to the ve
2929
| 0.9.0 | keptncontrib/prometheus-service:0.6.2 |
3030
| 0.9.0 - 0.9.2 | keptncontrib/prometheus-service:0.7.0 |
3131
| 0.10.0 | keptncontrib/prometheus-service:0.7.1 |
32-
| 0.10.0 | keptncontrib/prometheus-service:0.7.2 |
32+
| 0.10.0 | keptncontrib/prometheus-service:0.7.2 <PENDING> |
3333

3434

3535
## Installation instructions
@@ -40,11 +40,14 @@ Keptn does not install or manage Prometheus and its components. Users need to in
4040

4141
The easiest way would be to setup Prometheus using helm, e.g.:
4242
```console
43-
kubectl create ns monitoring
43+
kubectl create namespace monitoring
4444
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
4545
helm install prometheus prometheus-community/prometheus --namespace monitoring
4646
```
4747

48+
**Note**: After setting up prometheus, make sure to apply [deploy/role.yaml](deploy/role.yaml) such that prometheus-service can access the `monitoring` namespace (see instructions below).
49+
50+
4851
### Install prometheus-service
4952

5053
Please replace the placeholders in the commands below. Examples are provided.
@@ -60,6 +63,11 @@ Once this is done, you can go ahead and install prometheus-service:
6063

6164
* Install Keptn prometheus-service in Kubernetes using
6265

66+
```bash
67+
helm install -n keptn prometheus-service https://github.com/keptn-contrib/prometheus-service/releases/download/<VERSION>/prometheus-service-<VERSION>.tgz
68+
```
69+
70+
Prior to version 0.7.2 installation should be done via `kubectl`:
6371
```bash
6472
kubectl apply -f https://raw.githubusercontent.com/keptn-contrib/prometheus-service/release-<VERSION>/deploy/service.yaml
6573
```
@@ -71,8 +79,14 @@ kubectl apply -f https://raw.githubusercontent.com/keptn-contrib/prometheus-serv
7179
```
7280

7381

74-
* Replace the environment variable value according to the use case and apply the manifest:
82+
* (Optional) Replace the environment variable value according to the use case and apply the manifest:
83+
84+
```bash
85+
helm upgrade -n keptn prometheus-service https://github.com/keptn-contrib/prometheus-service/releases/download/<VERSION>/prometheus-service-<VERSION>.tgz --reuse-values --set=prometheus.namespace="<PROMETHEUS_NS>",prometheus.endpoint="<PROMETHEUS_ENDPOINT>",prometheus.namespace_am="<ALERT_MANAGER_NS>"
86+
```
87+
7588

89+
Prior to version 0.7.2 setting variables should be done via `kubectl`:
7690
```
7791
# Prometheus installed namespace
7892
kubectl set env deployment/prometheus-service -n keptn --containers="prometheus-service" PROMETHEUS_NS="<PROMETHEUS_NS>"

chart/templates/_helpers.tpl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,5 @@ app.kubernetes.io/instance: {{ .Release.Name }}
5454
Create the name of the service account to use
5555
*/}}
5656
{{- define "prometheus-service.serviceAccountName" -}}
57-
{{- if .Values.serviceAccount.create }}
58-
{{- default (include "prometheus-service.fullname" .) .Values.serviceAccount.name }}
59-
{{- else }}
60-
{{- default "default" .Values.serviceAccount.name }}
61-
{{- end }}
57+
keptn-prometheus-service
6258
{{- end }}

chart/templates/deployment.yaml

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
{{- toYaml . | nindent 8 }}
1919
{{- end }}
2020
labels:
21-
{{- include "prometheus-service.selectorLabels" . | nindent 8 }}
21+
{{- include "prometheus-service.labels" . | nindent 8 }}
2222
spec:
2323
{{- with .Values.imagePullSecrets }}
2424
imagePullSecrets:
@@ -39,18 +39,45 @@ spec:
3939
protocol: TCP
4040
livenessProbe:
4141
httpGet:
42-
path: /healthz
42+
path: /health
4343
port: http
4444
readinessProbe:
4545
httpGet:
46-
path: /healthz
46+
path: /health
4747
port: http
4848
resources:
4949
{{- toYaml .Values.resources | nindent 12 }}
50+
env:
51+
- name: METRICS_SCRAPE_PATH
52+
value: '/metrics'
53+
- name: CONFIGURATION_SERVICE
54+
value: 'http://configuration-service:8080'
55+
- name: PROMETHEUS_NS
56+
value: '{{ .Values.prometheus.namespace }}'
57+
- name: PROMETHEUS_CM
58+
value: 'prometheus-server'
59+
- name: PROMETHEUS_LABELS
60+
value: 'component=server'
61+
- name: PROMETHEUS_ENDPOINT
62+
value: "{{ .Values.prometheus.endpoint }}"
63+
- name: PROMETHEUS_CONFIG_FILENAME
64+
value: 'prometheus.yml'
65+
- name: ALERT_MANAGER_CONFIG_FILENAME
66+
value: 'alertmanager.yml'
67+
- name: ALERT_MANAGER_CM
68+
value: 'prometheus-alertmanager'
69+
- name: ALERT_MANAGER_LABELS
70+
value: 'component=alertmanager'
71+
- name: ALERT_MANAGER_NS
72+
value: '{{ .Values.prometheus.namespace_am }}'
73+
- name: ALERT_MANAGER_TEMPLATE_CM
74+
value: 'alertmanager-templates'
75+
- name: POD_NAMESPACE
76+
valueFrom:
77+
fieldRef:
78+
fieldPath: metadata.namespace
5079
- name: distributor
51-
image: keptn/distributor:0.9.1
52-
ports:
53-
- containerPort: 8081
80+
image: "{{ .Values.distributor.image.repository }}:{{ .Values.distributor.image.tag | default .Chart.AppVersion }}"
5481
livenessProbe:
5582
httpGet:
5683
path: /health
@@ -63,45 +90,63 @@ spec:
6390
port: 10999
6491
initialDelaySeconds: 5
6592
periodSeconds: 5
93+
imagePullPolicy: {{ .Values.distributor.image.pullPolicy }}
94+
ports:
95+
- containerPort: 8080
6696
resources:
6797
requests:
6898
memory: "16Mi"
6999
cpu: "25m"
70100
limits:
71-
memory: "128Mi"
72-
cpu: "250m"
101+
memory: "32Mi"
102+
cpu: "100m"
73103
env:
74104
- name: PUBSUB_URL
75105
value: 'nats://keptn-nats-cluster'
76106
- name: PUBSUB_TOPIC
77107
value: 'sh.keptn.event.monitoring.configure,sh.keptn.event.get-sli.triggered'
78108
- name: PUBSUB_RECIPIENT
79-
value: 'prometheus-service'
109+
value: '127.0.0.1'
110+
- name: STAGE_FILTER
111+
value: "{{ .Values.distributor.stageFilter }}"
112+
- name: PROJECT_FILTER
113+
value: "{{ .Values.distributor.projectFilter }}"
114+
- name: SERVICE_FILTER
115+
value: "{{ .Values.distributor.serviceFilter }}"
80116
- name: VERSION
81117
valueFrom:
82118
fieldRef:
83-
apiVersion: v1
84-
fieldPath: 'metadata.labels[''app.kubernetes.io/version'']'
119+
fieldPath: metadata.labels['app.kubernetes.io/version']
120+
- name: LOCATION
121+
valueFrom:
122+
fieldRef:
123+
fieldPath: metadata.labels['app.kubernetes.io/component']
85124
- name: K8S_DEPLOYMENT_NAME
86125
valueFrom:
87126
fieldRef:
88-
apiVersion: v1
89-
fieldPath: 'metadata.labels[''app.kubernetes.io/name'']'
127+
fieldPath: metadata.labels['app.kubernetes.io/name']
90128
- name: K8S_POD_NAME
91129
valueFrom:
92130
fieldRef:
93-
apiVersion: v1
94131
fieldPath: metadata.name
95132
- name: K8S_NAMESPACE
96133
valueFrom:
97134
fieldRef:
98-
apiVersion: v1
99135
fieldPath: metadata.namespace
100136
- name: K8S_NODE_NAME
101137
valueFrom:
102138
fieldRef:
103-
apiVersion: v1
104139
fieldPath: spec.nodeName
140+
{{- if .Values.remoteControlPlane.enabled }}
141+
- name: KEPTN_API_ENDPOINT
142+
value: "{{ .Values.remoteControlPlane.api.protocol }}://{{ .Values.remoteControlPlane.api.hostname }}/api"
143+
- name: KEPTN_API_TOKEN
144+
value: "{{ .Values.remoteControlPlane.api.token }}"
145+
- name: HTTP_SSL_VERIFY
146+
{{- $apiValidateTls := .Values.remoteControlPlane.api.apiValidateTls | ternary "true" "false" }}
147+
value: "{{ $apiValidateTls }}"
148+
{{- end }}
149+
105150
{{- with .Values.nodeSelector }}
106151
nodeSelector:
107152
{{- toYaml . | nindent 8 }}

chart/templates/serviceaccount.yaml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,116 @@ metadata:
99
annotations:
1010
{{- toYaml . | nindent 4 }}
1111
{{- end }}
12+
---
13+
apiVersion: rbac.authorization.k8s.io/v1
14+
kind: ClusterRole
15+
metadata:
16+
name: keptn-create-prom-clusterrole
17+
rules:
18+
- apiGroups:
19+
- "rbac.authorization.k8s.io"
20+
resources:
21+
- clusterroles
22+
- clusterrolebindings
23+
verbs:
24+
- get
25+
- create
26+
- update
27+
resourceNames:
28+
- "prometheus"
29+
---
30+
apiVersion: rbac.authorization.k8s.io/v1
31+
kind: ClusterRole
32+
metadata:
33+
name: keptn-prom-prometheus
34+
rules:
35+
- apiGroups:
36+
- ""
37+
resources:
38+
- endpoints
39+
- nodes
40+
- nodes/proxy
41+
- pods
42+
- services
43+
verbs:
44+
- get
45+
- list
46+
- watch
47+
- apiGroups:
48+
- "extensions"
49+
resources:
50+
- "ingresses"
51+
verbs:
52+
- get
53+
- list
54+
- watch
55+
- nonResourceURLs: [ "/metrics" ]
56+
verbs: [ "get" ]
57+
---
58+
apiVersion: rbac.authorization.k8s.io/v1
59+
kind: ClusterRole
60+
metadata:
61+
name: keptn-read-secret-prometheus
62+
rules:
63+
- apiGroups:
64+
- ""
65+
resources:
66+
- secrets
67+
verbs:
68+
- get
69+
- watch
70+
---
71+
apiVersion: rbac.authorization.k8s.io/v1
72+
kind: ClusterRoleBinding
73+
metadata:
74+
name: keptn-prometheus-sli-service
75+
roleRef:
76+
apiGroup: rbac.authorization.k8s.io
77+
kind: ClusterRole
78+
name: keptn-read-secret-prometheus
79+
subjects:
80+
- kind: ServiceAccount
81+
name: {{ include "prometheus-service.serviceAccountName" . }}
82+
namespace: keptn
83+
---
84+
apiVersion: rbac.authorization.k8s.io/v1
85+
kind: ClusterRoleBinding
86+
metadata:
87+
name: keptn-create-prom-clusterrole
88+
roleRef:
89+
apiGroup: rbac.authorization.k8s.io
90+
kind: ClusterRole
91+
name: keptn-create-prom-clusterrole
92+
subjects:
93+
- kind: ServiceAccount
94+
name: {{ include "prometheus-service.serviceAccountName" . }}
95+
namespace: keptn
96+
---
97+
apiVersion: rbac.authorization.k8s.io/v1
98+
kind: ClusterRoleBinding
99+
metadata:
100+
name: keptn-prom-prometheus
101+
roleRef:
102+
apiGroup: rbac.authorization.k8s.io
103+
kind: ClusterRole
104+
name: keptn-prom-prometheus
105+
subjects:
106+
- kind: ServiceAccount
107+
name: {{ include "prometheus-service.serviceAccountName" . }}
108+
namespace: keptn
109+
---
110+
apiVersion: rbac.authorization.k8s.io/v1
111+
kind: RoleBinding
112+
metadata:
113+
name: keptn-keptndomain-prom-service
114+
namespace: keptn
115+
roleRef:
116+
apiGroup: rbac.authorization.k8s.io
117+
kind: Role
118+
name: keptn-read-keptndomain
119+
subjects:
120+
- kind: ServiceAccount
121+
name: {{ include "prometheus-service.serviceAccountName" . }}
122+
namespace: keptn
123+
12124
{{- end }}

chart/values.yaml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@ image:
1010
# Overrides the image tag whose default is the chart appVersion.
1111
tag: ""
1212

13+
prometheus:
14+
namespace: "monitoring" # K8s namespace where prometheus is installed
15+
namespace_am: "monitoring" # K8s namespace where prometheus-alertmanager is installed
16+
endpoint: "http://prometheus-server.monitoring.svc.cluster.local:80" # HTTP Endpoint for Prometheus
17+
18+
distributor:
19+
stageFilter: "" # Sets the stage this helm service belongs to
20+
serviceFilter: "" # Sets the service this helm service belongs to
21+
projectFilter: "" # Sets the project this helm service belongs to
22+
image:
23+
repository: docker.io/keptn/distributor # Container Image Name
24+
pullPolicy: IfNotPresent # Kubernetes Image Pull Policy
25+
tag: "0.10.0" # Container Tag
26+
27+
remoteControlPlane:
28+
enabled: false # Enables remote execution plane mode
29+
api:
30+
protocol: "https" # Used Protocol (http, https)
31+
hostname: "" # Hostname of the control plane cluster (and Port)
32+
apiValidateTls: true # Defines if the control plane certificate should be validated
33+
token: "" # Keptn API Token
34+
1335
imagePullSecrets: []
1436
nameOverride: ""
1537
fullnameOverride: ""
@@ -21,7 +43,7 @@ serviceAccount:
2143
annotations: {}
2244
# The name of the service account to use.
2345
# If not set and create is true, a name is generated using the fullname template
24-
name: ""
46+
name: "keptn-prometheus-service"
2547

2648
podAnnotations: {}
2749

@@ -38,7 +60,7 @@ securityContext: {}
3860

3961
service:
4062
type: ClusterIP
41-
port: 80
63+
port: 8080
4264

4365
ingress:
4466
enabled: false
@@ -56,17 +78,13 @@ ingress:
5678
# hosts:
5779
# - chart-example.local
5880

59-
resources: {}
60-
# We usually recommend not to specify default resources and to leave this as a conscious
61-
# choice for the user. This also increases chances charts run on environments with little
62-
# resources, such as Minikube. If you do want to specify resources, uncomment the following
63-
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
64-
# limits:
65-
# cpu: 100m
66-
# memory: 128Mi
67-
# requests:
68-
# cpu: 100m
69-
# memory: 128Mi
81+
resources: # Resource limits and requests
82+
limits:
83+
cpu: 500m
84+
memory: 128Mi
85+
requests:
86+
cpu: 50m
87+
memory: 32Mi
7088

7189
autoscaling:
7290
enabled: false

0 commit comments

Comments
 (0)