mirror of
https://github.com/truenas/charts.git
synced 2026-11-26 07:25:00 +00:00
Add run As user in ix chart
This commit is contained in:
1 parent
3432f36f77
commit
f8a249c2d4
36 files changed
+52
-2
No files matched your search
@@ -0,0 +1,2 @@
|
||||
1. Get the application URL by running these commands:
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
{{/*
|
||||
Container Command
|
||||
*/}}
|
||||
{{- define "containerCommand" }}
|
||||
{{- if .Values.containerCommand }}
|
||||
command:
|
||||
{{- range .Values.containerCommand }}
|
||||
- {{ . | quote}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Container Args
|
||||
*/}}
|
||||
{{- define "containerArgs" }}
|
||||
{{- if .Values.containerArgs }}
|
||||
args:
|
||||
{{- range .Values.containerArgs }}
|
||||
- {{ . | quote}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Container Environment Variables
|
||||
*/}}
|
||||
{{- define "containerEnvVariables" }}
|
||||
{{- if .Values.containerEnvironmentVariables }}
|
||||
env:
|
||||
{{- range .Values.containerEnvironmentVariables }}
|
||||
- name: {{ .name | quote }}
|
||||
value: {{ .value | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Container Liveness Probe
|
||||
*/}}
|
||||
{{- define "containerLivenssProbe" }}
|
||||
{{- if .Values.livenessProbe }}
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
{{ toYaml .Values.livenessProbe.command | indent 16 }}
|
||||
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.periodSeconds }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Container Ports
|
||||
*/}}
|
||||
{{- define "containerPorts" }}
|
||||
{{- if or .Values.portForwardingList .Values.hostPortsList }}
|
||||
ports:
|
||||
{{- range $index, $config := .Values.portForwardingList }}
|
||||
- containerPort: {{ $config.containerPort }}
|
||||
{{- end }}
|
||||
{{- range $index, $config := .Values.hostPortsList }}
|
||||
- containerPort: {{ $config.containerPort }}
|
||||
hostPort: {{ $config.hostPort }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Container Resource Configuration
|
||||
*/}}
|
||||
{{- define "containerResourceConfiguration" }}
|
||||
{{- if .Values.gpuConfiguration }}
|
||||
resources:
|
||||
limits:
|
||||
{{- toYaml .Values.gpuConfiguration | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,71 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "ix-chart.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 "ix-chart.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 "ix-chart.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "ix-chart.labels" -}}
|
||||
helm.sh/chart: {{ include "ix-chart.chart" . }}
|
||||
{{ include "ix-chart.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "ix-chart.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "ix-chart.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "ix-chart.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "ix-chart.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Convert cron schema object to cron format
|
||||
*/}}
|
||||
{{- define "cronExpression" }}
|
||||
{{- printf "%s %s %s %s %s " .minute .hour .dom .month .dow }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,23 @@
|
||||
{{/*
|
||||
DNS Configuration
|
||||
*/}}
|
||||
{{- define "dnsConfiguration" }}
|
||||
dnsPolicy: {{ .Values.dnsPolicy }}
|
||||
{{- if .Values.dnsConfig }}
|
||||
dnsConfig:
|
||||
{{- toYaml .Values.dnsConfig | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Get configuration for host network
|
||||
*/}}
|
||||
{{- define "hostNetworkingConfiguration" -}}
|
||||
{{- $host := default false .Values.hostNetwork -}}
|
||||
{{- if or .Values.externalInterfaces (eq $host false) -}}
|
||||
{{- print "false" -}}
|
||||
{{- else -}}
|
||||
{{- print "true" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,51 @@
|
||||
{{/*
|
||||
Volumes Configuration
|
||||
*/}}
|
||||
{{- define "volumeConfiguration" }}
|
||||
{{- if or .Values.ixVolumes .Values.hostPathVolumes .Values.emptyDirVolumes }}
|
||||
volumes:
|
||||
{{ $host_p := list }}
|
||||
{{- range $index, $hostPathConfiguration := .Values.hostPathVolumes }}
|
||||
- name: ix-host-path-{{ $.Release.Name }}-{{ $index }}
|
||||
hostPath:
|
||||
path: {{ $hostPathConfiguration.hostPath }}
|
||||
{{ $host_p = mustAppend $host_p $hostPathConfiguration.hostPath }}
|
||||
{{- end }}
|
||||
{{- range $index, $hostPathConfiguration := .Values.ixVolumes }}
|
||||
{{ $dsName := base $hostPathConfiguration.hostPath }}
|
||||
- name: ix-host-volume-{{ $.Release.Name }}-{{ $dsName }}
|
||||
hostPath:
|
||||
path: {{ $hostPathConfiguration.hostPath }}
|
||||
{{ $host_p = mustAppend $host_p $hostPathConfiguration.hostPath }}
|
||||
{{- end }}
|
||||
{{ include "common.storage.hostPathsValidation" $host_p }}
|
||||
{{- range $index, $emptyDirConfiguration := .Values.emptyDirVolumes }}
|
||||
- name: ix-emptydir-volume-{{ $.Release.Name }}-{{ $index }}
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Volume Mounts Configuration
|
||||
*/}}
|
||||
{{- define "volumeMountsConfiguration" }}
|
||||
{{- if or .Values.hostPathVolumes .Values.ixVolumes .Values.emptyDirVolumes }}
|
||||
volumeMounts:
|
||||
{{- range $index, $hostPathConfiguration := .Values.hostPathVolumes }}
|
||||
- mountPath: {{ $hostPathConfiguration.mountPath }}
|
||||
name: ix-host-path-{{ $.Release.Name }}-{{ $index }}
|
||||
readOnly: {{ $hostPathConfiguration.readOnly }}
|
||||
{{- end }}
|
||||
{{- range $index, $hostPathConfiguration := .Values.volumes }}
|
||||
- mountPath: {{ $hostPathConfiguration.mountPath }}
|
||||
name: ix-host-volume-{{ $.Release.Name }}-{{ $hostPathConfiguration.datasetName }}
|
||||
{{- end }}
|
||||
{{- range $index, $emptyDirConfiguration := .Values.emptyDirVolumes }}
|
||||
- mountPath: {{ $emptyDirConfiguration.mountPath }}
|
||||
name: ix-emptydir-volume-{{ $.Release.Name }}-{{ $index }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,154 @@
|
||||
{{/*
|
||||
Check if workload type is a deployment
|
||||
*/}}
|
||||
{{- define "workloadIsDeployment" }}
|
||||
{{- if eq .Values.workloadType "Deployment" }}
|
||||
{{- true -}}
|
||||
{{- else }}
|
||||
{{- false -}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Check if workload type is a cronjob
|
||||
*/}}
|
||||
{{- define "workloadIsCronJob" }}
|
||||
{{- if eq .Values.workloadType "CronJob" }}
|
||||
{{- true -}}
|
||||
{{- else }}
|
||||
{{- false -}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Get API Version based on workload type
|
||||
*/}}
|
||||
{{- define "apiVersion" -}}
|
||||
{{- if eq (include "workloadIsDeployment" .) "true" }}
|
||||
{{- printf "apps/v1" }}
|
||||
{{- else if eq (include "workloadIsCronJob" .) "true" }}
|
||||
{{- printf "batch/v1beta1" }}
|
||||
{{- else }}
|
||||
{{- printf "batch/v1" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Get Restart policy based on workload type
|
||||
*/}}
|
||||
{{- define "restartPolicy" -}}
|
||||
{{- if eq (include "workloadIsDeployment" .) "true" }}
|
||||
{{- print "Always" }}
|
||||
{{- else }}
|
||||
{{- printf "%s" .Values.jobRestartPolicy }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Pod specification
|
||||
*/}}
|
||||
{{- define "podSepc" }}
|
||||
restartPolicy: {{ template "restartPolicy" . }}
|
||||
hostNetwork: {{ template "hostNetworkingConfiguration" . }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
{{ include "common.resources.limitation" . | nindent 2 }}
|
||||
{{- include "volumeMountsConfiguration" . | indent 2}}
|
||||
tty: {{ .Values.tty }}
|
||||
stdin: {{ .Values.stdin }}
|
||||
securityContext:
|
||||
privileged: {{ .Values.securityContext.privileged }}
|
||||
{{ if .Values.securityContext.enableRunAsUser }}
|
||||
runAsUser: {{ .Values.securityContext.runAsUser }}
|
||||
runAsGroup: {{ .Values.securityContext.runAsGroup }}
|
||||
{{ end }}
|
||||
{{ if .Values.securityContext.capabilities }}
|
||||
capabilities:
|
||||
add: {{ toYaml .Values.securityContext.capabilities | nindent 8 }}
|
||||
{{ end }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
{{- include "containerCommand" . | indent 2 }}
|
||||
{{- include "containerArgs" . | indent 2 }}
|
||||
{{- include "containerEnvVariables" . | indent 2 }}
|
||||
{{- include "containerLivenssProbe" . | indent 2 }}
|
||||
{{- include "containerPorts" . | indent 2 }}
|
||||
{{- include "containerResourceConfiguration" . | indent 2 }}
|
||||
{{- include "volumeConfiguration" . }}
|
||||
{{- include "dnsConfiguration" . }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Annotations for workload
|
||||
*/}}
|
||||
{{- define "workloadAnnotations" }}
|
||||
rollme: {{ randAlphaNum 5 | quote }}
|
||||
{{- if .Values.ixExternalInterfacesConfigurationNames }}
|
||||
k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurationNames }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Metadata for workload
|
||||
*/}}
|
||||
{{- define "commonMetadataWorkload" }}
|
||||
labels:
|
||||
{{- include "ix-chart.selectorLabels" . | nindent 2 }}
|
||||
annotations:
|
||||
{{- include "workloadAnnotations" . | nindent 2 }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Deployment Spec
|
||||
*/}}
|
||||
{{- define "deploymentSpec" }}
|
||||
strategy:
|
||||
{{- if and (eq .Values.updateStrategy "RollingUpdate") .Values.hostPortsList }}
|
||||
{{- fail "RollingUpdate is not allowed when host ports are specified" }}
|
||||
{{- else if and (eq .Values.updateStrategy "RollingUpdate") .Values.hostNetwork }}
|
||||
{{- fail "RollingUpdate is not allowed when host network is enabled" }}
|
||||
{{- end }}
|
||||
type: {{ .Values.updateStrategy }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "ix-chart.selectorLabels" . | nindent 4 }}
|
||||
template:
|
||||
metadata:
|
||||
{{ include "commonMetadataWorkload" . | nindent 4 }}
|
||||
spec:
|
||||
{{- include "podSepc" . | indent 4 }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Job Spec Common
|
||||
*/}}
|
||||
{{- define "jobSpecCommon" }}
|
||||
metadata:
|
||||
{{ include "commonMetadataWorkload" . | nindent 4 }}
|
||||
spec:
|
||||
{{- include "podSepc" . | indent 2 }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{/*
|
||||
Job Spec
|
||||
*/}}
|
||||
{{- define "jobSpec" }}
|
||||
template:
|
||||
{{ include "jobSpecCommon" . | nindent 2 }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
CronJob Spec
|
||||
*/}}
|
||||
{{- define "cronJobSpec" }}
|
||||
schedule: {{ include "cronExpression" .Values.cronSchedule | quote }}
|
||||
jobTemplate:
|
||||
spec:
|
||||
{{ include "jobSpec" . | nindent 4 }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,9 @@
|
||||
{{- range $index, $iface := .Values.ixExternalInterfacesConfiguration }}
|
||||
---
|
||||
apiVersion: "k8s.cni.cncf.io/v1"
|
||||
kind: NetworkAttachmentDefinition
|
||||
metadata:
|
||||
name: ix-{{ $.Release.Name }}-{{ $index }}
|
||||
spec:
|
||||
config: '{{ $iface }}'
|
||||
{{- end }}
|
||||
@@ -0,0 +1,20 @@
|
||||
{{- if and (.Values.portForwardingList) (eq (include "hostNetworkingConfiguration" .) "false") }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "ix-chart.fullname" . }}
|
||||
labels:
|
||||
{{- include "ix-chart.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
{{- range $index, $config := .Values.portForwardingList }}
|
||||
- port: {{ $config.containerPort }}
|
||||
targetPort: {{ $config.containerPort }}
|
||||
protocol: {{ $config.protocol }}
|
||||
nodePort: {{ $config.nodePort }}
|
||||
name: ix-{{ $.Release.Name }}-{{ $config.nodePort }}-{{ $index }}
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- include "ix-chart.selectorLabels" . | nindent 4 }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{ .Release.Name }}-deployment-test"
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .Release.Name }}-deployment-test
|
||||
image: "busybox"
|
||||
command:
|
||||
- nc
|
||||
args:
|
||||
- "-vz"
|
||||
- "{{ include "ix-chart.fullname" . }}"
|
||||
- "80"
|
||||
restartPolicy: Never
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: {{ template "apiVersion" . }}
|
||||
kind: {{ .Values.workloadType }}
|
||||
metadata:
|
||||
name: {{ include "ix-chart.fullname" . }}
|
||||
labels:
|
||||
{{- include "ix-chart.labels" . | nindent 4 }}
|
||||
spec:
|
||||
{{- if eq (include "workloadIsDeployment" .) "true" }}
|
||||
{{ include "deploymentSpec" . | nindent 2 }}
|
||||
{{- else if eq (include "workloadIsCronJob" .) "true" }}
|
||||
{{ include "cronJobSpec" . | nindent 2 }}
|
||||
{{- else }}
|
||||
{{ include "jobSpec" . | nindent 2 }}
|
||||
{{- end }}
|
||||
Reference in new issue
Block a user