Improve 'helm create'

reviewable/pr2584/r1
Reinhard Nägele 7 years ago
parent 72cd1464d2
commit 51923e54b1

@ -74,13 +74,13 @@ ingress:
# - secretName: chart-example-tls # - secretName: chart-example-tls
# hosts: # hosts:
# - chart-example.local # - chart-example.local
resources: resources: {}
limits: # limits:
cpu: 100m # cpu: 100m
memory: 128Mi # memory: 128Mi
requests: #requests:
cpu: 100m # cpu: 100m
memory: 128Mi # memory: 128Mi
` `
@ -115,10 +115,10 @@ kind: Ingress
metadata: metadata:
name: {{ template "fullname" . }} name: {{ template "fullname" . }}
labels: labels:
app: {{ template "fullname" . }} app: {{ template "name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: "{{ .Release.Name }}" release: {{ .Release.Name }}
heritage: "{{ .Release.Service }}" heritage: {{ .Release.Service }}
annotations: annotations:
{{- range $key, $value := .Values.ingress.annotations }} {{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }} {{ $key }}: {{ $value | quote }}
@ -146,30 +146,38 @@ kind: Deployment
metadata: metadata:
name: {{ template "fullname" . }} name: {{ template "fullname" . }}
labels: labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec: spec:
replicas: {{ .Values.replicaCount }} replicas: {{ .Values.replicaCount }}
template: template:
metadata: metadata:
labels: labels:
app: {{ template "fullname" . }} app: {{ template "name" . }}
release: {{ .Release.Name }}
spec: spec:
containers: containers:
- name: {{ .Chart.Name }} - name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
ports: ports:
- containerPort: {{ .Values.service.internalPort }} - containerPort: {{ .Values.service.internalPort }}
livenessProbe: livenessProbe:
httpGet: httpGet:
path: / path: /
port: {{ .Values.service.internalPort }} port: {{ .Values.service.internalPort }}
readinessProbe: readinessProbe:
httpGet: httpGet:
path: / path: /
port: {{ .Values.service.internalPort }} port: {{ .Values.service.internalPort }}
resources: resources:
{{ toYaml .Values.resources | indent 10 }} {{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
` `
const defaultService = `apiVersion: v1 const defaultService = `apiVersion: v1
@ -177,16 +185,20 @@ kind: Service
metadata: metadata:
name: {{ template "fullname" . }} name: {{ template "fullname" . }}
labels: labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec: spec:
type: {{ .Values.service.type }} type: {{ .Values.service.type }}
ports: ports:
- port: {{ .Values.service.externalPort }} - port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }} targetPort: {{ .Values.service.internalPort }}
protocol: TCP protocol: TCP
name: {{ .Values.service.name }} name: {{ .Values.service.name }}
selector: selector:
app: {{ template "fullname" . }} app: {{ template "name" . }}
release: {{ .Release.Name }}
` `
const defaultNotes = `1. Get the application URL by running these commands: const defaultNotes = `1. Get the application URL by running these commands:
@ -201,8 +213,8 @@ const defaultNotes = `1. Get the application URL by running these commands:
You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}' 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}') export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.externalPort }} echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
{{- else if contains "ClusterIP" .Values.service.type }} {{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "fullname" . }}" -o jsonpath="{.items[0].metadata.name}") export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application" echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }} kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }}
{{- end }} {{- end }}

Loading…
Cancel
Save