Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helm-chart (#14) #79

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions charts/exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: ssl_exporter
description: A Helm chart for SSL Exporter
type: application
version: 0.1.0
appVersion: 2.3.1
ribbybibby marked this conversation as resolved.
Show resolved Hide resolved
39 changes: 39 additions & 0 deletions charts/exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{/*****************************************************************************

General templates

*****************************************************************************/}}

{{- define "name" -}}{{- /******************************************************
Expand the name of the chart
***************************************************************************/ -}}
{{- $.Chart.Name | trunc 63 | trimSuffix "-" }}
{{- end }}


{{- define "releasename" -}}{{- /**********************************************
Expand the name of the instance
***************************************************************************/ -}}
{{- $.Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}


{{- define "labels" -}}{{- /****************************************************
Define controller labels
***************************************************************************/ -}}
app.kubernetes.io/name: {{ include "name" $ }}
helm.sh/chart: {{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/version: {{ $.Chart.AppVersion }}
{{- end }}


{{- define "matchLabels" -}}{{- /**********************************************
Define labels are used by controllers to find their pods
***************************************************************************/ -}}
app.kubernetes.io/name: {{ include "name" $ }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
app.kubernetes.io/instance: {{ $.Release.Name }}
{{- end }}

45 changes: 45 additions & 0 deletions charts/exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: {{ $.Release.Namespace | quote }}
name: {{ include "releasename" $ | quote }}
labels: {{- include "labels" $ | nindent 4 }}
annotations: {{- toYaml $.Values.annotations | nindent 4 }}
spec:
selector:
matchLabels: {{- include "matchLabels" $ | nindent 6 }}
replicas: {{ int $.Values.replicaCount }}
strategy:
type: RollingUpdate
revisionHistoryLimit: 3

ribbybibby marked this conversation as resolved.
Show resolved Hide resolved
template:
metadata:
labels: {{- include "labels" $ | nindent 8 }}
spec:
restartPolicy: Always
terminationGracePeriodSeconds: {{ $.Values.terminationGracePeriodSeconds }}
nodeSelector: {{- toYaml $.Values.nodeSelector | nindent 8 }}
tolerations: {{- toYaml $.Values.tolerations | nindent 8 }}
affinity: {{- toYaml $.Values.affinity | nindent 8 }}
securityContext: {{- toYaml $.Values.securityContext | nindent 8 }}
imagePullSecrets: {{- toYaml $.Values.imagePullSecrets | nindent 8 }}
containers:

ribbybibby marked this conversation as resolved.
Show resolved Hide resolved
- name: exporter
image: ribbybibby/ssl-exporter:v{{ $.Chart.AppVersion }}
imagePullPolicy: {{ $.Values.podImagePullPolicy | quote }}
resources: {{ toYaml $.Values.resources | nindent 12 }}
ports:
- name: exporter
containerPort: 9219
readinessProbe:
{{- toYaml $.Values.probes.readiness | nindent 12 }}
httpGet:
port: exporter
path: /
livenessProbe:
{{- toYaml $.Values.probes.liveness | nindent 12 }}
httpGet:
port: exporter
path: /
17 changes: 17 additions & 0 deletions charts/exporter/templates/prometheus-operator-probes/demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if $.Values.prometheusOperator.enableExampleProbes }}
apiVersion: monitoring.coreos.com/v1
kind: Probe
metadata:
name: probe-demo
labels:
release: prometheus-operator
{{- include "labels" $ | nindent 4 }}
spec:
prober:
url: {{ printf "%s.%s.svc" (include "releasename" .) $.Release.Namespace | quote }}
module: http
targets:
staticConfig:
static:
- "https://demo.do.prometheus.io"
{{- end }}
16 changes: 16 additions & 0 deletions charts/exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
namespace: {{ $.Release.Namespace | quote }}
name: {{ include "releasename" $ | quote }}
labels: {{- include "labels" $ | nindent 4 }}
annotations: {{- toYaml $.Values.service.annotations | nindent 4 }}
spec:
ports:
- name: exporter
port: {{ $.Values.service.port }}
protocol: TCP
targetPort: exporter
selector: {{- include "matchLabels" $ | nindent 4 }}
sessionAffinity: {{ $.Values.service.sessionAffinity | quote }}
type: {{ $.Values.service.type | quote }}
41 changes: 41 additions & 0 deletions charts/exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
annotations: {}
replicaCount: 1
imagePullPolicy: Always
ribbybibby marked this conversation as resolved.
Show resolved Hide resolved
imagePullSecrets: []
nodeSelector: {}
tolerations: []
affinity: {}
securityContext: {}
# fsGroup: 1001
# runAsGroup: 1001
# runAsNonRoot: true
# runAsUser: 1001
Comment on lines +9 to +12
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these (and the resources below) commented out? As an example?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As example.
I didn't dive deep into securityContext, for now.
Perhaps you'll advise better default value for the parameter?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# fsGroup: 1001
# runAsGroup: 1001
# runAsNonRoot: true
# runAsUser: 1001
fsGroup: 100
runAsGroup: 100
runAsNonRoot: true
runAsUser: 100

The image runs as user 100 by default, so let's go with that.

resources: {}
# limits:
# cpu: 500m
# memory: 256Mi
# requests:
# cpu: 200m
# memory: 128Mi
terminationGracePeriodSeconds: 5
probes:
readiness:
initialDelaySeconds: 3
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
liveness:
initialDelaySeconds: 3
periodSeconds: 5
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
service:
enabled: true
annotations: {}
port: 80
sessionAffinity: None

prometheusOperator:
enableExampleProbes: false