Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Charts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
魏国强
Charts
Commits
6716877f
Commit
6716877f
authored
Oct 08, 2020
by
Waqar Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move spec to functions and better format the structure for workload
parent
e174f013
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
230 additions
and
135 deletions
+230
-135
charts/ix-chart/2009.0.1/templates/_containers.tpl
charts/ix-chart/2009.0.1/templates/_containers.tpl
+50
-0
charts/ix-chart/2009.0.1/templates/_helpers.tpl
charts/ix-chart/2009.0.1/templates/_helpers.tpl
+0
-47
charts/ix-chart/2009.0.1/templates/_volumes.tpl
charts/ix-chart/2009.0.1/templates/_volumes.tpl
+36
-0
charts/ix-chart/2009.0.1/templates/_workload.tpl
charts/ix-chart/2009.0.1/templates/_workload.tpl
+130
-0
charts/ix-chart/2009.0.1/templates/deployment.yaml
charts/ix-chart/2009.0.1/templates/deployment.yaml
+0
-88
charts/ix-chart/2009.0.1/templates/workload.yaml
charts/ix-chart/2009.0.1/templates/workload.yaml
+14
-0
No files found.
charts/ix-chart/2009.0.1/templates/_containers.tpl
0 → 100644
View file @
6716877f
{{
/*
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 }}
charts/ix-chart/2009.0.1/templates/_helpers.tpl
View file @
6716877f
...
...
@@ -61,50 +61,3 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{
{
/*
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" }}
{{- printf "%s" .Values.restartPolicy }}
{{- else }}
{{- printf "%s" .Values.jobRestartPolicy }}
{{- end }}
{{- end }}
charts/ix-chart/2009.0.1/templates/_volumes.tpl
0 → 100644
View file @
6716877f
{{
/*
Volumes
Configuration
*/
}}
{{- define "volumeConfiguration" }}
{{- if or .Values.persistentVolumeClaims .Values.hostPathVolumes }}
volumes:
{{- range $index, $hostPathConfiguration := .Values.hostPathVolumes }}
- name: ix-host-path-{{ $.Release.Name }}-{{ $index }}
hostPath:
path: {{ $hostPathConfiguration.hostPath }}
{{- end }}
{{- range $index, $claim := .Values.persistentVolumeClaims }}
- name: ix-pv-{{ $.Release.Name }}-{{ $index }}
persistentVolumeClaim:
claimName: ix-pv-claim-{{ $.Release.Name }}-{{ $index }}
{{- end }}
{{- end }}
{{- end }}
{
{
/*
Volume
Mounts
Configuration
*/
}
}
{{- define "volumeMountsConfiguration" }}
{{- if or .Values.hostPathVolumes .Values.persistentVolumeClaims }}
volumeMounts:
{{- range $index, $hostPathConfiguration := .Values.hostPathVolumes }}
- mountPath: {{ $hostPathConfiguration.mountPath }}
name: ix-host-path-{{ $.Release.Name }}-{{ $index }}
readOnly: {{ $hostPathConfiguration.readOnly }}
{{- end }}
{{- range $index, $claim := .Values.persistentVolumeClaims }}
- mountPath: {{ $claim.mountPath }}
name: ix-pv-{{ $.Release.Name }}-{{ $index }}
{{- end }}
{{- end }}
{{- end }}
charts/ix-chart/2009.0.1/templates/_workload.tpl
0 → 100644
View file @
6716877f
{{
/*
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" }}
{{- printf "%s" .Values.restartPolicy }}
{{- else }}
{{- printf "%s" .Values.jobRestartPolicy }}
{{- end }}
{{- end }}
{
{
/*
Pod
specification
*/
}
}
{{- define "podSepc" }}
restartPolicy: {{ template "restartPolicy" . }}
containers:
- name: {{ .Chart.Name }}
{{- include "volumeMountsConfiguration" . | indent 2}}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
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 "volumeConfiguration" . }}
{{- end }}
{
{
/*
Annotations
for
workload
*/
}
}
{{- define "workloadAnnotations" }}
rollme: {{ randAlphaNum 5 | quote }}
{{- if .Values.ixExternalInterfacesConfigurationNames }}
k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurationNames }}
{{- end }}
{{- end }}
{
{
/*
Deployment
Spec
*/
}
}
{{- define "deploymentSpec" }}
strategy:
type: {{ .Values.updateStrategy }}
selector:
matchLabels:
{{- include "ix-chart.selectorLabels" . | nindent 2 }}
template:
metadata:
labels:
{{- include "ix-chart.selectorLabels" . | nindent 6 }}
annotations:
{{- include "workloadAnnotations" . | nindent 6 }}
spec:
{{- include "podSepc" . | indent 4 }}
{{- end }}
{
{
/*
Job
Spec
Common
*/
}
}
{{- define "jobSpecCommon" }}
metadata:
labels:
{{- include "ix-chart.selectorLabels" . | nindent 4 }}
annotations:
{{- include "workloadAnnotations" . | nindent 4 }}
spec:
{{- include "podSepc" . | indent 2 }}
{{- end }}
{
{
/*
Job
Spec
*/
}
}
{{- define "jobSpec" }}
template:
{{ include "jobSpecCommon" . | nindent 2 }}
{{- end }}
{
{
/*
CronJob
Spec
*/
}
}
{{- define "cronJobSpec" }}
schedule: {{ .Values.cronSchedule | quote }}
jobTemplate:
spec:
{{ include "jobSpec" . | nindent 4 }}
{{- end }}
charts/ix-chart/2009.0.1/templates/deployment.yaml
deleted
100644 → 0
View file @
e174f013
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"
}}
strategy
:
type
:
{{
.Values.updateStrategy
}}
selector
:
matchLabels
:
{{
- include "ix-chart.selectorLabels" . | nindent 6
}}
{{
- end
}}
{{
- if ne (include "workloadIsCronJob" .) "true"
}}
template
:
{{
- else
}}
schedule
:
{{
.Values.cronSchedule | quote
}}
jobTemplate
:
{{
- end
}}
metadata
:
labels
:
{{
- include "ix-chart.selectorLabels" . | nindent 8
}}
annotations
:
rollme
:
{{
randAlphaNum 5 | quote
}}
{{
- if .Values.ixExternalInterfacesConfigurationNames
}}
k8s.v1.cni.cncf.io/networks
:
{{
join "
,
"
.Values.ixExternalInterfacesConfigurationNames
}}
{{-
end
}}
spec:
restartPolicy:
{{
template
"
restartPolicy" .
}}
containers
:
-
name
:
{{
.Chart.Name
}}
{{
- if or .Values.hostPathVolumes .Values.persistentVolumeClaims
}}
volumeMounts
:
{{
- range $index
,
$hostPathConfiguration
:
= .Values.hostPathVolumes
}}
-
mountPath
:
{{
$hostPathConfiguration.mountPath
}}
name
:
ix-host-path-{{ $.Release.Name }}-{{ $index }}
readOnly
:
{{
$hostPathConfiguration.readOnly
}}
{{
- end
}}
{{
- range $index
,
$claim
:
= .Values.persistentVolumeClaims
}}
-
mountPath
:
{{
$claim.mountPath
}}
name
:
ix-pv-{{ $.Release.Name }}-{{ $index }}
{{
- end
}}
{{
- end
}}
securityContext
:
{{
- toYaml .Values.securityContext | nindent 12
}}
image
:
"
{{
.Values.image.repository
}}:{{
.Values.image.tag
|
default
"latest" }}"
imagePullPolicy
:
{{
.Values.image.pullPolicy
}}
{{
- if .Values.containerCommand
}}
command
:
{{
- range .Values.containerCommand
}}
-
{{
. | quote
}}
{{
- end
}}
{{
- end
}}
{{
- if .Values.containerArgs
}}
args
:
{{
- range .Values.containerArgs
}}
-
{{
. | quote
}}
{{
- end
}}
{{
- end
}}
{{
- if .Values.containerEnvironmentVariables
}}
env
:
{{
- range .Values.containerEnvironmentVariables
}}
-
name
:
{{
.name | quote
}}
value
:
{{
.value | quote
}}
{{
- end
}}
{{
- end
}}
{{
- if .Values.livenessProbe
}}
livenessProbe
:
exec
:
command
:
{{
toYaml .Values.livenessProbe.command | indent 16
}}
initialDelaySeconds
:
{{
.Values.livenessProbe.initialDelaySeconds
}}
periodSeconds
:
{{
.Values.periodSeconds
}}
{{
- end
}}
{{
- if or .Values.persistentVolumeClaims .Values.hostPathVolumes
}}
volumes
:
{{
- range $index
,
$hostPathConfiguration
:
= .Values.hostPathVolumes
}}
-
name
:
ix-host-path-{{ $.Release.Name }}-{{ $index }}
hostPath
:
path
:
{{
$hostPathConfiguration.hostPath
}}
{{
- end
}}
{{
- range $index
,
$claim
:
= .Values.persistentVolumeClaims
}}
-
name
:
ix-pv-{{ $.Release.Name }}-{{ $index }}
persistentVolumeClaim
:
claimName
:
ix-pv-claim-{{ $.Release.Name }}-{{ $index }}
{{
- end
}}
{{
- end
}}
charts/ix-chart/2009.0.1/templates/workload.yaml
0 → 100644
View file @
6716877f
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 ne (include "workloadIsCronJob" .) "true"
}}
{{
include "cronJobSpec" . | nindent 2
}}
{{
- else
}}
}
{{
include "jobSpec" . | nindent 2
}}
{{
- end
}}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment