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
4f2ef369
Commit
4f2ef369
authored
Jan 28, 2021
by
Waqar Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add common implementation of services
parent
0261fef3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
library/common/templates/classes/_service.tpl
library/common/templates/classes/_service.tpl
+41
-0
library/common/templates/classes/_service_ports.tpl
library/common/templates/classes/_service_ports.tpl
+19
-0
No files found.
library/common/templates/classes/_service.tpl
0 → 100644
View file @
4f2ef369
{{
/*
This
template
serves
as
a
blueprint
for
all
Service
objects
that
are
created
within
the
common
library
.
*/
}}
{{- define "common.classes.service" -}}
{{- $values := . -}}
{{- $serviceName := include "common.names.fullname" . -}}
{{- if hasKey $values "nameSuffix" -}}
{{- $serviceName = printf "%v-%v" $serviceName $values.nameSuffix -}}
{{ end -}}
{{- $svcType := $values.type | default "" -}}
apiVersion: v1
kind: Service
metadata:
name: {{ $serviceName }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- if $values.labels }}
{{ toYaml $values.labels | nindent 4 }}
{{- end }}
{{- if $values.annotations }}
{{- with $values.annotations }}
annotations:
{{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
spec:
{{- if (or (eq $svcType "ClusterIP") (empty $svcType)) }}
type: ClusterIP
{{- if $values.clusterIP }}
clusterIP: {{ $values.clusterIP }}
{
{
end
}
}
{{- else if eq $svcType "NodePort" }}
type: {{ $svcType }}
{{- else }}
{{- fail "Only ClusterIP and NodePort services are supported in common chart" }}
{{- end }}
{{- include "common.classes.service.ports" (dict "svcType" $svcType "values" $values ) | trim | nindent 2 }}
selector:
{{- include "common.labels.selectorLabels" . | nindent 4 }}
{{- end }}
library/common/templates/classes/_service_ports.tpl
0 → 100644
View file @
4f2ef369
{{
/*
Render
all
the
ports
and
additionalPorts
for
a
Service
object
.
*/
}}
{{- define "common.classes.service.ports" -}}
{{- $values := .values -}}
{{- $ports := $values.ports -}}
{{- if $ports -}}
ports:
{{- range $_ := $ports }}
- port: {{ .port }}
targetPort: {{ .targetPort | default "http" }}
protocol: {{ .protocol | default "TCP" }}
name: {{ .name | default "http" }}
{{- if (and (eq $.svcType "NodePort") (not (empty .nodePort))) }}
nodePort: {{ .nodePort }}
{{ end }}
{{- end -}}
{{- end -}}
{{- 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