Skip to content

Commit 775fe4e

Browse files
committed
Helm 3 chart / helm client 3.2.1
1 parent 85b8eca commit 775fe4e

18 files changed

+488
-2
lines changed

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ GOOS ?= linux
2222
LOCAL_IMAGE ?= local/$(BINARY)
2323
CLOUD_IMAGE ?= grepplabs/mqtt-proxy:$(TAG)
2424

25+
HELM_BIN ?= helm3
26+
HELM_VALUES ?= noop
27+
SVC_NAME ?= mqtt-proxy
28+
SVC_NAMESPACE ?= mqtt
29+
2530
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2631

2732
default: build
@@ -86,3 +91,25 @@ release-publish: release-setup
8691
.PHONY: release-snapshot
8792
release-snapshot:
8893
REVISION=$(REVISION) BRANCH=$(BRANCH) BUILD_DATE=$(BUILD_DATE) $(ROOT_DIR)/bin/goreleaser --debug --rm-dist --snapshot --skip-publish
94+
95+
96+
.PHONY: helm-template
97+
helm-template:
98+
$(HELM_BIN) template $(SVC_NAME) $(ROOT_DIR)/charts/mqtt-proxy \
99+
-f $(ROOT_DIR)/charts/mqtt-proxy/values-$(HELM_VALUES).yaml \
100+
--namespace=$(SVC_NAMESPACE)
101+
102+
.PHONY: helm-install
103+
helm-install:
104+
$(HELM_BIN) upgrade $(SVC_NAME) $(ROOT_DIR)/charts/mqtt-proxy \
105+
-f $(ROOT_DIR)/charts/mqtt-proxy/values-$(HELM_VALUES).yaml \
106+
--namespace=$(SVC_NAMESPACE) \
107+
--install \
108+
--create-namespace
109+
110+
.PHONY: helm-test
111+
helm-test:
112+
$(HELM_BIN) test $(SVC_NAME) \
113+
--namespace=$(SVC_NAMESPACE)
114+
115+

charts/mqtt-proxy/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/mqtt-proxy/Chart.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v2
2+
name: mqtt-proxy
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
appVersion: 0.0.1
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "mqtt-proxy.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
7+
{{- end }}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "mqtt-proxy.fullname" -}}
15+
{{- if .Values.fullnameOverride }}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
17+
{{- else }}
18+
{{- $name := default .Chart.Name .Values.nameOverride }}
19+
{{- if contains $name .Release.Name }}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
21+
{{- else }}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
23+
{{- end }}
24+
{{- end }}
25+
{{- end }}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "mqtt-proxy.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
32+
{{- end }}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "mqtt-proxy.labels" -}}
38+
helm.sh/chart: {{ include "mqtt-proxy.chart" . }}
39+
{{ include "mqtt-proxy.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end }}
45+
46+
{{/*
47+
Selector labels
48+
*/}}
49+
{{- define "mqtt-proxy.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "mqtt-proxy.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end }}
53+
54+
{{/*
55+
Create the name of the service account to use
56+
*/}}
57+
{{- define "mqtt-proxy.serviceAccountName" -}}
58+
{{- if .Values.serviceAccount.create }}
59+
{{- default (include "mqtt-proxy.fullname" .) .Values.serviceAccount.name }}
60+
{{- else }}
61+
{{- default "default" .Values.serviceAccount.name }}
62+
{{- end }}
63+
{{- end }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "mqtt-proxy.fullname" . }}
5+
labels:
6+
{{- include "mqtt-proxy.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "mqtt-proxy.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "mqtt-proxy.selectorLabels" . | nindent 8 }}
22+
spec:
23+
{{- with .Values.imagePullSecrets }}
24+
imagePullSecrets:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
serviceAccountName: {{ include "mqtt-proxy.serviceAccountName" . }}
28+
securityContext:
29+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
30+
containers:
31+
- name: {{ .Chart.Name }}
32+
securityContext:
33+
{{- toYaml .Values.securityContext | nindent 12 }}
34+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
35+
imagePullPolicy: {{ .Values.image.pullPolicy }}
36+
args:
37+
{{- if .Values.extraArgs }}
38+
{{ toYaml .Values.extraArgs | indent 12 }}
39+
{{- end }}
40+
ports:
41+
- name: http
42+
containerPort: {{ .Values.container.http.port }}
43+
protocol: TCP
44+
- name: mqtt
45+
containerPort: {{ .Values.container.mqtt.port }}
46+
protocol: TCP
47+
livenessProbe:
48+
httpGet:
49+
path: /healthy
50+
port: http
51+
readinessProbe:
52+
httpGet:
53+
path: /ready
54+
port: http
55+
resources:
56+
{{- toYaml .Values.resources | nindent 12 }}
57+
{{- with .Values.nodeSelector }}
58+
nodeSelector:
59+
{{- toYaml . | nindent 8 }}
60+
{{- end }}
61+
{{- with .Values.affinity }}
62+
affinity:
63+
{{- toYaml . | nindent 8 }}
64+
{{- end }}
65+
{{- with .Values.tolerations }}
66+
tolerations:
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}

charts/mqtt-proxy/templates/hpa.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2beta1
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "mqtt-proxy.fullname" . }}
6+
labels:
7+
{{- include "mqtt-proxy.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "mqtt-proxy.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
21+
{{- end }}
22+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
23+
- type: Resource
24+
resource:
25+
name: memory
26+
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
27+
{{- end }}
28+
{{- end }}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{- if .Values.serviceExternal.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "mqtt-proxy.fullname" . }}-external
6+
labels:
7+
{{- include "mqtt-proxy.labels" . | nindent 4 }}
8+
{{- with .Values.serviceExternal.labels -}}
9+
{{ toYaml . | nindent 4 }}
10+
{{- end }}
11+
{{- if .Values.serviceExternal.annotations }}
12+
annotations:
13+
{{ tpl (toYaml .Values.serviceExternal.annotations) . | indent 4 }}
14+
{{- end }}
15+
spec:
16+
type: {{ .Values.serviceExternal.type }}
17+
ports:
18+
- port: {{ .Values.serviceExternal.port }}
19+
targetPort: mqtt
20+
protocol: TCP
21+
name: mqtt
22+
{{- if ne .Values.serviceExternal.type "NodePort" }}
23+
{{- if and (eq .Values.serviceExternal.type "LoadBalancer") (ne .Values.serviceExternal.clusterIP "None") }}
24+
clusterIP: "{{ .Values.serviceExternal.clusterIP }}"
25+
{{- end }}
26+
{{- end }}
27+
{{- if .Values.serviceExternal.externalIPs }}
28+
externalIPs:
29+
{{ toYaml .Values.serviceExternal.externalIPs | indent 4 }}
30+
{{- end }}
31+
{{- if .Values.serviceExternal.loadBalancerIP }}
32+
loadBalancerIP: "{{ .Values.serviceExternal.loadBalancerIP }}"
33+
{{- end }}
34+
{{- if .Values.serviceExternal.externalTrafficPolicy }}
35+
externalTrafficPolicy: "{{ .Values.serviceExternal.externalTrafficPolicy }}"
36+
{{- end }}
37+
{{- if .Values.serviceExternal.loadBalancerSourceRanges }}
38+
loadBalancerSourceRanges:
39+
{{ toYaml .Values.serviceExternal.loadBalancerSourceRanges | indent 4 }}
40+
{{- end }}
41+
selector:
42+
{{- include "mqtt-proxy.selectorLabels" . | nindent 4 }}
43+
{{- end }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "mqtt-proxy.fullname" . }}
5+
labels:
6+
{{- include "mqtt-proxy.labels" . | nindent 4 }}
7+
{{- with .Values.service.labels -}}
8+
{{ toYaml . | nindent 4 }}
9+
{{- end }}
10+
{{- if .Values.service.annotations }}
11+
annotations:
12+
{{ tpl (toYaml .Values.service.annotations) . | indent 4 }}
13+
{{- end }}
14+
spec:
15+
type: {{ .Values.service.type }}
16+
ports:
17+
- port: {{ .Values.service.http.port }}
18+
targetPort: http
19+
protocol: TCP
20+
name: http
21+
- port: {{ .Values.service.mqtt.port }}
22+
targetPort: mqtt
23+
protocol: TCP
24+
name: mqtt
25+
selector:
26+
{{- include "mqtt-proxy.selectorLabels" . | nindent 4 }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "mqtt-proxy.serviceAccountName" . }}
6+
labels:
7+
{{- include "mqtt-proxy.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- end }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if .Values.serviceMonitor.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: ServiceMonitor
4+
metadata:
5+
name: {{ include "mqtt-proxy.fullname" . }}
6+
labels:
7+
{{- include "mqtt-proxy.labels" . | nindent 4 }}
8+
{{- with .Values.serviceMonitor.labels -}}
9+
{{ toYaml . | nindent 4 }}
10+
{{- end }}
11+
spec:
12+
endpoints:
13+
- port: http
14+
path: /metrics
15+
interval: {{ .Values.serviceMonitor.interval }}
16+
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
17+
namespaceSelector:
18+
matchNames:
19+
- {{ .Release.Namespace }}
20+
selector:
21+
{{- include "mqtt-proxy.selectorLabels" . | nindent 4 }}
22+
{{- end }}

0 commit comments

Comments
 (0)