feat: Helm chart
This commit is contained in:
52
deployments/helm/templates/_helpers.tpl
Normal file
52
deployments/helm/templates/_helpers.tpl
Normal file
@@ -0,0 +1,52 @@
|
||||
{{/* Define namespace of chart, useful for multi-namespace deployments */}}
|
||||
{{- define "proxy-3proxy.namespace" -}}
|
||||
{{- if .Values.namespaceOverride }}
|
||||
{{- .Values.namespaceOverride }}
|
||||
{{- else }}
|
||||
{{- .Release.Namespace }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/* Expand the name of the chart */}}
|
||||
{{- define "proxy-3proxy.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 "proxy-3proxy.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 chart name and version as used by the chart label */}}
|
||||
{{- define "proxy-3proxy.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/* Common labels */}}
|
||||
{{- define "proxy-3proxy.commonLabels" -}}
|
||||
helm.sh/chart: {{ include "proxy-3proxy.chart" . }}
|
||||
{{ include "proxy-3proxy.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/* Selector labels */}}
|
||||
{{- define "proxy-3proxy.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "proxy-3proxy.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
194
deployments/helm/templates/deployment.yaml
Normal file
194
deployments/helm/templates/deployment.yaml
Normal file
@@ -0,0 +1,194 @@
|
||||
{{- if .Values.deployment.enabled }}
|
||||
apiVersion: apps/v1
|
||||
kind: {{ .Values.deployment.kind | default "Deployment" }}
|
||||
|
||||
metadata:
|
||||
name: {{ include "proxy-3proxy.fullname" . }}
|
||||
namespace: {{ template "proxy-3proxy.namespace" . }}
|
||||
labels:
|
||||
{{- include "proxy-3proxy.commonLabels" . | nindent 4 }}
|
||||
|
||||
spec:
|
||||
{{- with .Values.deployment }}
|
||||
replicas: {{ .replicas | default 1 }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "proxy-3proxy.selectorLabels" $ | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with .podAnnotations }}
|
||||
annotations:
|
||||
{{- tpl (toYaml .) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "proxy-3proxy.commonLabels" $ | nindent 8 }}
|
||||
{{- with .labels }}
|
||||
{{- tpl (toYaml .) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
{{- with .imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- tpl (toYaml .) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ include "proxy-3proxy.fullname" $ }}
|
||||
|
||||
{{- with .securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
readOnlyRootFilesystem: false
|
||||
{{- end }}
|
||||
|
||||
{{- with $.Values.image }}
|
||||
image: "{{ .repository }}:{{ .tag | default $.Chart.AppVersion }}"
|
||||
imagePullPolicy: {{ .pullPolicy | default "IfNotPresent" }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3128
|
||||
protocol: TCP
|
||||
- name: socks
|
||||
containerPort: 1080
|
||||
protocol: TCP
|
||||
env:
|
||||
- {name: PROXY_PORT, value: "3128"}
|
||||
- {name: SOCKS_PORT, value: "1080"}
|
||||
{{- with $.Values.config }}
|
||||
{{- with .log }}
|
||||
{{- $logOutputEnvName := "LOG_OUTPUT" }}
|
||||
{{- if eq .enabled false }}
|
||||
- {name: {{ $logOutputEnvName }}, value: "/dev/null"}
|
||||
{{- else if .output }}
|
||||
- {name: {{ $logOutputEnvName }}, value: "{{ .output }}"}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .auth.login }}
|
||||
{{- $authLoginEnvName := "PROXY_LOGIN" }}
|
||||
{{- if .plain }}
|
||||
- {name: {{ $authLoginEnvName }}, value: "{{ .plain }}"}
|
||||
{{- else if .fromSecret.enabled }}
|
||||
- name: {{ $authLoginEnvName }}
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: "{{ tpl (toYaml .fromSecret.secretName) $ }}"
|
||||
key: "{{ tpl (toYaml .fromSecret.secretKey) $ }}"
|
||||
{{- else if .fromConfigMap.enabled }}
|
||||
- name: {{ $authLoginEnvName }}
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: "{{ tpl (toYaml .fromConfigMap.configMapName) $ }}"
|
||||
key: "{{ tpl (toYaml .fromConfigMap.configMapKey) $ }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .auth.password }}
|
||||
{{- $authPasswordEnvName := "PROXY_PASSWORD" }}
|
||||
{{- if .plain }}
|
||||
- {name: {{ $authPasswordEnvName }}, value: "{{ .plain }}"}
|
||||
{{- else if .fromSecret.enabled }}
|
||||
- name: {{ $authPasswordEnvName }}
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: "{{ tpl (toYaml .fromSecret.secretName) $ }}"
|
||||
key: "{{ tpl (toYaml .fromSecret.secretKey) $ }}"
|
||||
{{- else if .fromConfigMap.enabled }}
|
||||
- name: {{ $authPasswordEnvName }}
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: "{{ tpl (toYaml .fromConfigMap.configMapName) $ }}"
|
||||
key: "{{ tpl (toYaml .fromConfigMap.configMapKey) $ }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .auth.extraAccounts }}
|
||||
{{- $extraAuthAccountsEnvName := "EXTRA_ACCOUNTS" }}
|
||||
{{- if .plain }}
|
||||
- name: {{ $extraAuthAccountsEnvName }}
|
||||
value: >-
|
||||
{{ .plain | toJson }}
|
||||
{{- else if .fromSecret.enabled }}
|
||||
- name: {{ $extraAuthAccountsEnvName }}
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: "{{ tpl (toYaml .fromSecret.secretName) $ }}"
|
||||
key: "{{ tpl (toYaml .fromSecret.secretKey) $ }}"
|
||||
{{- else if .fromConfigMap.enabled }}
|
||||
- name: {{ $extraAuthAccountsEnvName }}
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: "{{ tpl (toYaml .fromConfigMap.configMapName) $ }}"
|
||||
key: "{{ tpl (toYaml .fromConfigMap.configMapKey) $ }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if .dns.primaryResolver }}
|
||||
- {name: PRIMARY_RESOLVER, value: "{{ .dns.primaryResolver }}"}
|
||||
{{- end }}
|
||||
|
||||
{{- if .dns.secondaryResolver }}
|
||||
- {name: SECONDARY_RESOLVER, value: "{{ .dns.secondaryResolver }}"}
|
||||
{{- end }}
|
||||
|
||||
{{- if ne .limits.maxConnections nil }}
|
||||
- {name: MAX_CONNECTIONS, value: "{{ .limits.maxConnections }}"}
|
||||
{{- end }}
|
||||
|
||||
{{- if .extraConfig }}
|
||||
- name: EXTRA_CONFIG
|
||||
value: >-
|
||||
{{ .extraConfig }}
|
||||
{{- end }}
|
||||
{{- with $.Values.deployment.env }}
|
||||
{{- tpl (toYaml .) $ | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .args }}
|
||||
args:
|
||||
{{- tpl (toYaml .) $ | nindent 12 }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .probe }}
|
||||
livenessProbe:
|
||||
tcpSocket: {port: "{{ .port }}"}
|
||||
periodSeconds: {{ .interval }}
|
||||
initialDelaySeconds: {{ .initialDelay }}
|
||||
readinessProbe:
|
||||
tcpSocket: {port: "{{ .port }}"}
|
||||
periodSeconds: {{ .interval }}
|
||||
initialDelaySeconds: {{ .initialDelay }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .volumeMounts }}
|
||||
volumeMounts:
|
||||
{{- tpl (toYaml .) $ | nindent 12 }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .volumes }}
|
||||
volumes:
|
||||
{{- tpl (toYaml .) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- tpl (toYaml .) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .affinity }}
|
||||
affinity:
|
||||
{{- tpl (toYaml .) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .tolerations }}
|
||||
tolerations:
|
||||
{{- tpl (toYaml .) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
29
deployments/helm/templates/service.yaml
Normal file
29
deployments/helm/templates/service.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
{{- if .Values.service.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
||||
metadata:
|
||||
name: {{ include "proxy-3proxy.fullname" . }}
|
||||
namespace: {{ template "proxy-3proxy.namespace" . }}
|
||||
labels:
|
||||
{{- include "proxy-3proxy.commonLabels" . | nindent 4 }}
|
||||
|
||||
spec:
|
||||
{{- with .Values.service }}
|
||||
type: {{ .type }}
|
||||
{{- with .externalName }}
|
||||
externalName: {{ . }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ .ports.http }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
- name: http
|
||||
port: {{ .ports.socks }}
|
||||
targetPort: socks
|
||||
protocol: TCP
|
||||
selector:
|
||||
{{- include "proxy-3proxy.selectorLabels" $ | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user