Skip to content

Commit b07137e

Browse files
committed
Add Helm Charts
1 parent b48ad7f commit b07137e

10 files changed

+360
-0
lines changed

charts/nlk/.helmignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Patterns to ignore when building packages.
2+
.png

charts/nlk/Chart.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v2
2+
appVersion: 0.1.0
3+
description: NGINX LoadBalancer for Kubernetes
4+
name: nginx-loadbalancer-kubernetes
5+
home: https://github.com/nginxinc/nginx-loadbalancer-kubernetes
6+
icon: https://raw.githubusercontent.com/nginxinc/nginx-loadbalancer-kubernetes/main/nlk-logo.svg
7+
keywords:
8+
- nginx
9+
- loadbalancer
10+
- ingress
11+
kubeVersion: '>= 1.22.0-0'
12+
maintainers:
13+
name: "@ciroque"
14+
name: "@chrisakker"
15+
type: application
16+
version: 0.0.1

charts/nlk/templates/_helpers.tpl

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
3+
{{/*
4+
Expand the name of the chart.
5+
*/}}
6+
{{- define "nlk.name" -}}
7+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
8+
{{- end }}
9+
10+
{{/*
11+
Create a default fully qualified app name.
12+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
13+
If release name contains chart name it will be used as a full name.
14+
*/}}
15+
{{- define "nlk.fullname" -}}
16+
{{- if .Values.fullnameOverride }}
17+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
18+
{{- else }}
19+
{{- $name := default .Chart.Name .Values.nameOverride }}
20+
{{- if contains $name .Release.Name }}
21+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
22+
{{- else }}
23+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
24+
{{- end }}
25+
{{- end }}
26+
{{- end }}
27+
28+
{{/*
29+
Create a default fully qualified nlk name.
30+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
31+
*/}}
32+
{{- define "nlk.nlk.fullname" -}}
33+
{{- printf "%s-%s" (include "nlk.fullname" .) .Values.nlk.name | trunc 63 | trimSuffix "-" -}}
34+
{{- end -}}
35+
36+
{{/*
37+
Create a default fully qualified nlk service name.
38+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
39+
*/}}
40+
{{- define "nlk.nlk.service.name" -}}
41+
{{- default (include "nlk.nlk.fullname" .) .Values.serviceNameOverride | trunc 63 | trimSuffix "-" -}}
42+
{{- end -}}
43+
44+
{{/*
45+
Create chart name and version as used by the chart label.
46+
*/}}
47+
{{- define "nlk.chart" -}}
48+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
49+
{{- end }}
50+
51+
{{/*
52+
Common labels
53+
*/}}
54+
{{- define "nlk.labels" -}}
55+
helm.sh/chart: {{ include "nlk.chart" . }}
56+
{{ include "nlk.selectorLabels" . }}
57+
{{- if .Chart.AppVersion }}
58+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
59+
{{- end }}
60+
app.kubernetes.io/managed-by: {{ .Release.Service }}
61+
{{- end }}
62+
63+
{{/*
64+
Selector labels
65+
*/}}
66+
{{- define "nlk.selectorLabels" -}}
67+
{{- if .Values.nlk.selectorLabels -}}
68+
{{ toYaml .Values.nlk.selectorLabels }}
69+
{{- else -}}
70+
app.kubernetes.io/name: {{ include "nlk.name" . }}
71+
app.kubernetes.io/instance: {{ .Release.Name }}
72+
{{- end -}}
73+
{{- end -}}
74+
75+
{{/*
76+
Expand the name of the configmap.
77+
*/}}
78+
{{- define "nlk.configName" -}}
79+
{{- if .Values.nlk.customConfigMap -}}
80+
{{ .Values.nlk.customConfigMap }}
81+
{{- else -}}
82+
{{- default (include "nlk.fullname" .) .Values.nlk.config.name -}}
83+
{{- end -}}
84+
{{- end -}}
85+
86+
{{/*
87+
Expand service account name.
88+
*/}}
89+
{{- define "nlk.serviceAccountName" -}}
90+
{{- default (include "nlk.fullname" .) .Values.nlk.serviceAccount.name -}}
91+
{{- end -}}
92+
93+
{{- define "nlk.tag" -}}
94+
{{- default .Chart.AppVersion .Values.nlk.image.tag -}}
95+
{{- end -}}
96+
97+
{{/*
98+
Expand image name.
99+
*/}}
100+
{{- define "nlk.image" -}}
101+
{{- if .Values.nlk.image.digest -}}
102+
{{- printf "%s@%s" .Values.nlk.image.repository .Values.nlk.image.digest -}}
103+
{{- else -}}
104+
{{- printf "%s:%s" .Values.nlk.image.repository (include "nlk.tag" .) -}}
105+
{{- end -}}
106+
{{- end -}}
107+
108+
{{- define "nlk.prometheus.serviceName" -}}
109+
{{- printf "%s-%s" (include "nlk.fullname" .) "prometheus-service" -}}
110+
{{- end -}}

charts/nlk/templates/clusterrole.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: resource-get-watch-list
6+
namespace: nlk
7+
rules:
8+
- apiGroups:
9+
- ""
10+
resources:
11+
- configmaps
12+
- nodes
13+
- secrets
14+
- services
15+
verbs:
16+
- get
17+
- list
18+
- watch
19+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRoleBinding
4+
metadata:
5+
name: "nginx-loadbalancer-kubernetes:resource-get-watch-list"
6+
namespace: nlk
7+
subjects:
8+
- kind: ServiceAccount
9+
name: {{ .Values.nlk.serviceAccount.name }}
10+
namespace: nlk
11+
roleRef:
12+
kind: ClusterRole
13+
name: resource-get-watch-list
14+
apiGroup: rbac.authorization.k8s.io
15+
{{- end }}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: nlk-config
5+
namespace: nlk
6+
data:
7+
{{- if .Values.nlk.config.entries.hosts }}
8+
nginx-hosts: "{{ .Values.nlk.config.entries.hosts }}"
9+
{{- end }}
10+
tls-mode: "{{ .Values.nlk.defaultTLS.tls-mode }}"
11+
ca-certificate: "{{ .Values.nlk.defaultTLS.ca-certificate }}"
12+
client-certificate: "{{ .Values.nlk.defaultTLS.client-certificate }}"
13+
log-level: "{{ .Values.nlk.logLevel }}"
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ .Release.Name }}-nlk
5+
namespace: nlk
6+
labels:
7+
app: nlk
8+
spec:
9+
replicas: {{ .Values.nlk.replicaCount }}
10+
selector:
11+
matchLabels:
12+
app: nlk
13+
template:
14+
metadata:
15+
labels:
16+
app: nlk
17+
spec:
18+
containers:
19+
- name: {{ .Chart.Name }}
20+
image: "{{ .Values.nlk.image.repository }}:{{ .Values.nlk.image.tag }}"
21+
imagePullPolicy: {{ .Values.nlk.image.pullPolicy }}
22+
ports:
23+
{{- range $key, $value := .Values.nlk.containerPort }}
24+
- name: {{ $key }}
25+
containerPort: {{ $value }}
26+
protocol: TCP
27+
{{- end }}
28+
{{- if .Values.nlk.liveStatus.enable }}
29+
livenessProbe:
30+
httpGet:
31+
path: /livez
32+
port: {{ .Values.nlk.liveStatus.port }}
33+
initialDelaySeconds: {{ .Values.nlk.liveStatus.initialDelaySeconds }}
34+
periodSeconds: {{ .Values.nlk.readyStatus.periodSeconds }}
35+
{{- end }}
36+
{{- if .Values.nlk.readyStatus.enable }}
37+
readinessProbe:
38+
httpGet:
39+
path: /readyz
40+
port: {{ .Values.nlk.readyStatus.port }}
41+
initialDelaySeconds: {{ .Values.nlk.readyStatus.initialDelaySeconds }}
42+
periodSeconds: {{ .Values.nlk.readyStatus.periodSeconds }}
43+
{{- end }}
44+
serviceAccountName: {{ .Values.nlk.serviceAccount.name }}

charts/nlk/templates/nlk-secret.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: nginx-loadbalancer-kubernetes-secret
5+
namespace: nlk
6+
annotations:
7+
kubernetes.io/service-account.name: {{ .Values.nlk.serviceAccount.name }}
8+
type: kubernetes.io/service-account-token
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: nginx-loadbalancer-kubernetes
6+
namespace: nlk
7+
{{- end }}

charts/nlk/values.yaml

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
nlk:
2+
name: nginx-loadbalancer-kubernetes
3+
4+
kind: deployment
5+
6+
replicaCount: 1
7+
8+
image:
9+
repository: ghcr.io/nginxinc/nginx-loadbalancer-kubernetes
10+
pullPolicy: Always
11+
# Overrides the image tag whose default is the chart appVersion.
12+
tag: latest
13+
14+
imagePullSecrets: []
15+
nameOverride: ""
16+
fullnameOverride: ""
17+
18+
serviceAccount:
19+
# Specifies whether a service account should be created
20+
create: true
21+
# Automatically mount a ServiceAccount's API credentials?
22+
automount: true
23+
# Annotations to add to the service account
24+
annotations: {}
25+
# The name of the service account to use.
26+
# If not set and create is true, a name is generated using the fullname template
27+
name: nginx-loadbalancer-kubernetes
28+
29+
podAnnotations: {}
30+
podLabels: {}
31+
32+
podSecurityContext: {}
33+
# fsGroup: 2000
34+
35+
securityContext: {}
36+
# capabilities:
37+
# drop:
38+
# - ALL
39+
# readOnlyRootFilesystem: true
40+
# runAsNonRoot: true
41+
# runAsUser: 1000
42+
43+
service:
44+
type: ClusterIP
45+
port: 80
46+
47+
ingress:
48+
enabled: false
49+
className: ""
50+
annotations: {}
51+
# kubernetes.io/ingress.class: nginx
52+
# kubernetes.io/tls-acme: "true"
53+
hosts:
54+
- host: chart-example.local
55+
paths:
56+
- path: /
57+
pathType: ImplementationSpecific
58+
tls: []
59+
# - secretName: chart-example-tls
60+
# hosts:
61+
# - chart-example.local
62+
63+
resources:
64+
requests:
65+
cpu: 100m
66+
memory: 128Mi
67+
# limits:
68+
# cpu: 100m
69+
# memory: 128Mi
70+
71+
autoscaling:
72+
enabled: false
73+
minReplicas: 1
74+
maxReplicas: 3
75+
targetCPUUtilizationPercentage: 80
76+
# targetMemoryUtilizationPercentage: 80
77+
78+
# Additional volumes on the output Deployment definition.
79+
volumes: []
80+
# - name: foo
81+
# secret:
82+
# secretName: mysecret
83+
# optional: false
84+
85+
# Additional volumeMounts on the output Deployment definition.
86+
volumeMounts: []
87+
# - name: foo
88+
# mountPath: "/etc/foo"
89+
# readOnly: true
90+
91+
nodeSelector: {}
92+
93+
tolerations: []
94+
95+
affinity: {}
96+
97+
config:
98+
entries:
99+
hosts:
100+
"http://10.1.1.4:9000/api,http://10.1.1.5:9000/api"
101+
102+
defaultTLS:
103+
tls-mode: "no-tls"
104+
ca-certificate: ""
105+
client-certificate: ""
106+
107+
logLevel: "warn"
108+
109+
containerPort:
110+
http: 51031
111+
112+
liveStatus:
113+
enable: true
114+
port: 51031
115+
initialDelaySeconds: 5
116+
periodSeconds: 2
117+
118+
readyStatus:
119+
enable: true
120+
port: 51031
121+
initialDelaySeconds: 5
122+
periodSeconds: 2
123+
124+
rbac:
125+
## Configures RBAC.
126+
create: true

0 commit comments

Comments
 (0)