Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
6c88a429
Unverified
Commit
6c88a429
authored
Jun 17, 2019
by
Matt Farina
Committed by
GitHub
Jun 17, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5890 from naseemkullah/sa
[helm create] Add service account to templates
parents
3630a532
ab8585fa
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
create_test.go
cmd/helm/create_test.go
+1
-1
create.go
pkg/chartutil/create.go
+35
-0
No files found.
cmd/helm/create_test.go
View file @
6c88a429
...
...
@@ -143,7 +143,7 @@ func TestCreateStarterCmd(t *testing.T) {
t
.
Errorf
(
"Wrong API version: %q"
,
c
.
Metadata
.
ApiVersion
)
}
expectedTemplateCount
:=
7
expectedTemplateCount
:=
8
if
l
:=
len
(
c
.
Templates
);
l
!=
expectedTemplateCount
{
t
.
Errorf
(
"Expected %d templates, got %d"
,
expectedTemplateCount
,
l
)
}
...
...
pkg/chartutil/create.go
View file @
6c88a429
...
...
@@ -42,6 +42,8 @@ const (
DeploymentName
=
"deployment.yaml"
// ServiceName is the name of the example service file.
ServiceName
=
"service.yaml"
// ServiceAccountName is the name of the example serviceaccount file.
ServiceAccountName
=
"serviceaccount.yaml"
// NotesName is the name of the example NOTES.txt file.
NotesName
=
"NOTES.txt"
// HelpersName is the name of the example helpers file.
...
...
@@ -67,6 +69,13 @@ imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:
service:
type: ClusterIP
port: 80
...
...
@@ -189,6 +198,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "<CHARTNAME>.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
...
...
@@ -238,6 +248,15 @@ spec:
app.kubernetes.io/name: {{ include "<CHARTNAME>.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
`
const
defaultServiceAccount
=
`{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "<CHARTNAME>.serviceAccountName" . }}
labels:
{{ include "<CHARTNAME>.labels" . | indent 4 }}
{{- end -}}
`
const
defaultNotes
=
`1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
...
...
@@ -307,6 +326,17 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "<CHARTNAME>.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "<CHARTNAME>.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
`
const
defaultTestConnection
=
`apiVersion: v1
...
...
@@ -425,6 +455,11 @@ func Create(chartfile *chart.Metadata, dir string) (string, error) {
path
:
filepath
.
Join
(
cdir
,
TemplatesDir
,
ServiceName
),
content
:
Transform
(
defaultService
,
"<CHARTNAME>"
,
chartfile
.
Name
),
},
{
// serviceaccount.yaml
path
:
filepath
.
Join
(
cdir
,
TemplatesDir
,
ServiceAccountName
),
content
:
Transform
(
defaultServiceAccount
,
"<CHARTNAME>"
,
chartfile
.
Name
),
},
{
// NOTES.txt
path
:
filepath
.
Join
(
cdir
,
TemplatesDir
,
NotesName
),
...
...
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