@ -52,29 +52,31 @@ const (
const defaultValues = ` # Default values for % s .
# This is a YAML - formatted file .
# Declare variables to be passed into your templates .
replicaCount : 1
image :
repository : nginx
tag : stable
pullPolicy : IfNotPresent
service :
name : nginx
type : ClusterIP
externalP ort: 80
internalPort : 80
p ort: 80
ingress :
enabled : false
# Used to create an Ingress record .
hosts :
- chart - example . local
annotations :
annotations : { }
# kubernetes . io / ingress . class : nginx
# kubernetes . io / tls - acme : "true"
tls :
# Secrets must be manually created in the namespace .
path : /
hosts :
- chart - example . local
tls : [ ]
# - secretName : chart - example - tls
# hosts :
# - chart - example . local
resources : { }
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user . This also increases chances charts run on environments with little
@ -86,6 +88,12 @@ resources: {}
# requests :
# cpu : 100 m
# memory : 128 Mi
nodeSelector : { }
tolerations : [ ]
affinity : { }
`
const defaultIgnore = ` # Patterns to ignore when building packages .
@ -112,50 +120,61 @@ const defaultIgnore = `# Patterns to ignore when building packages.
`
const defaultIngress = ` { { - if . Values . ingress . enabled - } }
{ { - $ serviceName := include "<CHARTNAME>.fullname" . - } }
{ { - $ servicePort := . Values . service . externalPort - } }
{ { - $ fullName := include "<CHARTNAME>.fullname" . - } }
{ { - $ servicePort := . Values . service . port - } }
{ { - $ ingressPath := . Values . ingress . path - } }
apiVersion : extensions / v1beta1
kind : Ingress
metadata :
name : { { template "<CHARTNAME>.fullname" . } }
name : { { $ fullName } }
labels :
app : { { template "<CHARTNAME>.name" . } }
chart : { { . Chart . Name } } - { { . Chart . Version | replace "+" "_" } }
chart : { { template "<CHARTNAME>.chart" . } }
release : { { . Release . Name } }
heritage : { { . Release . Service } }
{ { - with . Values . ingress . annotations } }
annotations :
{ { - range $ key , $ value := . Values . ingress . annotations } }
{ { $ key } } : { { $ value | quote } }
{ { toYaml . | indent 4 } }
{ { - end } }
spec :
{ { - if . Values . ingress . tls } }
tls :
{ { - range . Values . ingress . tls } }
- hosts :
{ { - range . hosts } }
- { { . } }
{ { - end } }
secretName : { { . secretName } }
{ { - end } }
{ { - end } }
rules :
{ { - range $ host := . Values . ingress . hosts } }
- host : { { $ host } }
{ { - range . Values . ingress . hosts } }
- host : { { . } }
http :
paths :
- path : /
- path : { { $ ingressPath } }
backend :
serviceName : { { $ serviceName } }
servicePort : { { $ servicePort } }
{ { - end - } }
{ { - if . Values . ingress . tls } }
tls :
{ { toYaml . Values . ingress . tls | indent 4 } }
{ { - end - } }
{ { - end - } }
serviceName : { { $ fullName } }
servicePort : http
{ { - end } }
{ { - end } }
`
const defaultDeployment = ` apiVersion : extensions/ v1beta1
const defaultDeployment = ` apiVersion : apps / v1beta2
kind : Deployment
metadata :
name : { { template "<CHARTNAME>.fullname" . } }
labels :
app : { { template "<CHARTNAME>.name" . } }
chart : { { . Chart . Name } } - { { . Chart . Version | replace "+" "_" } }
chart : { { template "<CHARTNAME>.chart" . } }
release : { { . Release . Name } }
heritage : { { . Release . Service } }
spec :
replicas : { { . Values . replicaCount } }
selector :
matchLabels :
app : { { template "<CHARTNAME>.name" . } }
release : { { . Release . Name } }
template :
metadata :
labels :
@ -167,20 +186,30 @@ spec:
image : "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy : { { . Values . image . pullPolicy } }
ports :
- containerPort : { { . Values . service . internalPort } }
- name : http
containerPort : 80
protocol : TCP
livenessProbe :
httpGet :
path : /
port : { { . Values . service . internalPort } }
port : http
readinessProbe :
httpGet :
path : /
port : { { . Values . service . internalPort } }
port : http
resources :
{ { toYaml . Values . resources | indent 12 } }
{ { - if . Values . nodeSelector } }
{ { - with . Values . nodeSelector } }
nodeSelector :
{ { toYaml . Values . nodeSelector | indent 8 } }
{ { toYaml . | indent 8 } }
{ { - end } }
{ { - with . Values . affinity } }
affinity :
{ { toYaml . | indent 8 } }
{ { - end } }
{ { - with . Values . tolerations } }
tolerations :
{ { toYaml . | indent 8 } }
{ { - end } }
`
@ -190,16 +219,16 @@ metadata:
name : { { template "<CHARTNAME>.fullname" . } }
labels :
app : { { template "<CHARTNAME>.name" . } }
chart : { { . Chart . Name } } - { { . Chart . Version | replace "+" "_" } }
chart : { { template "<CHARTNAME>.chart" . } }
release : { { . Release . Name } }
heritage : { { . Release . Service } }
spec :
type : { { . Values . service . type } }
ports :
- port : { { . Values . service . externalP ort } }
targetPort : { { . Values . service . internalPort } }
- port : { { . Values . service . p ort } }
targetPort : http
protocol : TCP
name : { { . Values . service . name } }
name : http
selector :
app : { { template "<CHARTNAME>.name" . } }
release : { { . Release . Name } }
@ -208,7 +237,7 @@ spec:
const defaultNotes = ` 1. Get the application URL by running these commands :
{ { - if . Values . ingress . enabled } }
{ { - range . Values . ingress . hosts } }
http ://{{ . }}
http {{ if $ . Values . ingress . tls } } s { { end } } ://{{ . }}{{ $.Values.ingress.path }}
{ { - end } }
{ { - else if contains "NodePort" . Values . service . type } }
export NODE_PORT = $ ( kubectl get -- namespace { { . Release . Namespace } } - o jsonpath = "{.spec.ports[0].nodePort}" services { { template "<CHARTNAME>.fullname" . } } )
@ -218,11 +247,11 @@ const defaultNotes = `1. Get the application URL by running these commands:
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 "<CHARTNAME>.fullname" . } } '
export SERVICE_IP = $ ( kubectl get svc -- namespace { { . Release . Namespace } } { { template "<CHARTNAME>.fullname" . } } - o jsonpath = ' { . status . loadBalancer . ingress [ 0 ] . ip } ' )
echo http : //$SERVICE_IP:{{ .Values.service. externalP ort }}
echo http : //$SERVICE_IP:{{ .Values.service. p ort }}
{ { - else if contains "ClusterIP" . Values . service . type } }
export POD_NAME = $ ( kubectl get pods -- namespace { { . Release . Namespace } } - l "app={{ template " < CHARTNAME > . name " . }},release={{ .Release.Name }}" - o jsonpath = "{.items[0].metadata.name}" )
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port - forward $ POD_NAME 8080 : { { . Values . service . internalPort } }
kubectl port - forward $ POD_NAME 8080 : 80
{ { - end } }
`
@ -240,6 +269,9 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
If release name contains chart name it will be used as a full name .
* / } }
{ { - define "<CHARTNAME>.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 "-" - } }
@ -247,6 +279,14 @@ If release name contains chart name it will be used as a full name.
{ { - printf "%s-%s" . Release . Name $ name | trunc 63 | trimSuffix "-" - } }
{ { - end - } }
{ { - end - } }
{ { - end - } }
{ { / *
Create chart name and version as used by the chart label .
* / } }
{ { - define "<CHARTNAME>.chart" - } }
{ { - printf "%s-%s" . Chart . Name . Chart . Version | replace "+" "_" | trunc 63 | trimSuffix "-" - } }
{ { - end - } }
`
// CreateFrom creates a new chart, but scaffolds it from the src chart.