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

Update examples #2343

Merged
merged 2 commits into from
Jun 26, 2019
Merged
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: 1 addition & 1 deletion examples/google-cloud-build/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: skaffold/v1beta8
apiVersion: skaffold/v1beta11
kind: Config
build:
googleCloudBuild:
Expand Down
2 changes: 1 addition & 1 deletion examples/helm-deployment-dependencies/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: skaffold/v1beta5
apiVersion: skaffold/v1beta11
kind: Config
build:
tagPolicy:
Expand Down
2 changes: 1 addition & 1 deletion integration/examples/google-cloud-build/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: skaffold/v1beta8
apiVersion: skaffold/v1beta12
kind: Config
build:
googleCloudBuild:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: skaffold/v1beta5
apiVersion: skaffold/v1beta12
kind: Config
build:
tagPolicy:
Expand Down
29 changes: 0 additions & 29 deletions integration/examples/helm-deployment/skaffold-int.yaml

This file was deleted.

9 changes: 3 additions & 6 deletions integration/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,19 @@ func TestHelmDeploy(t *testing.T) {
t.Skip("skipping gcp only test")
}

helmDir := "examples/helm-deployment"
helmDir := "testdata/helm"

ns, client, deleteNs := SetupNamespace(t)
// To fix #1823, we make use of env variable templating for release name
env := []string{fmt.Sprintf("TEST_NS=%s", ns.Name)}
depName := fmt.Sprintf("skaffold-helm-%s", ns.Name)
// Please make sure to make the same changes in skaffold.yaml if you make
// any changes to skaffold-int.yaml
overrideConfigArgs := []string{"-f", "skaffold-int.yaml"}

defer func() {
skaffold.Delete(overrideConfigArgs...).InDir(helmDir).InNs(ns.Name).WithEnv(env).RunOrFail(t)
skaffold.Delete().InDir(helmDir).InNs(ns.Name).WithEnv(env).RunOrFail(t)
deleteNs()
}()

runArgs := append(overrideConfigArgs, "--images", "gcr.io/k8s-skaffold/skaffold-helm")
runArgs := []string{"--images", "gcr.io/k8s-skaffold/skaffold-helm"}

skaffold.Deploy(runArgs...).InDir(helmDir).InNs(ns.Name).WithEnv(env).RunOrFailOutput(t)

Expand Down
2 changes: 2 additions & 0 deletions integration/testdata/helm/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skaffold-helm
*.swp
3 changes: 3 additions & 0 deletions integration/testdata/helm/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 integration/testdata/helm/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 integration/testdata/helm/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
16 changes: 16 additions & 0 deletions integration/testdata/helm/skaffold-helm/templates/_helpers.tpl
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 -}}
29 changes: 29 additions & 0 deletions integration/testdata/helm/skaffold-helm/templates/deployment.yaml
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 }}
imagePullPolicy: {{ .Values.pullPolicy }}
ports:
- containerPort: {{ .Values.service.internalPort }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
41 changes: 41 additions & 0 deletions integration/testdata/helm/skaffold-helm/templates/ingress.yaml
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 -}}
19 changes: 19 additions & 0 deletions integration/testdata/helm/skaffold-helm/templates/service.yaml
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 }}
39 changes: 39 additions & 0 deletions integration/testdata/helm/skaffold-helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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: 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This config should be used for running integration tests purpose only.
# Please use to skaffold.yaml to run this example
apiVersion: skaffold/v1beta10
kind: Config
build:
Expand Down
9 changes: 9 additions & 0 deletions integration/testdata/helm/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 integration/testdata/helm/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;
}