Skip to content

Add Helm Charts #149

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

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions charts/nlk/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Patterns to ignore when building packages.
.png
16 changes: 16 additions & 0 deletions charts/nlk/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v2
appVersion: 0.1.0
description: NGINX LoadBalancer for Kubernetes
name: nginx-loadbalancer-kubernetes
home: https://github.com/nginxinc/nginx-loadbalancer-kubernetes
icon: https://raw.githubusercontent.com/nginxinc/nginx-loadbalancer-kubernetes/main/nlk-logo.svg
keywords:
- nginx
- loadbalancer
- ingress
kubeVersion: '>= 1.22.0-0'
maintainers:
name: "@ciroque"
name: "@chrisakker"
type: application
version: 0.0.1
110 changes: 110 additions & 0 deletions charts/nlk/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{{/* vim: set filetype=mustache: */}}

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

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "nlk.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create a default fully qualified nlk name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "nlk.nlk.fullname" -}}
{{- printf "%s-%s" (include "nlk.fullname" .) .Values.nlk.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified nlk service name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "nlk.nlk.service.name" -}}
{{- default (include "nlk.nlk.fullname" .) .Values.serviceNameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "nlk.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "nlk.labels" -}}
helm.sh/chart: {{ include "nlk.chart" . }}
{{ include "nlk.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "nlk.selectorLabels" -}}
{{- if .Values.nlk.selectorLabels -}}
{{ toYaml .Values.nlk.selectorLabels }}
{{- else -}}
app.kubernetes.io/name: {{ include "nlk.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{- end -}}

{{/*
Expand the name of the configmap.
*/}}
{{- define "nlk.configName" -}}
{{- if .Values.nlk.customConfigMap -}}
{{ .Values.nlk.customConfigMap }}
{{- else -}}
{{- default (include "nlk.fullname" .) .Values.nlk.config.name -}}
{{- end -}}
{{- end -}}

{{/*
Expand service account name.
*/}}
{{- define "nlk.serviceAccountName" -}}
{{- default (include "nlk.fullname" .) .Values.nlk.serviceAccount.name -}}
{{- end -}}

{{- define "nlk.tag" -}}
{{- default .Chart.AppVersion .Values.nlk.image.tag -}}
{{- end -}}

{{/*
Expand image name.
*/}}
{{- define "nlk.image" -}}
{{- if .Values.nlk.image.digest -}}
{{- printf "%s@%s" .Values.nlk.image.repository .Values.nlk.image.digest -}}
{{- else -}}
{{- printf "%s:%s" .Values.nlk.image.repository (include "nlk.tag" .) -}}
{{- end -}}
{{- end -}}

{{- define "nlk.prometheus.serviceName" -}}
{{- printf "%s-%s" (include "nlk.fullname" .) "prometheus-service" -}}
{{- end -}}
19 changes: 19 additions & 0 deletions charts/nlk/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: resource-get-watch-list
namespace: nlk
rules:
- apiGroups:
- ""
resources:
- configmaps
- nodes
- secrets
- services
verbs:
- get
- list
- watch
{{- end }}
15 changes: 15 additions & 0 deletions charts/nlk/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: "nginx-loadbalancer-kubernetes:resource-get-watch-list"
namespace: nlk
subjects:
- kind: ServiceAccount
name: {{ .Values.nlk.serviceAccount.name }}
namespace: nlk
roleRef:
kind: ClusterRole
name: resource-get-watch-list
apiGroup: rbac.authorization.k8s.io
{{- end }}
13 changes: 13 additions & 0 deletions charts/nlk/templates/nlk-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nlk-config
namespace: nlk
data:
{{- if .Values.nlk.config.entries.hosts }}
nginx-hosts: "{{ .Values.nlk.config.entries.hosts }}"
{{- end }}
tls-mode: "{{ .Values.nlk.defaultTLS.tls-mode }}"
ca-certificate: "{{ .Values.nlk.defaultTLS.ca-certificate }}"
client-certificate: "{{ .Values.nlk.defaultTLS.client-certificate }}"
log-level: "{{ .Values.nlk.logLevel }}"
44 changes: 44 additions & 0 deletions charts/nlk/templates/nlk-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-nlk
namespace: nlk
labels:
app: nlk
spec:
replicas: {{ .Values.nlk.replicaCount }}
selector:
matchLabels:
app: nlk
template:
metadata:
labels:
app: nlk
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.nlk.image.repository }}:{{ .Values.nlk.image.tag }}"
imagePullPolicy: {{ .Values.nlk.image.pullPolicy }}
ports:
{{- range $key, $value := .Values.nlk.containerPort }}
- name: {{ $key }}
containerPort: {{ $value }}
protocol: TCP
{{- end }}
{{- if .Values.nlk.liveStatus.enable }}
livenessProbe:
httpGet:
path: /livez
port: {{ .Values.nlk.liveStatus.port }}
initialDelaySeconds: {{ .Values.nlk.liveStatus.initialDelaySeconds }}
periodSeconds: {{ .Values.nlk.readyStatus.periodSeconds }}
{{- end }}
{{- if .Values.nlk.readyStatus.enable }}
readinessProbe:
httpGet:
path: /readyz
port: {{ .Values.nlk.readyStatus.port }}
initialDelaySeconds: {{ .Values.nlk.readyStatus.initialDelaySeconds }}
periodSeconds: {{ .Values.nlk.readyStatus.periodSeconds }}
{{- end }}
serviceAccountName: {{ .Values.nlk.serviceAccount.name }}
8 changes: 8 additions & 0 deletions charts/nlk/templates/nlk-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: nginx-loadbalancer-kubernetes-secret
namespace: nlk
annotations:
kubernetes.io/service-account.name: {{ .Values.nlk.serviceAccount.name }}
type: kubernetes.io/service-account-token
7 changes: 7 additions & 0 deletions charts/nlk/templates/nlk-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- if .Values.rbac.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: nginx-loadbalancer-kubernetes
namespace: nlk
{{- end }}
126 changes: 126 additions & 0 deletions charts/nlk/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
nlk:
name: nginx-loadbalancer-kubernetes

kind: deployment

replicaCount: 1

image:
repository: ghcr.io/nginxinc/nginx-loadbalancer-kubernetes
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: latest

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: nginx-loadbalancer-kubernetes

podAnnotations: {}
podLabels: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 80

ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

resources:
requests:
cpu: 100m
memory: 128Mi
# limits:
# cpu: 100m
# memory: 128Mi

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 3
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false

# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true

nodeSelector: {}

tolerations: []

affinity: {}

config:
entries:
hosts:
"http://10.1.1.4:9000/api,http://10.1.1.5:9000/api"

defaultTLS:
tls-mode: "no-tls"
ca-certificate: ""
client-certificate: ""

logLevel: "warn"

containerPort:
http: 51031

liveStatus:
enable: true
port: 51031
initialDelaySeconds: 5
periodSeconds: 2

readyStatus:
enable: true
port: 51031
initialDelaySeconds: 5
periodSeconds: 2

rbac:
## Configures RBAC.
create: true