From 51923e54b18ad6400375697e4935fd791cc23072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20N=C3=A4gele?= Date: Fri, 16 Jun 2017 09:40:46 +0200 Subject: [PATCH 1/2] Improve 'helm create' --- pkg/chartutil/create.go | 84 +++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 8ab05e896..855ada7bd 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -74,13 +74,13 @@ ingress: # - secretName: chart-example-tls # hosts: # - chart-example.local -resources: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + #requests: + # cpu: 100m + # memory: 128Mi ` @@ -115,10 +115,10 @@ kind: Ingress metadata: name: {{ template "fullname" . }} labels: - app: {{ template "fullname" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} annotations: {{- range $key, $value := .Values.ingress.annotations }} {{ $key }}: {{ $value | quote }} @@ -146,30 +146,38 @@ kind: Deployment metadata: name: {{ template "fullname" . }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} spec: replicas: {{ .Values.replicaCount }} template: metadata: labels: - app: {{ template "fullname" . }} + app: {{ template "name" . }} + release: {{ .Release.Name }} spec: containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - containerPort: {{ .Values.service.internalPort }} - livenessProbe: - httpGet: - path: / - port: {{ .Values.service.internalPort }} - readinessProbe: - httpGet: - path: / - port: {{ .Values.service.internalPort }} - resources: -{{ toYaml .Values.resources | indent 10 }} + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.internalPort }} + livenessProbe: + httpGet: + path: / + port: {{ .Values.service.internalPort }} + readinessProbe: + httpGet: + path: / + port: {{ .Values.service.internalPort }} + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} ` const defaultService = `apiVersion: v1 @@ -177,16 +185,20 @@ kind: Service metadata: name: {{ template "fullname" . }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} spec: type: {{ .Values.service.type }} ports: - - port: {{ .Values.service.externalPort }} - targetPort: {{ .Values.service.internalPort }} - protocol: TCP - name: {{ .Values.service.name }} + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + protocol: TCP + name: {{ .Values.service.name }} selector: - app: {{ template "fullname" . }} + app: {{ template "name" . }} + release: {{ .Release.Name }} ` 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" . }}' 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 }} -{{- 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}") +{{- else if contains "ClusterIP" .Values.service.type }} + 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" kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }} {{- end }} From 76e6e15a0c89c03fe6cfa0ac48b7f3cc1f2e5cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20N=C3=A4gele?= Date: Sun, 18 Jun 2017 14:42:36 +0200 Subject: [PATCH 2/2] Add comment on resources --- pkg/chartutil/create.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 855ada7bd..e0e0429db 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -75,13 +75,16 @@ ingress: # 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 + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. # limits: # cpu: 100m # memory: 128Mi #requests: # cpu: 100m # memory: 128Mi - ` const defaultIgnore = `# Patterns to ignore when building packages.