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
4120e672
Commit
4120e672
authored
Oct 25, 2016
by
Vic Iglesias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add deployment, service and NOTES to create
parent
05c04bcc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
2 deletions
+116
-2
create.go
pkg/chartutil/create.go
+116
-2
No files found.
pkg/chartutil/create.go
View file @
4120e672
...
...
@@ -36,12 +36,29 @@ const (
ChartsDir
=
"charts"
// IgnorefileName is the name of the Helm ignore file.
IgnorefileName
=
".helmignore"
// DeploymentName is the name of the example deployment file.
DeploymentName
=
"deployment.yaml"
// ServiceName is the name of the example service file.
ServiceName
=
"service.yaml"
// NotesName is the name of the example NOTES.txt file.
NotesName
=
"NOTES.txt"
// HelpersName is the name of the example NOTES.txt file.
HelpersName
=
"_helpers.tpl"
)
const
defaultValues
=
`# Default values for %s.
# This is a YAML-formatted file.
# Declare name/value pairs to be passed into your templates.
# name: value
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: nginx
tag: stable
pullPolicy: IfNotPresent
service:
name: nginx
type: ClusterIP
externalPort: 80
internalPort: 80
`
const
defaultIgnore
=
`# Patterns to ignore when building packages.
...
...
@@ -67,6 +84,79 @@ const defaultIgnore = `# Patterns to ignore when building packages.
*.tmproj
`
const
defaultDeployment
=
`apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "fullname" . }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ template "fullname" . }}
spec:
containers:
- name: nginx
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.internalPort }}
`
const
defaultService
=
`apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app: {{ template "fullname" . }}
`
const
defaultNotes
=
`1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT/login
{{- else if contains "LoadBalancer" .Values.service.type }}
**** NOTE: It may take a few minutes for the LoadBalancer IP to be available. ****
**** You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}' ****
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.Master.ServicePort }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "component={{ template "fullname" . }}-master" -o jsonpath="{.items[0].metadata.name}")
echo http://127.0.0.1:{{ .Values.service.externalPort }}
kubectl port-forward $POD_NAME {{ .Values.service.externalPort }}:{{ .Values.service.externalPort }}
{{- end }}
`
const
defaultHelpers
=
`{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 24 -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 24 -}}
{{- end -}}
`
// Create creates a new chart in a directory.
//
// Inside of dir, this will create a directory based on the name of
...
...
@@ -120,5 +210,29 @@ func Create(chartfile *chart.Metadata, dir string) (string, error) {
return
cdir
,
err
}
}
// Write out deployment.yaml
val
=
[]
byte
(
defaultDeployment
)
if
err
:=
ioutil
.
WriteFile
(
filepath
.
Join
(
cdir
,
TemplatesDir
,
DeploymentName
),
val
,
0644
);
err
!=
nil
{
return
cdir
,
err
}
// Write out service.yaml
val
=
[]
byte
(
defaultService
)
if
err
:=
ioutil
.
WriteFile
(
filepath
.
Join
(
cdir
,
TemplatesDir
,
ServiceName
),
val
,
0644
);
err
!=
nil
{
return
cdir
,
err
}
// Write out NOTES.txt
val
=
[]
byte
(
defaultNotes
)
if
err
:=
ioutil
.
WriteFile
(
filepath
.
Join
(
cdir
,
TemplatesDir
,
NotesName
),
val
,
0644
);
err
!=
nil
{
return
cdir
,
err
}
// Write out _helpers.tpl
val
=
[]
byte
(
defaultHelpers
)
if
err
:=
ioutil
.
WriteFile
(
filepath
.
Join
(
cdir
,
TemplatesDir
,
HelpersName
),
val
,
0644
);
err
!=
nil
{
return
cdir
,
err
}
return
cdir
,
nil
}
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