Skip to content

Commit 194d767

Browse files
committed
Added helm chart
1 parent 27c4b99 commit 194d767

File tree

10 files changed

+417
-1
lines changed

10 files changed

+417
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.idea/
22
nirn-proxy.*
33
nirn-proxy
4+
!.helm/*
45
.env
5-
*.txt
66
*.log
77
k6_tests/node_modules

.helm/nirn-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/

.helm/nirn-proxy/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: nirn-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: 1.0.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+
# It is recommended to use it with quotes.
24+
appVersion: "1.3.3"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "nirn-proxy.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "nirn-proxy.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "nirn-proxy.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "nirn-proxy.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "nirn-proxy.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "nirn-proxy.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "nirn-proxy.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "nirn-proxy.labels" -}}
37+
helm.sh/chart: {{ include "nirn-proxy.chart" . }}
38+
{{ include "nirn-proxy.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "nirn-proxy.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "nirn-proxy.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: {{ include "nirn-proxy.fullname" . }}
5+
labels:
6+
{{- include "nirn-proxy.labels" . | nindent 4 }}
7+
spec:
8+
selector:
9+
matchLabels:
10+
{{- include "nirn-proxy.selectorLabels" . | nindent 6 }}
11+
template:
12+
metadata:
13+
{{- with .Values.podAnnotations }}
14+
annotations:
15+
{{- toYaml . | nindent 8 }}
16+
{{- end }}
17+
labels:
18+
{{- include "nirn-proxy.labels" . | nindent 8 }}
19+
{{- with .Values.podLabels }}
20+
{{- toYaml . | nindent 8 }}
21+
{{- end }}
22+
spec:
23+
{{- with .Values.imagePullSecrets }}
24+
imagePullSecrets:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
securityContext:
28+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
29+
containers:
30+
- name: {{ .Chart.Name }}
31+
securityContext:
32+
{{- toYaml .Values.securityContext | nindent 12 }}
33+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
34+
imagePullPolicy: {{ .Values.image.pullPolicy }}
35+
env:
36+
{{ if .Values.nirnProxy.logLevel }}
37+
- name: LOG_LEVEL
38+
value: {{ .Values.nirnProxy.logLevel }}
39+
{{ end }}
40+
- name: PORT
41+
value: {{ .Values.service.port | quote }}
42+
- name: METRICS_PORT
43+
value: {{ .Values.service.metricsPort | quote }}
44+
{{ if .Values.nirnProxy.enableMetrics }}
45+
- name: ENABLE_METRICS
46+
value: {{ .Values.nirnProxy.enableMetrics | quote }}
47+
{{ end }}
48+
{{ if .Values.nirnProxy.enablePprof }}
49+
- name: ENABLE_PPROF
50+
value: {{ .Values.nirnProxy.enablePprof | quote }}
51+
{{ end }}
52+
{{ if .Values.nirnProxy.bufferSize }}
53+
- name: BUFFER_SIZE
54+
value: {{ .Values.nirnProxy.bufferSize | quote }}
55+
{{ end }}
56+
{{ if .Values.nirnProxy.outboundIp }}
57+
- name: OUTBOUND_IP
58+
value: {{ .Values.nirnProxy.outboundIp }}
59+
{{ end }}
60+
- name: BIND_IP
61+
value: '0.0.0.0'
62+
{{ if .Values.nirnProxy.requestTimeout }}
63+
- name: REQUEST_TIMEOUT
64+
value: {{ .Values.nirnProxy.requestTimeout | quote }}
65+
{{ end }}
66+
- name: CLUSTER_PORT
67+
value: {{ .Values.service.clusterPort | quote }}
68+
{{ if .Values.nirnProxy.clusterMembers }}
69+
- name: CLUSTER_MEMBERS
70+
value: {{ .Values.nirnProxy.clusterMembers }}
71+
{{ end }}
72+
- name: CLUSTER_DNS
73+
value: {{ printf "%s-headless" (include "nirn-proxy.fullname" .) }}
74+
- name: MAX_BEARER_COUNT
75+
value: {{ .Values.nirnProxy.maxBearerCount | quote }}
76+
{{ if .Values.nirnProxy.disableHttp2 }}
77+
- name: DISABLE_HTTP_2
78+
value: {{ .Values.nirnProxy.disableHttp2 | quote }}
79+
{{ end }}
80+
{{ if .Values.nirnProxy.botRateLimitOverrides }}
81+
- name: BOT_RATELIMIT_OVERRIDES
82+
value: {{ .Values.nirnProxy.botRateLimitOverrides }}
83+
{{ end }}
84+
{{ if .Values.nirnProxy.disableGlobalRateLimitDetection }}
85+
- name: DISABLE_GLOBAL_RATELIMIT_DETECTION
86+
value: {{ .Values.nirnProxy.disableGlobalRateLimitDetection | quote }}
87+
{{ end }}
88+
ports:
89+
- name: http
90+
containerPort: {{ .Values.service.port }}
91+
protocol: TCP
92+
- name: metrics
93+
containerPort: {{ .Values.service.metricsPort }}
94+
protocol: TCP
95+
- name: cluster
96+
containerPort: {{ .Values.service.clusterPort }}
97+
protocol: TCP
98+
livenessProbe:
99+
{{- toYaml .Values.livenessProbe | nindent 12 }}
100+
readinessProbe:
101+
{{- toYaml .Values.readinessProbe | nindent 12 }}
102+
resources:
103+
{{- toYaml .Values.resources | nindent 12 }}
104+
{{- with .Values.nodeSelector }}
105+
nodeSelector:
106+
{{- toYaml . | nindent 8 }}
107+
{{- end }}
108+
{{- with .Values.affinity }}
109+
affinity:
110+
{{- toYaml . | nindent 8 }}
111+
{{- end }}
112+
{{- with .Values.tolerations }}
113+
tolerations:
114+
{{- toYaml . | nindent 8 }}
115+
{{- end }}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "nirn-proxy.fullname" . }}
6+
labels:
7+
{{- include "nirn-proxy.labels" . | nindent 4 }}
8+
{{- with .Values.ingress.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
{{- with .Values.ingress.className }}
14+
ingressClassName: {{ . }}
15+
{{- end }}
16+
{{- if .Values.ingress.tls }}
17+
tls:
18+
{{- range .Values.ingress.tls }}
19+
- hosts:
20+
{{- range .hosts }}
21+
- {{ . | quote }}
22+
{{- end }}
23+
secretName: {{ .secretName }}
24+
{{- end }}
25+
{{- end }}
26+
rules:
27+
{{- range .Values.ingress.hosts }}
28+
- host: {{ .host | quote }}
29+
http:
30+
paths:
31+
{{- range .paths }}
32+
- path: {{ .path }}
33+
{{- with .pathType }}
34+
pathType: {{ . }}
35+
{{- end }}
36+
backend:
37+
service:
38+
name: {{ include "nirn-proxy.fullname" $ }}
39+
port:
40+
number: {{ $.Values.service.port }}
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ printf "%s-headless" (include "nirn-proxy.fullname" .) }}
5+
labels:
6+
{{- include "nirn-proxy.labels" . | nindent 4 }}
7+
spec:
8+
type: ClusterIP
9+
clusterIP: None
10+
ports:
11+
- port: {{ .Values.service.clusterPort }}
12+
targetPort: cluster
13+
protocol: TCP
14+
name: cluster
15+
selector:
16+
{{- include "nirn-proxy.selectorLabels" . | nindent 4 }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "nirn-proxy.fullname" . }}
5+
labels:
6+
{{- include "nirn-proxy.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: http
14+
- port: {{ .Values.service.metricsPort }}
15+
targetPort: metrics
16+
protocol: TCP
17+
name: metrics
18+
selector:
19+
{{- include "nirn-proxy.selectorLabels" . | nindent 4 }}

0 commit comments

Comments
 (0)