From d8c74479032eef0674066db54b3211692ff0b587 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 6 Dec 2018 23:33:54 +1100 Subject: [PATCH 01/22] Added skipDependencyBuild option to Helm deployment --- pkg/skaffold/deploy/helm.go | 13 +++++++++---- pkg/skaffold/deploy/helm_test.go | 25 +++++++++++++++++++++++++ pkg/skaffold/schema/latest/config.go | 27 ++++++++++++++------------- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/pkg/skaffold/deploy/helm.go b/pkg/skaffold/deploy/helm.go index 263636a5312..07b833beafa 100644 --- a/pkg/skaffold/deploy/helm.go +++ b/pkg/skaffold/deploy/helm.go @@ -153,10 +153,15 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates } } - // First build dependencies. - logrus.Infof("Building helm dependencies...") - if err := h.helm(ctx, out, "dep", "build", r.ChartPath); err != nil { - return nil, errors.Wrap(err, "building helm dependencies") + // Dependency builds should be skipped when trying to install a chart + // with local dependencies in the chart folder, e.g. the istio helm chart. + // This decision is left to the user. + if !r.SkipDependencyBuild { + // First build dependencies. + logrus.Infof("Building helm dependencies...") + if err := h.helm(ctx, out, "dep", "build", r.ChartPath); err != nil { + return nil, errors.Wrap(err, "building helm dependencies") + } } var args []string diff --git a/pkg/skaffold/deploy/helm_test.go b/pkg/skaffold/deploy/helm_test.go index f540d386b16..ef08ebe65fa 100644 --- a/pkg/skaffold/deploy/helm_test.go +++ b/pkg/skaffold/deploy/helm_test.go @@ -86,6 +86,25 @@ var testDeployRecreatePodsConfig = &latest.HelmDeploy{ }, } +var testDeploySkipDependencyBuildConfig = &latest.HelmDeploy{ + Releases: []latest.HelmRelease{ + { + Name: "skaffold-helm", + ChartPath: "examples/test", + Values: map[string]string{ + "image": "skaffold-helm", + }, + Overrides: map[string]interface{}{ + "foo": "bar", + }, + SetValues: map[string]string{ + "some.key": "somevalue", + }, + SkipDependencyBuild: true, + }, + }, +} + var testDeployHelmStyleConfig = &latest.HelmDeploy{ Releases: []latest.HelmRelease{ { @@ -261,6 +280,12 @@ func TestHelmDeploy(t *testing.T) { deployer: NewHelmDeployer(testDeployRecreatePodsConfig, testKubeContext, testNamespace, ""), builds: testBuilds, }, + { + description: "deploy success with skipDependencyBuild", + cmd: &MockHelm{t: t}, + deployer: NewHelmDeployer(testDeploySkipDependencyBuildConfig, testKubeContext, testNamespace, ""), + builds: testBuilds, + }, { description: "deploy error unmatched parameter", cmd: &MockHelm{t: t}, diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 974a80b030e..e953e45596b 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -185,19 +185,20 @@ type KustomizeDeploy struct { } type HelmRelease struct { - Name string `yaml:"name,omitempty"` - ChartPath string `yaml:"chartPath,omitempty"` - ValuesFiles []string `yaml:"valuesFiles,omitempty"` - Values map[string]string `yaml:"values,omitempty,omitempty"` - Namespace string `yaml:"namespace,omitempty"` - Version string `yaml:"version,omitempty"` - SetValues map[string]string `yaml:"setValues,omitempty"` - SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` - Wait bool `yaml:"wait,omitempty"` - RecreatePods bool `yaml:"recreatePods,omitempty"` - Overrides map[string]interface{} `yaml:"overrides,omitempty"` - Packaged *HelmPackaged `yaml:"packaged,omitempty"` - ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` + Name string `yaml:"name,omitempty"` + ChartPath string `yaml:"chartPath,omitempty"` + ValuesFiles []string `yaml:"valuesFiles,omitempty"` + Values map[string]string `yaml:"values,omitempty,omitempty"` + Namespace string `yaml:"namespace,omitempty"` + Version string `yaml:"version,omitempty"` + SetValues map[string]string `yaml:"setValues,omitempty"` + SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` + Wait bool `yaml:"wait,omitempty"` + SkipDependencyBuild bool `yaml:"skipDependencyBuild,omitempty"` + RecreatePods bool `yaml:"recreatePods,omitempty"` + Overrides map[string]interface{} `yaml:"overrides,omitempty"` + Packaged *HelmPackaged `yaml:"packaged,omitempty"` + ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` } // HelmPackaged represents parameters for packaging helm chart. From 21147f10e3046c656687e5bcf2e9bc19b987a25c Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 7 Dec 2018 00:08:06 +1100 Subject: [PATCH 02/22] Added example of using helm with skipBuildDependencies --- examples/README.adoc | 1 + .../helm-deployment-dependencies/Dockerfile | 1 + .../helm-deployment-dependencies/README.adoc | 29 +++++++++++++ .../skaffold-helm/.helmignore | 21 ++++++++++ .../skaffold-helm/Chart.yaml | 4 ++ .../skaffold-helm/charts/subchart/.helmignore | 21 ++++++++++ .../skaffold-helm/charts/subchart/Chart.yaml | 4 ++ .../charts/subchart/templates/_helpers.tpl | 16 +++++++ .../charts/subchart/templates/deployment.yaml | 29 +++++++++++++ .../charts/subchart/templates/ingress.yaml | 32 ++++++++++++++ .../charts/subchart/templates/service.yaml | 19 +++++++++ .../skaffold-helm/charts/subchart/values.yaml | 40 ++++++++++++++++++ .../skaffold-helm/requirements.yaml | 3 ++ .../skaffold-helm/templates/_helpers.tpl | 16 +++++++ .../skaffold-helm/templates/deployment.yaml | 29 +++++++++++++ .../skaffold-helm/templates/ingress.yaml | 32 ++++++++++++++ .../skaffold-helm/templates/service.yaml | 19 +++++++++ .../skaffold-helm/values.yaml | 42 +++++++++++++++++++ .../skaffold.yaml | 28 +++++++++++++ 19 files changed, 386 insertions(+) create mode 100644 examples/helm-deployment-dependencies/Dockerfile create mode 100644 examples/helm-deployment-dependencies/README.adoc create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/.helmignore create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/values.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold.yaml diff --git a/examples/README.adoc b/examples/README.adoc index e3b67bd9744..e51f5f37553 100644 --- a/examples/README.adoc +++ b/examples/README.adoc @@ -22,6 +22,7 @@ include::./getting-started/README.adoc[] include::./microservices/README.adoc[] include::./tagging-with-environment-variables/README.adoc[] include::./helm-deployment/README.adoc[] +include::./helm-deployment-dependencies/README.adoc[] include::./kustomize/README.adoc[] include::./kaniko/README.adoc[] include::./bazel/README.adoc[] diff --git a/examples/helm-deployment-dependencies/Dockerfile b/examples/helm-deployment-dependencies/Dockerfile new file mode 100644 index 00000000000..75eca2cb8ef --- /dev/null +++ b/examples/helm-deployment-dependencies/Dockerfile @@ -0,0 +1 @@ +FROM nginx:stable diff --git a/examples/helm-deployment-dependencies/README.adoc b/examples/helm-deployment-dependencies/README.adoc new file mode 100644 index 00000000000..c009fff2ec6 --- /dev/null +++ b/examples/helm-deployment-dependencies/README.adoc @@ -0,0 +1,29 @@ +=== Example: helm-dependencies +:icons: font + +ifndef::env-github[] +link:{github-repo-tree}/examples/helm-deployment-dependencies[see on Github icon:github[]] +endif::[] + +==== Helm charts with local dependencies + +This example follows the `helm-deployment` example, but with a local chart as a depenency. + +The option `skipDependencyBuild` is used to skip the `helm dep build` command, which is not required for local dependencies. + +The image can be passed to the subchart using the standard Helm format of `subchart-name.value`. + +``` +deploy: + helm: + releases: + - name: skaffold-helm + chartPath: skaffold-helm + namespace: skaffold + skipDependencyBuild: true # Skip helm dep build + values: + image: skaffold-helm + "skaffold-helm-subchart.image": gcr.io/k8s-skaffold/skaffold-helm + valuesFiles: + - helm-values-file.yaml +``` diff --git a/examples/helm-deployment-dependencies/skaffold-helm/.helmignore b/examples/helm-deployment-dependencies/skaffold-helm/.helmignore new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml b/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml new file mode 100644 index 00000000000..f4fcfadbec9 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: skaffold-helm +version: 0.1.0 diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml new file mode 100644 index 00000000000..3879caeaabd --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: subchart +version: 0.1.0 diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl new file mode 100644 index 00000000000..7ced0ae3253 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "subchart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "subchart.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml new file mode 100644 index 00000000000..f3075de53e3 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "subchart.name" . }} + labels: + app: {{ template "subchart.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "subchart.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} + imagePullPolicy: {{ .Values.pullPolicy }} + command: ["/bin/bash", "-c", "--" ] + args: ["while true; do sleep 30; done;"] + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml new file mode 100644 index 00000000000..127987f69d9 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "subchart.fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "subchart.fullname" . }} + labels: + app: {{ template "subchart.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml new file mode 100644 index 00000000000..80bb3759b95 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "subchart.fullname" . }} + labels: + app: {{ template "subchart.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 }} + selector: + app: {{ template "subchart.name" . }} + release: {{ .Release.Name }} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml new file mode 100644 index 00000000000..e930d90bd76 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml @@ -0,0 +1,40 @@ +# Default values for skaffold-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +nameOverride: "subchart" +replicaCount: 1 +image: nginx:stable +# This is the helm convention on declaring images +# image: +# repository: nginx +# tag: stable +# pullPolicy: IfNotPresent +service: + name: nginx + type: ClusterIP + externalPort: 80 + internalPort: 80 +ingress: + enabled: false + # Used to create an Ingress record. + hosts: + - chart-example.local + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + # Secrets must be manually created in the namespace. + # - 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 + # 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 diff --git a/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml b/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml new file mode 100644 index 00000000000..14601dde3a6 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml @@ -0,0 +1,3 @@ +dependencies: + - name: subchart + condition: subchart.enabled diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl b/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl new file mode 100644 index 00000000000..537a7399829 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "skaffold-helm.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "skaffold-helm.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml b/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml new file mode 100644 index 00000000000..02b76c5ec04 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "skaffold-helm.name" . }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "skaffold-helm.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} + imagePullPolicy: {{ .Values.pullPolicy }} + command: ["/bin/bash", "-c", "--" ] + args: ["while true; do sleep 30; done;"] + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml b/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml new file mode 100644 index 00000000000..87fe1e813e6 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "skaffold-helm.fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml b/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml new file mode 100644 index 00000000000..da7b3ef867b --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.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 }} + selector: + app: {{ template "skaffold-helm.name" . }} + release: {{ .Release.Name }} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/values.yaml b/examples/helm-deployment-dependencies/skaffold-helm/values.yaml new file mode 100644 index 00000000000..3f3132b57e5 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/values.yaml @@ -0,0 +1,42 @@ +# Default values for skaffold-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +image: nginx:stable +# This is the helm convention on declaring images +# image: +# repository: nginx +# tag: stable +# pullPolicy: IfNotPresent +service: + name: nginx + type: ClusterIP + externalPort: 80 + internalPort: 80 +ingress: + enabled: false + # Used to create an Ingress record. + hosts: + - chart-example.local + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + # Secrets must be manually created in the namespace. + # - 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 + # 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 + +skaffold-helm-subchart: + enabled: true diff --git a/examples/helm-deployment-dependencies/skaffold.yaml b/examples/helm-deployment-dependencies/skaffold.yaml new file mode 100644 index 00000000000..f40536aae1c --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold.yaml @@ -0,0 +1,28 @@ +apiVersion: skaffold/v1beta1 +kind: Config +build: + tagPolicy: + sha256: {} + artifacts: + - image: gcr.io/k8s-skaffold/skaffold-helm +deploy: + helm: + releases: + - name: skaffold-helm + chartPath: skaffold-helm + #wait: true + #valuesFiles: + #- helm-skaffold-values.yaml + skipDependencyBuild: true # Skip helm dep build + values: + image: gcr.io/k8s-skaffold/skaffold-helm + "skaffold-helm-subchart.image": gcr.io/k8s-skaffold/skaffold-helm + #recreatePods will pass --recreate-pods to helm upgrade + #recreatePods: true + #overrides builds an override values.yaml file to run with the helm deploy + #overrides: + # some: + # key: someValue + #setValues get appended to the helm deploy with --set. + #setValues: + #some.key: someValue From 542dcb78bbdf432ca332562a7d425f09cec256d5 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 7 Dec 2018 00:09:54 +1100 Subject: [PATCH 03/22] Updated annotated-skaffold.yaml --- examples/annotated-skaffold.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/annotated-skaffold.yaml b/examples/annotated-skaffold.yaml index 2c50ac83cdb..0d42954338a 100644 --- a/examples/annotated-skaffold.yaml +++ b/examples/annotated-skaffold.yaml @@ -185,6 +185,9 @@ deploy: # version: "" # recreatePods: false # + # # Skip the helm dep build, required for charts with local dependencies + # skipDependencyBuild: false + # # # setValues get appended to the helm deploy with --set. # setValues: # key: "value" From b6f4a345b323a29fd858b325457cfbb3b460565d Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 7 Dec 2018 00:20:48 +1100 Subject: [PATCH 04/22] Example + docs fixes --- examples/helm-deployment-dependencies/README.adoc | 8 ++++---- .../skaffold-helm/values.yaml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/helm-deployment-dependencies/README.adoc b/examples/helm-deployment-dependencies/README.adoc index c009fff2ec6..37590119b02 100644 --- a/examples/helm-deployment-dependencies/README.adoc +++ b/examples/helm-deployment-dependencies/README.adoc @@ -5,11 +5,11 @@ ifndef::env-github[] link:{github-repo-tree}/examples/helm-deployment-dependencies[see on Github icon:github[]] endif::[] -==== Helm charts with local dependencies +==== Deploy helm charts with local dependencies -This example follows the `helm-deployment` example, but with a local chart as a depenency. +This example follows the link:{github-repo-tree}/examples/helm-deployment-dependencies[helm] example, but with a local chart as a depenency. -The option `skipDependencyBuild` is used to skip the `helm dep build` command, which is not required for local dependencies. +The `skipDependencyBuild` option is used to skip the `helm dep build` command. This must be disabled for charts with local dependencies. The image can be passed to the subchart using the standard Helm format of `subchart-name.value`. @@ -23,7 +23,7 @@ deploy: skipDependencyBuild: true # Skip helm dep build values: image: skaffold-helm - "skaffold-helm-subchart.image": gcr.io/k8s-skaffold/skaffold-helm + "subchart.image": gcr.io/k8s-skaffold/skaffold-helm # Set image for subchart valuesFiles: - helm-values-file.yaml ``` diff --git a/examples/helm-deployment-dependencies/skaffold-helm/values.yaml b/examples/helm-deployment-dependencies/skaffold-helm/values.yaml index 3f3132b57e5..49dfad48c72 100644 --- a/examples/helm-deployment-dependencies/skaffold-helm/values.yaml +++ b/examples/helm-deployment-dependencies/skaffold-helm/values.yaml @@ -38,5 +38,5 @@ resources: {} # cpu: 100m # memory: 128Mi -skaffold-helm-subchart: +subchart: enabled: true From 8a7816e467e2d4674d1ddb75291513c0b1b8d132 Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 8 Dec 2018 13:18:13 +1100 Subject: [PATCH 05/22] Move example + annotated-skaffold.yaml to integration folder --- examples/annotated-skaffold.yaml | 3 --- integration/examples/annotated-skaffold.yaml | 3 +++ .../examples}/helm-deployment-dependencies/Dockerfile | 0 .../examples}/helm-deployment-dependencies/README.adoc | 0 .../helm-deployment-dependencies/skaffold-helm/.helmignore | 0 .../helm-deployment-dependencies/skaffold-helm/Chart.yaml | 0 .../skaffold-helm/charts/subchart/.helmignore | 0 .../skaffold-helm/charts/subchart/Chart.yaml | 0 .../skaffold-helm/charts/subchart/templates/_helpers.tpl | 0 .../skaffold-helm/charts/subchart/templates/deployment.yaml | 0 .../skaffold-helm/charts/subchart/templates/ingress.yaml | 0 .../skaffold-helm/charts/subchart/templates/service.yaml | 0 .../skaffold-helm/charts/subchart/values.yaml | 0 .../skaffold-helm/requirements.yaml | 0 .../skaffold-helm/templates/_helpers.tpl | 0 .../skaffold-helm/templates/deployment.yaml | 0 .../skaffold-helm/templates/ingress.yaml | 0 .../skaffold-helm/templates/service.yaml | 0 .../helm-deployment-dependencies/skaffold-helm/values.yaml | 0 .../examples}/helm-deployment-dependencies/skaffold.yaml | 0 20 files changed, 3 insertions(+), 3 deletions(-) rename {examples => integration/examples}/helm-deployment-dependencies/Dockerfile (100%) rename {examples => integration/examples}/helm-deployment-dependencies/README.adoc (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/.helmignore (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/Chart.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/requirements.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/templates/service.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold-helm/values.yaml (100%) rename {examples => integration/examples}/helm-deployment-dependencies/skaffold.yaml (100%) diff --git a/examples/annotated-skaffold.yaml b/examples/annotated-skaffold.yaml index 0d42954338a..2c50ac83cdb 100644 --- a/examples/annotated-skaffold.yaml +++ b/examples/annotated-skaffold.yaml @@ -185,9 +185,6 @@ deploy: # version: "" # recreatePods: false # - # # Skip the helm dep build, required for charts with local dependencies - # skipDependencyBuild: false - # # # setValues get appended to the helm deploy with --set. # setValues: # key: "value" diff --git a/integration/examples/annotated-skaffold.yaml b/integration/examples/annotated-skaffold.yaml index 2c50ac83cdb..0d42954338a 100644 --- a/integration/examples/annotated-skaffold.yaml +++ b/integration/examples/annotated-skaffold.yaml @@ -185,6 +185,9 @@ deploy: # version: "" # recreatePods: false # + # # Skip the helm dep build, required for charts with local dependencies + # skipDependencyBuild: false + # # # setValues get appended to the helm deploy with --set. # setValues: # key: "value" diff --git a/examples/helm-deployment-dependencies/Dockerfile b/integration/examples/helm-deployment-dependencies/Dockerfile similarity index 100% rename from examples/helm-deployment-dependencies/Dockerfile rename to integration/examples/helm-deployment-dependencies/Dockerfile diff --git a/examples/helm-deployment-dependencies/README.adoc b/integration/examples/helm-deployment-dependencies/README.adoc similarity index 100% rename from examples/helm-deployment-dependencies/README.adoc rename to integration/examples/helm-deployment-dependencies/README.adoc diff --git a/examples/helm-deployment-dependencies/skaffold-helm/.helmignore b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/.helmignore rename to integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore diff --git a/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore rename to integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl rename to integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml diff --git a/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl rename to integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml diff --git a/examples/helm-deployment-dependencies/skaffold-helm/values.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/values.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold-helm/values.yaml rename to integration/examples/helm-deployment-dependencies/skaffold-helm/values.yaml diff --git a/examples/helm-deployment-dependencies/skaffold.yaml b/integration/examples/helm-deployment-dependencies/skaffold.yaml similarity index 100% rename from examples/helm-deployment-dependencies/skaffold.yaml rename to integration/examples/helm-deployment-dependencies/skaffold.yaml From f0730f725b01bc298af6e94ef489aa7e75251f59 Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 8 Dec 2018 13:21:05 +1100 Subject: [PATCH 06/22] Corrected README in examples, updated integration examples README --- examples/README.adoc | 1 - integration/examples/README.adoc | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/README.adoc b/examples/README.adoc index e51f5f37553..e3b67bd9744 100644 --- a/examples/README.adoc +++ b/examples/README.adoc @@ -22,7 +22,6 @@ include::./getting-started/README.adoc[] include::./microservices/README.adoc[] include::./tagging-with-environment-variables/README.adoc[] include::./helm-deployment/README.adoc[] -include::./helm-deployment-dependencies/README.adoc[] include::./kustomize/README.adoc[] include::./kaniko/README.adoc[] include::./bazel/README.adoc[] diff --git a/integration/examples/README.adoc b/integration/examples/README.adoc index e3b67bd9744..42745242366 100644 --- a/integration/examples/README.adoc +++ b/integration/examples/README.adoc @@ -22,6 +22,7 @@ include::./getting-started/README.adoc[] include::./microservices/README.adoc[] include::./tagging-with-environment-variables/README.adoc[] include::./helm-deployment/README.adoc[] +include::./helm-deployment-dependencies/README.adoc[] include::./kustomize/README.adoc[] include::./kaniko/README.adoc[] include::./bazel/README.adoc[] @@ -33,6 +34,7 @@ ifdef::env-github[] - link:./microservices[] - link:./tagging-with-environment-variables[] - link:./helm-deployment[] +- link:./helm-deployment-dependencies[] - link:./kustomize[] - link:./kaniko[] - link:./bazel[] From 25d9e3102bede8efd55164a1125e28c7188c7a8b Mon Sep 17 00:00:00 2001 From: Balint Pato Date: Sun, 9 Dec 2018 12:22:35 +1100 Subject: [PATCH 07/22] Update apiVersion to v1beta2 in integration/examples/helm-deployment-dependencies/skaffold.yaml Co-Authored-By: pscarey --- integration/examples/helm-deployment-dependencies/skaffold.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/examples/helm-deployment-dependencies/skaffold.yaml b/integration/examples/helm-deployment-dependencies/skaffold.yaml index f40536aae1c..3865fa1d43b 100644 --- a/integration/examples/helm-deployment-dependencies/skaffold.yaml +++ b/integration/examples/helm-deployment-dependencies/skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1beta1 +apiVersion: skaffold/v1beta2 kind: Config build: tagPolicy: From 68aa15f11f5d3bf0a5d392675117cace5257a72a Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 6 Dec 2018 23:33:54 +1100 Subject: [PATCH 08/22] Added skipDependencyBuild option to Helm deployment --- pkg/skaffold/deploy/helm.go | 13 +++++++++---- pkg/skaffold/deploy/helm_test.go | 25 +++++++++++++++++++++++++ pkg/skaffold/schema/latest/config.go | 27 ++++++++++++++------------- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/pkg/skaffold/deploy/helm.go b/pkg/skaffold/deploy/helm.go index 263636a5312..07b833beafa 100644 --- a/pkg/skaffold/deploy/helm.go +++ b/pkg/skaffold/deploy/helm.go @@ -153,10 +153,15 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates } } - // First build dependencies. - logrus.Infof("Building helm dependencies...") - if err := h.helm(ctx, out, "dep", "build", r.ChartPath); err != nil { - return nil, errors.Wrap(err, "building helm dependencies") + // Dependency builds should be skipped when trying to install a chart + // with local dependencies in the chart folder, e.g. the istio helm chart. + // This decision is left to the user. + if !r.SkipDependencyBuild { + // First build dependencies. + logrus.Infof("Building helm dependencies...") + if err := h.helm(ctx, out, "dep", "build", r.ChartPath); err != nil { + return nil, errors.Wrap(err, "building helm dependencies") + } } var args []string diff --git a/pkg/skaffold/deploy/helm_test.go b/pkg/skaffold/deploy/helm_test.go index f540d386b16..ef08ebe65fa 100644 --- a/pkg/skaffold/deploy/helm_test.go +++ b/pkg/skaffold/deploy/helm_test.go @@ -86,6 +86,25 @@ var testDeployRecreatePodsConfig = &latest.HelmDeploy{ }, } +var testDeploySkipDependencyBuildConfig = &latest.HelmDeploy{ + Releases: []latest.HelmRelease{ + { + Name: "skaffold-helm", + ChartPath: "examples/test", + Values: map[string]string{ + "image": "skaffold-helm", + }, + Overrides: map[string]interface{}{ + "foo": "bar", + }, + SetValues: map[string]string{ + "some.key": "somevalue", + }, + SkipDependencyBuild: true, + }, + }, +} + var testDeployHelmStyleConfig = &latest.HelmDeploy{ Releases: []latest.HelmRelease{ { @@ -261,6 +280,12 @@ func TestHelmDeploy(t *testing.T) { deployer: NewHelmDeployer(testDeployRecreatePodsConfig, testKubeContext, testNamespace, ""), builds: testBuilds, }, + { + description: "deploy success with skipDependencyBuild", + cmd: &MockHelm{t: t}, + deployer: NewHelmDeployer(testDeploySkipDependencyBuildConfig, testKubeContext, testNamespace, ""), + builds: testBuilds, + }, { description: "deploy error unmatched parameter", cmd: &MockHelm{t: t}, diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 710df3a1972..221e33da349 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -178,19 +178,20 @@ type KustomizeDeploy struct { } type HelmRelease struct { - Name string `yaml:"name,omitempty"` - ChartPath string `yaml:"chartPath,omitempty"` - ValuesFiles []string `yaml:"valuesFiles,omitempty"` - Values map[string]string `yaml:"values,omitempty,omitempty"` - Namespace string `yaml:"namespace,omitempty"` - Version string `yaml:"version,omitempty"` - SetValues map[string]string `yaml:"setValues,omitempty"` - SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` - Wait bool `yaml:"wait,omitempty"` - RecreatePods bool `yaml:"recreatePods,omitempty"` - Overrides map[string]interface{} `yaml:"overrides,omitempty"` - Packaged *HelmPackaged `yaml:"packaged,omitempty"` - ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` + Name string `yaml:"name,omitempty"` + ChartPath string `yaml:"chartPath,omitempty"` + ValuesFiles []string `yaml:"valuesFiles,omitempty"` + Values map[string]string `yaml:"values,omitempty,omitempty"` + Namespace string `yaml:"namespace,omitempty"` + Version string `yaml:"version,omitempty"` + SetValues map[string]string `yaml:"setValues,omitempty"` + SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` + Wait bool `yaml:"wait,omitempty"` + SkipDependencyBuild bool `yaml:"skipDependencyBuild,omitempty"` + RecreatePods bool `yaml:"recreatePods,omitempty"` + Overrides map[string]interface{} `yaml:"overrides,omitempty"` + Packaged *HelmPackaged `yaml:"packaged,omitempty"` + ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` } // HelmPackaged represents parameters for packaging helm chart. From d210c2672656d3bec4959f1b8864147dcfc92ee1 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 7 Dec 2018 00:09:54 +1100 Subject: [PATCH 09/22] Updated annotated-skaffold.yaml --- examples/annotated-skaffold.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/annotated-skaffold.yaml b/examples/annotated-skaffold.yaml index 46252613de4..354b84695ba 100644 --- a/examples/annotated-skaffold.yaml +++ b/examples/annotated-skaffold.yaml @@ -190,6 +190,9 @@ deploy: # version: "" # recreatePods: false # + # # Skip the helm dep build, required for charts with local dependencies + # skipDependencyBuild: false + # # # setValues get appended to the helm deploy with --set. # setValues: # key: "value" From 53a9865010120c4bec81262bd74f7dcba158bdc5 Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 8 Dec 2018 13:18:13 +1100 Subject: [PATCH 10/22] Move example + annotated-skaffold.yaml to integration folder --- examples/annotated-skaffold.yaml | 3 -- integration/examples/annotated-skaffold.yaml | 3 ++ .../helm-deployment-dependencies/Dockerfile | 1 + .../Dockerfile~HEAD | 1 + ...otated-skaffold.yaml to integration folder | 1 + .../helm-deployment-dependencies/README.adoc | 29 +++++++++++++ .../skaffold-helm/.helmignore | 21 ++++++++++ .../skaffold-helm/.helmignore~HEAD | 21 ++++++++++ .../skaffold-helm/.helmignore~HEAD_0 | 21 ++++++++++ ...otated-skaffold.yaml to integration folder | 21 ++++++++++ ...ated-skaffold.yaml to integration folder_0 | 21 ++++++++++ .../skaffold-helm/Chart.yaml | 4 ++ .../skaffold-helm/Chart.yaml~HEAD | 4 ++ ...otated-skaffold.yaml to integration folder | 4 ++ .../skaffold-helm/charts/subchart/.helmignore | 21 ++++++++++ .../charts/subchart/.helmignore~HEAD | 21 ++++++++++ ...otated-skaffold.yaml to integration folder | 21 ++++++++++ .../skaffold-helm/charts/subchart/Chart.yaml | 4 ++ .../charts/subchart/templates/_helpers.tpl | 16 +++++++ .../charts/subchart/templates/deployment.yaml | 29 +++++++++++++ .../charts/subchart/templates/ingress.yaml | 32 ++++++++++++++ .../charts/subchart/templates/service.yaml | 19 +++++++++ .../skaffold-helm/charts/subchart/values.yaml | 40 ++++++++++++++++++ .../skaffold-helm/requirements.yaml | 3 ++ .../skaffold-helm/templates/_helpers.tpl | 16 +++++++ .../skaffold-helm/templates/_helpers.tpl~HEAD | 16 +++++++ ...otated-skaffold.yaml to integration folder | 16 +++++++ .../skaffold-helm/templates/deployment.yaml | 29 +++++++++++++ .../skaffold-helm/templates/ingress.yaml | 32 ++++++++++++++ .../skaffold-helm/templates/ingress.yaml~HEAD | 32 ++++++++++++++ ...otated-skaffold.yaml to integration folder | 32 ++++++++++++++ .../skaffold-helm/templates/service.yaml | 19 +++++++++ .../skaffold-helm/templates/service.yaml~HEAD | 19 +++++++++ ...otated-skaffold.yaml to integration folder | 19 +++++++++ .../skaffold-helm/values.yaml | 42 +++++++++++++++++++ .../skaffold.yaml | 28 +++++++++++++ 36 files changed, 658 insertions(+), 3 deletions(-) create mode 100644 integration/examples/helm-deployment-dependencies/Dockerfile create mode 100644 integration/examples/helm-deployment-dependencies/Dockerfile~HEAD create mode 100644 integration/examples/helm-deployment-dependencies/Dockerfile~Move example + annotated-skaffold.yaml to integration folder create mode 100644 integration/examples/helm-deployment-dependencies/README.adoc create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD_0 create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder_0 create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~HEAD create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~Move example + annotated-skaffold.yaml to integration folder create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~HEAD create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~Move example + annotated-skaffold.yaml to integration folder create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~HEAD create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~Move example + annotated-skaffold.yaml to integration folder create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~HEAD create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~Move example + annotated-skaffold.yaml to integration folder create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~HEAD create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~Move example + annotated-skaffold.yaml to integration folder create mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/values.yaml create mode 100644 integration/examples/helm-deployment-dependencies/skaffold.yaml diff --git a/examples/annotated-skaffold.yaml b/examples/annotated-skaffold.yaml index 354b84695ba..46252613de4 100644 --- a/examples/annotated-skaffold.yaml +++ b/examples/annotated-skaffold.yaml @@ -190,9 +190,6 @@ deploy: # version: "" # recreatePods: false # - # # Skip the helm dep build, required for charts with local dependencies - # skipDependencyBuild: false - # # # setValues get appended to the helm deploy with --set. # setValues: # key: "value" diff --git a/integration/examples/annotated-skaffold.yaml b/integration/examples/annotated-skaffold.yaml index 46252613de4..354b84695ba 100644 --- a/integration/examples/annotated-skaffold.yaml +++ b/integration/examples/annotated-skaffold.yaml @@ -190,6 +190,9 @@ deploy: # version: "" # recreatePods: false # + # # Skip the helm dep build, required for charts with local dependencies + # skipDependencyBuild: false + # # # setValues get appended to the helm deploy with --set. # setValues: # key: "value" diff --git a/integration/examples/helm-deployment-dependencies/Dockerfile b/integration/examples/helm-deployment-dependencies/Dockerfile new file mode 100644 index 00000000000..75eca2cb8ef --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/Dockerfile @@ -0,0 +1 @@ +FROM nginx:stable diff --git a/integration/examples/helm-deployment-dependencies/Dockerfile~HEAD b/integration/examples/helm-deployment-dependencies/Dockerfile~HEAD new file mode 100644 index 00000000000..75eca2cb8ef --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/Dockerfile~HEAD @@ -0,0 +1 @@ +FROM nginx:stable diff --git a/integration/examples/helm-deployment-dependencies/Dockerfile~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/Dockerfile~Move example + annotated-skaffold.yaml to integration folder new file mode 100644 index 00000000000..75eca2cb8ef --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/Dockerfile~Move example + annotated-skaffold.yaml to integration folder @@ -0,0 +1 @@ +FROM nginx:stable diff --git a/integration/examples/helm-deployment-dependencies/README.adoc b/integration/examples/helm-deployment-dependencies/README.adoc new file mode 100644 index 00000000000..37590119b02 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/README.adoc @@ -0,0 +1,29 @@ +=== Example: helm-dependencies +:icons: font + +ifndef::env-github[] +link:{github-repo-tree}/examples/helm-deployment-dependencies[see on Github icon:github[]] +endif::[] + +==== Deploy helm charts with local dependencies + +This example follows the link:{github-repo-tree}/examples/helm-deployment-dependencies[helm] example, but with a local chart as a depenency. + +The `skipDependencyBuild` option is used to skip the `helm dep build` command. This must be disabled for charts with local dependencies. + +The image can be passed to the subchart using the standard Helm format of `subchart-name.value`. + +``` +deploy: + helm: + releases: + - name: skaffold-helm + chartPath: skaffold-helm + namespace: skaffold + skipDependencyBuild: true # Skip helm dep build + values: + image: skaffold-helm + "subchart.image": gcr.io/k8s-skaffold/skaffold-helm # Set image for subchart + valuesFiles: + - helm-values-file.yaml +``` diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD_0 b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD_0 new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD_0 @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder_0 b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder_0 new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder_0 @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml new file mode 100644 index 00000000000..f4fcfadbec9 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: skaffold-helm +version: 0.1.0 diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~HEAD new file mode 100644 index 00000000000..f4fcfadbec9 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~HEAD @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: skaffold-helm +version: 0.1.0 diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~Move example + annotated-skaffold.yaml to integration folder new file mode 100644 index 00000000000..f4fcfadbec9 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~Move example + annotated-skaffold.yaml to integration folder @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: skaffold-helm +version: 0.1.0 diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~HEAD new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~HEAD @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~Move example + annotated-skaffold.yaml to integration folder new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~Move example + annotated-skaffold.yaml to integration folder @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml new file mode 100644 index 00000000000..3879caeaabd --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: subchart +version: 0.1.0 diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl new file mode 100644 index 00000000000..7ced0ae3253 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "subchart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "subchart.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml new file mode 100644 index 00000000000..f3075de53e3 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "subchart.name" . }} + labels: + app: {{ template "subchart.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "subchart.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} + imagePullPolicy: {{ .Values.pullPolicy }} + command: ["/bin/bash", "-c", "--" ] + args: ["while true; do sleep 30; done;"] + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml new file mode 100644 index 00000000000..127987f69d9 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "subchart.fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "subchart.fullname" . }} + labels: + app: {{ template "subchart.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml new file mode 100644 index 00000000000..80bb3759b95 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "subchart.fullname" . }} + labels: + app: {{ template "subchart.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 }} + selector: + app: {{ template "subchart.name" . }} + release: {{ .Release.Name }} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml new file mode 100644 index 00000000000..e930d90bd76 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml @@ -0,0 +1,40 @@ +# Default values for skaffold-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +nameOverride: "subchart" +replicaCount: 1 +image: nginx:stable +# This is the helm convention on declaring images +# image: +# repository: nginx +# tag: stable +# pullPolicy: IfNotPresent +service: + name: nginx + type: ClusterIP + externalPort: 80 + internalPort: 80 +ingress: + enabled: false + # Used to create an Ingress record. + hosts: + - chart-example.local + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + # Secrets must be manually created in the namespace. + # - 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 + # 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 diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml new file mode 100644 index 00000000000..14601dde3a6 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml @@ -0,0 +1,3 @@ +dependencies: + - name: subchart + condition: subchart.enabled diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl new file mode 100644 index 00000000000..537a7399829 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "skaffold-helm.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "skaffold-helm.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~HEAD new file mode 100644 index 00000000000..537a7399829 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~HEAD @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "skaffold-helm.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "skaffold-helm.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~Move example + annotated-skaffold.yaml to integration folder new file mode 100644 index 00000000000..537a7399829 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~Move example + annotated-skaffold.yaml to integration folder @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "skaffold-helm.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "skaffold-helm.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml new file mode 100644 index 00000000000..02b76c5ec04 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "skaffold-helm.name" . }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "skaffold-helm.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} + imagePullPolicy: {{ .Values.pullPolicy }} + command: ["/bin/bash", "-c", "--" ] + args: ["while true; do sleep 30; done;"] + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml new file mode 100644 index 00000000000..87fe1e813e6 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "skaffold-helm.fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~HEAD new file mode 100644 index 00000000000..87fe1e813e6 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~HEAD @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "skaffold-helm.fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~Move example + annotated-skaffold.yaml to integration folder new file mode 100644 index 00000000000..87fe1e813e6 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~Move example + annotated-skaffold.yaml to integration folder @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "skaffold-helm.fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml new file mode 100644 index 00000000000..da7b3ef867b --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.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 }} + selector: + app: {{ template "skaffold-helm.name" . }} + release: {{ .Release.Name }} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~HEAD new file mode 100644 index 00000000000..da7b3ef867b --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~HEAD @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.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 }} + selector: + app: {{ template "skaffold-helm.name" . }} + release: {{ .Release.Name }} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~Move example + annotated-skaffold.yaml to integration folder new file mode 100644 index 00000000000..da7b3ef867b --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~Move example + annotated-skaffold.yaml to integration folder @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.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 }} + selector: + app: {{ template "skaffold-helm.name" . }} + release: {{ .Release.Name }} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/values.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/values.yaml new file mode 100644 index 00000000000..49dfad48c72 --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/values.yaml @@ -0,0 +1,42 @@ +# Default values for skaffold-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +image: nginx:stable +# This is the helm convention on declaring images +# image: +# repository: nginx +# tag: stable +# pullPolicy: IfNotPresent +service: + name: nginx + type: ClusterIP + externalPort: 80 + internalPort: 80 +ingress: + enabled: false + # Used to create an Ingress record. + hosts: + - chart-example.local + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + # Secrets must be manually created in the namespace. + # - 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 + # 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 + +subchart: + enabled: true diff --git a/integration/examples/helm-deployment-dependencies/skaffold.yaml b/integration/examples/helm-deployment-dependencies/skaffold.yaml new file mode 100644 index 00000000000..f40536aae1c --- /dev/null +++ b/integration/examples/helm-deployment-dependencies/skaffold.yaml @@ -0,0 +1,28 @@ +apiVersion: skaffold/v1beta1 +kind: Config +build: + tagPolicy: + sha256: {} + artifacts: + - image: gcr.io/k8s-skaffold/skaffold-helm +deploy: + helm: + releases: + - name: skaffold-helm + chartPath: skaffold-helm + #wait: true + #valuesFiles: + #- helm-skaffold-values.yaml + skipDependencyBuild: true # Skip helm dep build + values: + image: gcr.io/k8s-skaffold/skaffold-helm + "skaffold-helm-subchart.image": gcr.io/k8s-skaffold/skaffold-helm + #recreatePods will pass --recreate-pods to helm upgrade + #recreatePods: true + #overrides builds an override values.yaml file to run with the helm deploy + #overrides: + # some: + # key: someValue + #setValues get appended to the helm deploy with --set. + #setValues: + #some.key: someValue From 7ea92d8f8c890f8bf3e3c71a0f031b5db7eb8a2a Mon Sep 17 00:00:00 2001 From: Balint Pato Date: Sun, 9 Dec 2018 12:22:35 +1100 Subject: [PATCH 11/22] Update apiVersion to v1beta2 in integration/examples/helm-deployment-dependencies/skaffold.yaml Co-Authored-By: pscarey --- integration/examples/helm-deployment-dependencies/skaffold.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/examples/helm-deployment-dependencies/skaffold.yaml b/integration/examples/helm-deployment-dependencies/skaffold.yaml index f40536aae1c..3865fa1d43b 100644 --- a/integration/examples/helm-deployment-dependencies/skaffold.yaml +++ b/integration/examples/helm-deployment-dependencies/skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1beta1 +apiVersion: skaffold/v1beta2 kind: Config build: tagPolicy: From 1d8732dd916ea3897bc72173a72248339006aad2 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 14 Jan 2019 14:06:33 +1100 Subject: [PATCH 12/22] Remove extraneous files --- .../Dockerfile~HEAD | 1 - ...otated-skaffold.yaml to integration folder | 1 - .../skaffold-helm/.helmignore~HEAD | 21 ------------ .../skaffold-helm/.helmignore~HEAD_0 | 21 ------------ ...otated-skaffold.yaml to integration folder | 21 ------------ ...ated-skaffold.yaml to integration folder_0 | 21 ------------ .../skaffold-helm/Chart.yaml~HEAD | 4 --- ...otated-skaffold.yaml to integration folder | 4 --- .../charts/subchart/.helmignore~HEAD | 21 ------------ ...otated-skaffold.yaml to integration folder | 21 ------------ .../skaffold-helm/templates/_helpers.tpl~HEAD | 16 ---------- ...otated-skaffold.yaml to integration folder | 16 ---------- .../skaffold-helm/templates/ingress.yaml~HEAD | 32 ------------------- ...otated-skaffold.yaml to integration folder | 32 ------------------- .../skaffold-helm/templates/service.yaml~HEAD | 19 ----------- ...otated-skaffold.yaml to integration folder | 19 ----------- 16 files changed, 270 deletions(-) delete mode 100644 integration/examples/helm-deployment-dependencies/Dockerfile~HEAD delete mode 100644 integration/examples/helm-deployment-dependencies/Dockerfile~Move example + annotated-skaffold.yaml to integration folder delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD_0 delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder_0 delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~HEAD delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~Move example + annotated-skaffold.yaml to integration folder delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~HEAD delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~Move example + annotated-skaffold.yaml to integration folder delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~HEAD delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~Move example + annotated-skaffold.yaml to integration folder delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~HEAD delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~Move example + annotated-skaffold.yaml to integration folder delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~HEAD delete mode 100644 integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~Move example + annotated-skaffold.yaml to integration folder diff --git a/integration/examples/helm-deployment-dependencies/Dockerfile~HEAD b/integration/examples/helm-deployment-dependencies/Dockerfile~HEAD deleted file mode 100644 index 75eca2cb8ef..00000000000 --- a/integration/examples/helm-deployment-dependencies/Dockerfile~HEAD +++ /dev/null @@ -1 +0,0 @@ -FROM nginx:stable diff --git a/integration/examples/helm-deployment-dependencies/Dockerfile~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/Dockerfile~Move example + annotated-skaffold.yaml to integration folder deleted file mode 100644 index 75eca2cb8ef..00000000000 --- a/integration/examples/helm-deployment-dependencies/Dockerfile~Move example + annotated-skaffold.yaml to integration folder +++ /dev/null @@ -1 +0,0 @@ -FROM nginx:stable diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD deleted file mode 100644 index f0c13194444..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD_0 b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD_0 deleted file mode 100644 index f0c13194444..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~HEAD_0 +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder deleted file mode 100644 index f0c13194444..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder_0 b/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder_0 deleted file mode 100644 index f0c13194444..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/.helmignore~Move example + annotated-skaffold.yaml to integration folder_0 +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~HEAD deleted file mode 100644 index f4fcfadbec9..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~HEAD +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: skaffold-helm -version: 0.1.0 diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~Move example + annotated-skaffold.yaml to integration folder deleted file mode 100644 index f4fcfadbec9..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml~Move example + annotated-skaffold.yaml to integration folder +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -description: A Helm chart for Kubernetes -name: skaffold-helm -version: 0.1.0 diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~HEAD deleted file mode 100644 index f0c13194444..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~HEAD +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~Move example + annotated-skaffold.yaml to integration folder deleted file mode 100644 index f0c13194444..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore~Move example + annotated-skaffold.yaml to integration folder +++ /dev/null @@ -1,21 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*~ -# Various IDEs -.project -.idea/ -*.tmproj diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~HEAD deleted file mode 100644 index 537a7399829..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~HEAD +++ /dev/null @@ -1,16 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "skaffold-helm.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -*/}} -{{- define "skaffold-helm.fullname" -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~Move example + annotated-skaffold.yaml to integration folder deleted file mode 100644 index 537a7399829..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl~Move example + annotated-skaffold.yaml to integration folder +++ /dev/null @@ -1,16 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "skaffold-helm.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -*/}} -{{- define "skaffold-helm.fullname" -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~HEAD deleted file mode 100644 index 87fe1e813e6..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~HEAD +++ /dev/null @@ -1,32 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $serviceName := include "skaffold-helm.fullname" . -}} -{{- $servicePort := .Values.service.externalPort -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ template "skaffold-helm.fullname" . }} - labels: - app: {{ template "skaffold-helm.name" . }} - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} - annotations: - {{- range $key, $value := .Values.ingress.annotations }} - {{ $key }}: {{ $value | quote }} - {{- end }} -spec: - rules: - {{- range $host := .Values.ingress.hosts }} - - host: {{ $host }} - http: - paths: - - path: / - backend: - serviceName: {{ $serviceName }} - servicePort: {{ $servicePort }} - {{- end -}} - {{- if .Values.ingress.tls }} - tls: -{{ toYaml .Values.ingress.tls | indent 4 }} - {{- end -}} -{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~Move example + annotated-skaffold.yaml to integration folder deleted file mode 100644 index 87fe1e813e6..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml~Move example + annotated-skaffold.yaml to integration folder +++ /dev/null @@ -1,32 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $serviceName := include "skaffold-helm.fullname" . -}} -{{- $servicePort := .Values.service.externalPort -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ template "skaffold-helm.fullname" . }} - labels: - app: {{ template "skaffold-helm.name" . }} - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} - annotations: - {{- range $key, $value := .Values.ingress.annotations }} - {{ $key }}: {{ $value | quote }} - {{- end }} -spec: - rules: - {{- range $host := .Values.ingress.hosts }} - - host: {{ $host }} - http: - paths: - - path: / - backend: - serviceName: {{ $serviceName }} - servicePort: {{ $servicePort }} - {{- end -}} - {{- if .Values.ingress.tls }} - tls: -{{ toYaml .Values.ingress.tls | indent 4 }} - {{- end -}} -{{- end -}} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~HEAD b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~HEAD deleted file mode 100644 index da7b3ef867b..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~HEAD +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ template "skaffold-helm.fullname" . }} - labels: - app: {{ template "skaffold-helm.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 }} - selector: - app: {{ template "skaffold-helm.name" . }} - release: {{ .Release.Name }} diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~Move example + annotated-skaffold.yaml to integration folder b/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~Move example + annotated-skaffold.yaml to integration folder deleted file mode 100644 index da7b3ef867b..00000000000 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml~Move example + annotated-skaffold.yaml to integration folder +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ template "skaffold-helm.fullname" . }} - labels: - app: {{ template "skaffold-helm.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 }} - selector: - app: {{ template "skaffold-helm.name" . }} - release: {{ .Release.Name }} From 0cb43e2ef90c69168ae0a60ae14357ebbc6b78c5 Mon Sep 17 00:00:00 2001 From: Balint Pato Date: Mon, 28 Jan 2019 16:50:52 -0800 Subject: [PATCH 13/22] update to v1beta4 --- .../skaffold-helm/charts/subchart/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml index f3075de53e3..87e6cf95d4a 100644 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml @@ -1,4 +1,4 @@ -apiVersion: extensions/v1beta1 +apiVersion: extensions/v1beta4 kind: Deployment metadata: name: {{ template "subchart.name" . }} From 7596048b5d75fbab2c046d8f7afaed4635ae7cc0 Mon Sep 17 00:00:00 2001 From: Balint Pato Date: Mon, 28 Jan 2019 16:52:08 -0800 Subject: [PATCH 14/22] revert rushed change --- .../skaffold-helm/charts/subchart/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml index 87e6cf95d4a..f3075de53e3 100644 --- a/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml +++ b/integration/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml @@ -1,4 +1,4 @@ -apiVersion: extensions/v1beta4 +apiVersion: extensions/v1beta1 kind: Deployment metadata: name: {{ template "subchart.name" . }} From 8876a516e4dbdea1e584daddddad290444cdad65 Mon Sep 17 00:00:00 2001 From: Balint Pato Date: Mon, 28 Jan 2019 16:52:45 -0800 Subject: [PATCH 15/22] upgrade to v1beta4 --- integration/examples/helm-deployment-dependencies/skaffold.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/examples/helm-deployment-dependencies/skaffold.yaml b/integration/examples/helm-deployment-dependencies/skaffold.yaml index 3865fa1d43b..a8cf67765ee 100644 --- a/integration/examples/helm-deployment-dependencies/skaffold.yaml +++ b/integration/examples/helm-deployment-dependencies/skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1beta2 +apiVersion: skaffold/v1beta4 kind: Config build: tagPolicy: From 831515f8d69ebc96baf011912b35504cbee8a15e Mon Sep 17 00:00:00 2001 From: Balint Pato Date: Mon, 28 Jan 2019 16:54:10 -0800 Subject: [PATCH 16/22] remove unnecessary header from example doc --- integration/examples/helm-deployment-dependencies/README.adoc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/integration/examples/helm-deployment-dependencies/README.adoc b/integration/examples/helm-deployment-dependencies/README.adoc index 37590119b02..b5383919cc2 100644 --- a/integration/examples/helm-deployment-dependencies/README.adoc +++ b/integration/examples/helm-deployment-dependencies/README.adoc @@ -1,10 +1,6 @@ === Example: helm-dependencies :icons: font -ifndef::env-github[] -link:{github-repo-tree}/examples/helm-deployment-dependencies[see on Github icon:github[]] -endif::[] - ==== Deploy helm charts with local dependencies This example follows the link:{github-repo-tree}/examples/helm-deployment-dependencies[helm] example, but with a local chart as a depenency. From 4e23a49a4ce000f6abbfa7efda7f8ed5b056ca21 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 22 Feb 2019 11:18:54 +1100 Subject: [PATCH 17/22] Fix naming errors - change option to SkipDependencyBuild --- pkg/skaffold/deploy/helm.go | 2 +- pkg/skaffold/deploy/helm_test.go | 20 +++++++++---------- pkg/skaffold/schema/latest/config.go | 4 ++-- pkg/skaffold/schema/v1beta4/config.go | 28 +++++++++++++-------------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/pkg/skaffold/deploy/helm.go b/pkg/skaffold/deploy/helm.go index 239f6a26dc0..3f7fb5a07d3 100644 --- a/pkg/skaffold/deploy/helm.go +++ b/pkg/skaffold/deploy/helm.go @@ -161,7 +161,7 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates // Dependency builds should be skipped when trying to install a chart // with local dependencies in the chart folder, e.g. the istio helm chart. // This decision is left to the user. - if !r.SkipBuildDependencies { + if !r.SkipDependencyBuild { // First build dependencies. logrus.Infof("Building helm dependencies...") if err := h.helm(ctx, out, "dep", "build", r.ChartPath); err != nil { diff --git a/pkg/skaffold/deploy/helm_test.go b/pkg/skaffold/deploy/helm_test.go index 2fc007bb152..8aed86203d6 100644 --- a/pkg/skaffold/deploy/helm_test.go +++ b/pkg/skaffold/deploy/helm_test.go @@ -174,12 +174,12 @@ var testDeployWithTemplatedName = &latest.HelmDeploy{ }, } -var testDeploySkipBuildDependencies = &latest.HelmDeploy{ +var testDeploySkipDependencyBuild = &latest.HelmDeploy{ Releases: []latest.HelmRelease{ { - Name: "skaffold-helm", - ChartPath: "stable/chartmuseum", - SkipBuildDependencies: true, + Name: "skaffold-helm", + ChartPath: "stable/chartmuseum", + SkipDependencyBuild: true, }, }, } @@ -187,9 +187,9 @@ var testDeploySkipBuildDependencies = &latest.HelmDeploy{ var testDeployRemoteChart = &latest.HelmDeploy{ Releases: []latest.HelmRelease{ { - Name: "skaffold-helm-remote", - ChartPath: "stable/chartmuseum", - SkipBuildDependencies: false, + Name: "skaffold-helm-remote", + ChartPath: "stable/chartmuseum", + SkipDependencyBuild: false, }, }, } @@ -314,13 +314,13 @@ func TestHelmDeploy(t *testing.T) { shouldErr: true, }, { - description: "deploy success remote chart with skipBuildDependencies", + description: "deploy success remote chart with skipDependencyBuild", cmd: &MockHelm{t: t}, - deployer: NewHelmDeployer(testDeploySkipBuildDependencies, testKubeContext, testNamespace, ""), + deployer: NewHelmDeployer(testDeploySkipDependencyBuild, testKubeContext, testNamespace, ""), builds: testBuilds, }, { - description: "deploy error remote chart without skipBuildDependencies", + description: "deploy error remote chart without skipDependencyBuild", cmd: &MockHelm{ t: t, depResult: fmt.Errorf("unexpected error"), diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 05aafba0d6b..3414896b2dd 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -391,8 +391,8 @@ type HelmRelease struct { // Defaults to `false`. RecreatePods bool `yaml:"recreatePods,omitempty"` - // SkipBuildDependencies should build dependencies be skipped. - SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"` + // SkipDependencyBuild should build dependencies be skipped. + SkipDependencyBuild bool `yaml:"skipDependencyBuild,omitempty"` // Overrides are key-value pairs. // If present, Skaffold will build a Helm `values` file that overrides diff --git a/pkg/skaffold/schema/v1beta4/config.go b/pkg/skaffold/schema/v1beta4/config.go index 6bc194f4816..2de75e2fdb2 100644 --- a/pkg/skaffold/schema/v1beta4/config.go +++ b/pkg/skaffold/schema/v1beta4/config.go @@ -188,20 +188,20 @@ type KustomizeDeploy struct { } type HelmRelease struct { - Name string `yaml:"name,omitempty"` - ChartPath string `yaml:"chartPath,omitempty"` - ValuesFiles []string `yaml:"valuesFiles,omitempty"` - Values map[string]string `yaml:"values,omitempty,omitempty"` - Namespace string `yaml:"namespace,omitempty"` - Version string `yaml:"version,omitempty"` - SetValues map[string]string `yaml:"setValues,omitempty"` - SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` - Wait bool `yaml:"wait,omitempty"` - RecreatePods bool `yaml:"recreatePods,omitempty"` - SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"` - Overrides map[string]interface{} `yaml:"overrides,omitempty"` - Packaged *HelmPackaged `yaml:"packaged,omitempty"` - ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` + Name string `yaml:"name,omitempty"` + ChartPath string `yaml:"chartPath,omitempty"` + ValuesFiles []string `yaml:"valuesFiles,omitempty"` + Values map[string]string `yaml:"values,omitempty,omitempty"` + Namespace string `yaml:"namespace,omitempty"` + Version string `yaml:"version,omitempty"` + SetValues map[string]string `yaml:"setValues,omitempty"` + SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` + Wait bool `yaml:"wait,omitempty"` + RecreatePods bool `yaml:"recreatePods,omitempty"` + SkipDependencyBuild bool `yaml:"skipDependencyBuild,omitempty"` + Overrides map[string]interface{} `yaml:"overrides,omitempty"` + Packaged *HelmPackaged `yaml:"packaged,omitempty"` + ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` } // HelmPackaged represents parameters for packaging helm chart. From 010dabb837e4145c77460ad0ffdd50c64f313eca Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 22 Feb 2019 11:31:49 +1100 Subject: [PATCH 18/22] Update schemas --- docs/content/en/schemas/v1beta4.json | 2 +- docs/content/en/schemas/v1beta5.json | 2 +- integration/examples/helm-deployment-dependencies/skaffold.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/content/en/schemas/v1beta4.json b/docs/content/en/schemas/v1beta4.json index 44db92990b8..20e8e3943e9 100755 --- a/docs/content/en/schemas/v1beta4.json +++ b/docs/content/en/schemas/v1beta4.json @@ -439,7 +439,7 @@ "type": "boolean", "default": "false" }, - "skipBuildDependencies": { + "skipDependencyBuild": { "type": "boolean", "default": "false" }, diff --git a/docs/content/en/schemas/v1beta5.json b/docs/content/en/schemas/v1beta5.json index 881509c2505..c6f715886c8 100755 --- a/docs/content/en/schemas/v1beta5.json +++ b/docs/content/en/schemas/v1beta5.json @@ -576,7 +576,7 @@ "description": "if true, Skaffold will send --recreate-pods flag to Helm CLI.", "default": "false" }, - "skipBuildDependencies": { + "skipDependencyBuild": { "type": "boolean", "description": "should build dependencies be skipped.", "default": "false" diff --git a/integration/examples/helm-deployment-dependencies/skaffold.yaml b/integration/examples/helm-deployment-dependencies/skaffold.yaml index a8cf67765ee..e3626d59234 100644 --- a/integration/examples/helm-deployment-dependencies/skaffold.yaml +++ b/integration/examples/helm-deployment-dependencies/skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1beta4 +apiVersion: skaffold/v1beta5 kind: Config build: tagPolicy: From 0c3202b45520b646528b8fb0b03f8b6c3fee936f Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 9 Mar 2019 11:52:37 +1100 Subject: [PATCH 19/22] Remove v1beta4 change --- pkg/skaffold/schema/v1beta4/config.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pkg/skaffold/schema/v1beta4/config.go b/pkg/skaffold/schema/v1beta4/config.go index 2de75e2fdb2..c2a2c3e3bda 100644 --- a/pkg/skaffold/schema/v1beta4/config.go +++ b/pkg/skaffold/schema/v1beta4/config.go @@ -188,20 +188,19 @@ type KustomizeDeploy struct { } type HelmRelease struct { - Name string `yaml:"name,omitempty"` - ChartPath string `yaml:"chartPath,omitempty"` - ValuesFiles []string `yaml:"valuesFiles,omitempty"` - Values map[string]string `yaml:"values,omitempty,omitempty"` - Namespace string `yaml:"namespace,omitempty"` - Version string `yaml:"version,omitempty"` - SetValues map[string]string `yaml:"setValues,omitempty"` - SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` - Wait bool `yaml:"wait,omitempty"` - RecreatePods bool `yaml:"recreatePods,omitempty"` - SkipDependencyBuild bool `yaml:"skipDependencyBuild,omitempty"` - Overrides map[string]interface{} `yaml:"overrides,omitempty"` - Packaged *HelmPackaged `yaml:"packaged,omitempty"` - ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` + Name string `yaml:"name,omitempty"` + ChartPath string `yaml:"chartPath,omitempty"` + ValuesFiles []string `yaml:"valuesFiles,omitempty"` + Values map[string]string `yaml:"values,omitempty,omitempty"` + Namespace string `yaml:"namespace,omitempty"` + Version string `yaml:"version,omitempty"` + SetValues map[string]string `yaml:"setValues,omitempty"` + SetValueTemplates map[string]string `yaml:"setValueTemplates,omitempty"` + Wait bool `yaml:"wait,omitempty"` + RecreatePods bool `yaml:"recreatePods,omitempty"` + Overrides map[string]interface{} `yaml:"overrides,omitempty"` + Packaged *HelmPackaged `yaml:"packaged,omitempty"` + ImageStrategy HelmImageStrategy `yaml:"imageStrategy,omitempty"` } // HelmPackaged represents parameters for packaging helm chart. From de81c9fbf3fcda29bf8dc0a55dd1777484c7addc Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 9 Mar 2019 11:53:31 +1100 Subject: [PATCH 20/22] Update schemas --- docs/content/en/schemas/v1beta4.json | 5 ----- docs/content/en/schemas/v1beta7.json | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/content/en/schemas/v1beta4.json b/docs/content/en/schemas/v1beta4.json index 1c1171a9e30..d51ec6042e5 100755 --- a/docs/content/en/schemas/v1beta4.json +++ b/docs/content/en/schemas/v1beta4.json @@ -642,10 +642,6 @@ "type": "object", "default": "{}" }, - "skipBuildDependencies": { - "type": "boolean", - "default": "false" - }, "values": { "additionalProperties": { "type": "string" @@ -679,7 +675,6 @@ "setValueTemplates", "wait", "recreatePods", - "skipBuildDependencies", "overrides", "packaged", "imageStrategy" diff --git a/docs/content/en/schemas/v1beta7.json b/docs/content/en/schemas/v1beta7.json index ad789defb44..dae47e58f6f 100755 --- a/docs/content/en/schemas/v1beta7.json +++ b/docs/content/en/schemas/v1beta7.json @@ -1036,7 +1036,7 @@ "x-intellij-html-description": "key-value pairs. If present, Skaffold will send --set flag to Helm CLI and append all pairs after the flag.", "default": "{}" }, - "skipBuildDependencies": { + "skipDependencyBuild": { "type": "boolean", "description": "should build dependencies be skipped.", "x-intellij-html-description": "should build dependencies be skipped.", @@ -1083,7 +1083,7 @@ "setValueTemplates", "wait", "recreatePods", - "skipBuildDependencies", + "skipDependencyBuild", "overrides", "packaged", "imageStrategy" From 14d24f073c1067a28ec3f6c7cfad0a64bfe7a650 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 20 Mar 2019 18:11:49 +1100 Subject: [PATCH 21/22] Revent rename --- docs/content/en/schemas/v1beta7.json | 4 +-- .../helm-deployment-dependencies/README.adoc | 4 +-- .../skaffold.yaml | 2 +- pkg/skaffold/deploy/helm.go | 2 +- pkg/skaffold/deploy/helm_test.go | 28 +++++++++---------- pkg/skaffold/schema/latest/config.go | 4 +-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/content/en/schemas/v1beta7.json b/docs/content/en/schemas/v1beta7.json index dae47e58f6f..ad789defb44 100755 --- a/docs/content/en/schemas/v1beta7.json +++ b/docs/content/en/schemas/v1beta7.json @@ -1036,7 +1036,7 @@ "x-intellij-html-description": "key-value pairs. If present, Skaffold will send --set flag to Helm CLI and append all pairs after the flag.", "default": "{}" }, - "skipDependencyBuild": { + "skipBuildDependencies": { "type": "boolean", "description": "should build dependencies be skipped.", "x-intellij-html-description": "should build dependencies be skipped.", @@ -1083,7 +1083,7 @@ "setValueTemplates", "wait", "recreatePods", - "skipDependencyBuild", + "skipBuildDependencies", "overrides", "packaged", "imageStrategy" diff --git a/integration/examples/helm-deployment-dependencies/README.adoc b/integration/examples/helm-deployment-dependencies/README.adoc index b5383919cc2..9a1cff3e1a1 100644 --- a/integration/examples/helm-deployment-dependencies/README.adoc +++ b/integration/examples/helm-deployment-dependencies/README.adoc @@ -5,7 +5,7 @@ This example follows the link:{github-repo-tree}/examples/helm-deployment-dependencies[helm] example, but with a local chart as a depenency. -The `skipDependencyBuild` option is used to skip the `helm dep build` command. This must be disabled for charts with local dependencies. +The `skipBuildDependencies` option is used to skip the `helm dep build` command. This must be disabled for charts with local dependencies. The image can be passed to the subchart using the standard Helm format of `subchart-name.value`. @@ -16,7 +16,7 @@ deploy: - name: skaffold-helm chartPath: skaffold-helm namespace: skaffold - skipDependencyBuild: true # Skip helm dep build + skipBuildDependencies: true # Skip helm dep build values: image: skaffold-helm "subchart.image": gcr.io/k8s-skaffold/skaffold-helm # Set image for subchart diff --git a/integration/examples/helm-deployment-dependencies/skaffold.yaml b/integration/examples/helm-deployment-dependencies/skaffold.yaml index e3626d59234..c4af62b8002 100644 --- a/integration/examples/helm-deployment-dependencies/skaffold.yaml +++ b/integration/examples/helm-deployment-dependencies/skaffold.yaml @@ -13,7 +13,7 @@ deploy: #wait: true #valuesFiles: #- helm-skaffold-values.yaml - skipDependencyBuild: true # Skip helm dep build + skipBuildDependencies: true # Skip helm dep build values: image: gcr.io/k8s-skaffold/skaffold-helm "skaffold-helm-subchart.image": gcr.io/k8s-skaffold/skaffold-helm diff --git a/pkg/skaffold/deploy/helm.go b/pkg/skaffold/deploy/helm.go index 37fb611e857..2670f934b91 100644 --- a/pkg/skaffold/deploy/helm.go +++ b/pkg/skaffold/deploy/helm.go @@ -185,7 +185,7 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates // Dependency builds should be skipped when trying to install a chart // with local dependencies in the chart folder, e.g. the istio helm chart. // This decision is left to the user. - if !r.SkipDependencyBuild { + if !r.SkipBuildDependencies { // First build dependencies. logrus.Infof("Building helm dependencies...") if err := h.helm(ctx, out, "dep", "build", r.ChartPath); err != nil { diff --git a/pkg/skaffold/deploy/helm_test.go b/pkg/skaffold/deploy/helm_test.go index 5b062229750..7060ac7aecf 100644 --- a/pkg/skaffold/deploy/helm_test.go +++ b/pkg/skaffold/deploy/helm_test.go @@ -88,7 +88,7 @@ var testDeployRecreatePodsConfig = &latest.HelmDeploy{ }, } -var testDeploySkipDependencyBuildConfig = &latest.HelmDeploy{ +var testDeploySkipBuildDependenciesConfig = &latest.HelmDeploy{ Releases: []latest.HelmRelease{ { Name: "skaffold-helm", @@ -102,7 +102,7 @@ var testDeploySkipDependencyBuildConfig = &latest.HelmDeploy{ SetValues: map[string]string{ "some.key": "somevalue", }, - SkipDependencyBuild: true, + SkipBuildDependencies: true, }, }, } @@ -176,12 +176,12 @@ var testDeployWithTemplatedName = &latest.HelmDeploy{ }, } -var testDeploySkipDependencyBuild = &latest.HelmDeploy{ +var testDeploySkipBuildDependencies = &latest.HelmDeploy{ Releases: []latest.HelmRelease{ { - Name: "skaffold-helm", - ChartPath: "stable/chartmuseum", - SkipDependencyBuild: true, + Name: "skaffold-helm", + ChartPath: "stable/chartmuseum", + SkipBuildDependencies: true, }, }, } @@ -189,9 +189,9 @@ var testDeploySkipDependencyBuild = &latest.HelmDeploy{ var testDeployRemoteChart = &latest.HelmDeploy{ Releases: []latest.HelmRelease{ { - Name: "skaffold-helm-remote", - ChartPath: "stable/chartmuseum", - SkipDependencyBuild: false, + Name: "skaffold-helm-remote", + ChartPath: "stable/chartmuseum", + SkipBuildDependencies: false, }, }, } @@ -303,9 +303,9 @@ func TestHelmDeploy(t *testing.T) { builds: testBuilds, }, { - description: "deploy success with skipDependencyBuild", + description: "deploy success with skipBuildDependencies", cmd: &MockHelm{t: t}, - deployer: NewHelmDeployer(testDeploySkipDependencyBuildConfig, testKubeContext, testNamespace, ""), + deployer: NewHelmDeployer(testDeploySkipBuildDependenciesConfig, testKubeContext, testNamespace, ""), builds: testBuilds, }, { @@ -316,13 +316,13 @@ func TestHelmDeploy(t *testing.T) { shouldErr: true, }, { - description: "deploy success remote chart with skipDependencyBuild", + description: "deploy success remote chart with skipBuildDependencies", cmd: &MockHelm{t: t}, - deployer: NewHelmDeployer(testDeploySkipDependencyBuild, testKubeContext, testNamespace, ""), + deployer: NewHelmDeployer(testDeploySkipBuildDependencies, testKubeContext, testNamespace, ""), builds: testBuilds, }, { - description: "deploy error remote chart without skipDependencyBuild", + description: "deploy error remote chart without skipBuildDependencies", cmd: &MockHelm{ t: t, depResult: fmt.Errorf("unexpected error"), diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 0eb4a25219e..4ad233a6338 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -414,8 +414,8 @@ type HelmRelease struct { // Defaults to `false`. RecreatePods bool `yaml:"recreatePods,omitempty"` - // SkipDependencyBuild should build dependencies be skipped. - SkipDependencyBuild bool `yaml:"skipDependencyBuild,omitempty"` + // SkipBuildDependencies should build dependencies be skipped. + SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"` // Overrides are key-value pairs. // If present, Skaffold will build a Helm `values` file that overrides From b2089a23126b6fadc3df4761534eee0ef47283c9 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 20 Mar 2019 18:28:04 +1100 Subject: [PATCH 22/22] Schema, docs, examples updates --- docs/content/en/schemas/v1beta4.json | 5 +++ .../helm-deployment-dependencies/Dockerfile | 1 + .../helm-deployment-dependencies/README.adoc | 25 +++++++++++ .../skaffold-helm/.helmignore | 21 ++++++++++ .../skaffold-helm/Chart.yaml | 4 ++ .../skaffold-helm/charts/subchart/.helmignore | 21 ++++++++++ .../skaffold-helm/charts/subchart/Chart.yaml | 4 ++ .../charts/subchart/templates/_helpers.tpl | 16 +++++++ .../charts/subchart/templates/deployment.yaml | 29 +++++++++++++ .../charts/subchart/templates/ingress.yaml | 32 ++++++++++++++ .../charts/subchart/templates/service.yaml | 19 +++++++++ .../skaffold-helm/charts/subchart/values.yaml | 40 ++++++++++++++++++ .../skaffold-helm/requirements.yaml | 3 ++ .../skaffold-helm/templates/_helpers.tpl | 16 +++++++ .../skaffold-helm/templates/deployment.yaml | 29 +++++++++++++ .../skaffold-helm/templates/ingress.yaml | 32 ++++++++++++++ .../skaffold-helm/templates/service.yaml | 19 +++++++++ .../skaffold-helm/values.yaml | 42 +++++++++++++++++++ .../skaffold.yaml | 28 +++++++++++++ pkg/skaffold/deploy/helm_test.go | 4 +- 20 files changed, 387 insertions(+), 3 deletions(-) create mode 100644 examples/helm-deployment-dependencies/Dockerfile create mode 100644 examples/helm-deployment-dependencies/README.adoc create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/.helmignore create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold-helm/values.yaml create mode 100644 examples/helm-deployment-dependencies/skaffold.yaml diff --git a/docs/content/en/schemas/v1beta4.json b/docs/content/en/schemas/v1beta4.json index 66a789c4a8a..fe667fd6725 100755 --- a/docs/content/en/schemas/v1beta4.json +++ b/docs/content/en/schemas/v1beta4.json @@ -638,6 +638,10 @@ "type": "object", "default": "{}" }, + "skipBuildDependencies": { + "type": "boolean", + "default": "false" + }, "values": { "additionalProperties": { "type": "string" @@ -671,6 +675,7 @@ "setValueTemplates", "wait", "recreatePods", + "skipBuildDependencies", "overrides", "packaged", "imageStrategy" diff --git a/examples/helm-deployment-dependencies/Dockerfile b/examples/helm-deployment-dependencies/Dockerfile new file mode 100644 index 00000000000..75eca2cb8ef --- /dev/null +++ b/examples/helm-deployment-dependencies/Dockerfile @@ -0,0 +1 @@ +FROM nginx:stable diff --git a/examples/helm-deployment-dependencies/README.adoc b/examples/helm-deployment-dependencies/README.adoc new file mode 100644 index 00000000000..9a1cff3e1a1 --- /dev/null +++ b/examples/helm-deployment-dependencies/README.adoc @@ -0,0 +1,25 @@ +=== Example: helm-dependencies +:icons: font + +==== Deploy helm charts with local dependencies + +This example follows the link:{github-repo-tree}/examples/helm-deployment-dependencies[helm] example, but with a local chart as a depenency. + +The `skipBuildDependencies` option is used to skip the `helm dep build` command. This must be disabled for charts with local dependencies. + +The image can be passed to the subchart using the standard Helm format of `subchart-name.value`. + +``` +deploy: + helm: + releases: + - name: skaffold-helm + chartPath: skaffold-helm + namespace: skaffold + skipBuildDependencies: true # Skip helm dep build + values: + image: skaffold-helm + "subchart.image": gcr.io/k8s-skaffold/skaffold-helm # Set image for subchart + valuesFiles: + - helm-values-file.yaml +``` diff --git a/examples/helm-deployment-dependencies/skaffold-helm/.helmignore b/examples/helm-deployment-dependencies/skaffold-helm/.helmignore new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml b/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml new file mode 100644 index 00000000000..f4fcfadbec9 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: skaffold-helm +version: 0.1.0 diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml new file mode 100644 index 00000000000..3879caeaabd --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: subchart +version: 0.1.0 diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl new file mode 100644 index 00000000000..7ced0ae3253 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "subchart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "subchart.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml new file mode 100644 index 00000000000..f3075de53e3 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "subchart.name" . }} + labels: + app: {{ template "subchart.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "subchart.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} + imagePullPolicy: {{ .Values.pullPolicy }} + command: ["/bin/bash", "-c", "--" ] + args: ["while true; do sleep 30; done;"] + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml new file mode 100644 index 00000000000..127987f69d9 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "subchart.fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "subchart.fullname" . }} + labels: + app: {{ template "subchart.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml new file mode 100644 index 00000000000..80bb3759b95 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "subchart.fullname" . }} + labels: + app: {{ template "subchart.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 }} + selector: + app: {{ template "subchart.name" . }} + release: {{ .Release.Name }} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml new file mode 100644 index 00000000000..e930d90bd76 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/charts/subchart/values.yaml @@ -0,0 +1,40 @@ +# Default values for skaffold-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +nameOverride: "subchart" +replicaCount: 1 +image: nginx:stable +# This is the helm convention on declaring images +# image: +# repository: nginx +# tag: stable +# pullPolicy: IfNotPresent +service: + name: nginx + type: ClusterIP + externalPort: 80 + internalPort: 80 +ingress: + enabled: false + # Used to create an Ingress record. + hosts: + - chart-example.local + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + # Secrets must be manually created in the namespace. + # - 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 + # 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 diff --git a/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml b/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml new file mode 100644 index 00000000000..14601dde3a6 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/requirements.yaml @@ -0,0 +1,3 @@ +dependencies: + - name: subchart + condition: subchart.enabled diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl b/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl new file mode 100644 index 00000000000..537a7399829 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "skaffold-helm.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "skaffold-helm.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml b/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml new file mode 100644 index 00000000000..02b76c5ec04 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/templates/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "skaffold-helm.name" . }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "skaffold-helm.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} + imagePullPolicy: {{ .Values.pullPolicy }} + command: ["/bin/bash", "-c", "--" ] + args: ["while true; do sleep 30; done;"] + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml b/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml new file mode 100644 index 00000000000..87fe1e813e6 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "skaffold-helm.fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml b/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml new file mode 100644 index 00000000000..da7b3ef867b --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.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 }} + selector: + app: {{ template "skaffold-helm.name" . }} + release: {{ .Release.Name }} diff --git a/examples/helm-deployment-dependencies/skaffold-helm/values.yaml b/examples/helm-deployment-dependencies/skaffold-helm/values.yaml new file mode 100644 index 00000000000..49dfad48c72 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold-helm/values.yaml @@ -0,0 +1,42 @@ +# Default values for skaffold-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +image: nginx:stable +# This is the helm convention on declaring images +# image: +# repository: nginx +# tag: stable +# pullPolicy: IfNotPresent +service: + name: nginx + type: ClusterIP + externalPort: 80 + internalPort: 80 +ingress: + enabled: false + # Used to create an Ingress record. + hosts: + - chart-example.local + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + # Secrets must be manually created in the namespace. + # - 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 + # 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 + +subchart: + enabled: true diff --git a/examples/helm-deployment-dependencies/skaffold.yaml b/examples/helm-deployment-dependencies/skaffold.yaml new file mode 100644 index 00000000000..c4af62b8002 --- /dev/null +++ b/examples/helm-deployment-dependencies/skaffold.yaml @@ -0,0 +1,28 @@ +apiVersion: skaffold/v1beta5 +kind: Config +build: + tagPolicy: + sha256: {} + artifacts: + - image: gcr.io/k8s-skaffold/skaffold-helm +deploy: + helm: + releases: + - name: skaffold-helm + chartPath: skaffold-helm + #wait: true + #valuesFiles: + #- helm-skaffold-values.yaml + skipBuildDependencies: true # Skip helm dep build + values: + image: gcr.io/k8s-skaffold/skaffold-helm + "skaffold-helm-subchart.image": gcr.io/k8s-skaffold/skaffold-helm + #recreatePods will pass --recreate-pods to helm upgrade + #recreatePods: true + #overrides builds an override values.yaml file to run with the helm deploy + #overrides: + # some: + # key: someValue + #setValues get appended to the helm deploy with --set. + #setValues: + #some.key: someValue diff --git a/pkg/skaffold/deploy/helm_test.go b/pkg/skaffold/deploy/helm_test.go index b7bff79345e..54edbcd471e 100644 --- a/pkg/skaffold/deploy/helm_test.go +++ b/pkg/skaffold/deploy/helm_test.go @@ -93,9 +93,7 @@ var testDeploySkipBuildDependenciesConfig = &latest.HelmDeploy{ Values: map[string]string{ "image": "skaffold-helm", }, - Overrides: map[string]interface{}{ - "foo": "bar", - }, + Overrides: schemautil.HelmOverrides{map[string]interface{}{"foo": "bar"}}, SetValues: map[string]string{ "some.key": "somevalue", },