Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ #1379 | Bug fix for Helm imageStrategy file sync #2111

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/helm-deployment-hot-reload/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skaffold-helm
*.swp
3 changes: 3 additions & 0 deletions examples/helm-deployment-hot-reload/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx:stable

COPY static /usr/share/nginx/html/
21 changes: 21 additions & 0 deletions examples/helm-deployment-hot-reload/skaffold-helm/.helmignore
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions examples/helm-deployment-hot-reload/skaffold-helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
description: A Helm chart for Kubernetes
name: skaffold-helm
version: 0.1.0
Original file line number Diff line number Diff line change
@@ -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 -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ .Release.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.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.internalPort }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- 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:
{{- if .Values.ingress.hosts }}
{{- range $host := .Values.ingress.hosts }}
- host: {{ $host }}
http:
paths:
- path: /
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end -}}
{{- else }}
- http:
paths:
- path: /
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -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 }}
38 changes: 38 additions & 0 deletions examples/helm-deployment-hot-reload/skaffold-helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Default values for skaffold-helm.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
# 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: true
# 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
31 changes: 31 additions & 0 deletions examples/helm-deployment-hot-reload/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: skaffold/v1beta11
kind: Config
build:
artifacts:
- image: gcr.io/k8s-skaffold/skaffold-helm-hot-reload
sync:
manual:
- src: 'static/**/*.*'
dest: '/usr/share/nginx/html'
strip: static/
deploy:
helm:
releases:
- name: skaffold-helm
chartPath: skaffold-helm
#wait: true
#valuesFiles:
#- helm-skaffold-values.yaml
values:
image: gcr.io/k8s-skaffold/skaffold-helm-hot-reload
#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
imageStrategy:
helm: {}
9 changes: 9 additions & 0 deletions examples/helm-deployment-hot-reload/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html lang="en">
<head>
<title>Skaffold Helm</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
6 changes: 6 additions & 0 deletions examples/helm-deployment-hot-reload/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
h1 {
color: #27aedb;
text-align: center;
margin-top: 40vh;
font-size: 120pt;
}
2 changes: 1 addition & 1 deletion pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates
if err != nil {
return nil, errors.Wrapf(err, "cannot parse the docker image reference %s", v.Tag)
}
imageRepositoryTag := fmt.Sprintf("%s.repository=%s,%s.tag=%s", k, dockerRef.BaseName, k, dockerRef.Tag)
imageRepositoryTag := fmt.Sprintf("%s.repository=%s,%s.tag=%s", k, dockerRef.BaseName, k, extractTag(v.Tag))
setOpts = append(setOpts, imageRepositoryTag)
} else {
setOpts = append(setOpts, fmt.Sprintf("%s=%s", k, v.Tag))
Expand Down