Skip to content

Commit

Permalink
feat: Introduce appName for canary deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
colinjfw committed Sep 2, 2019
1 parent 272df83 commit 6538c4c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions charts/app/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Expand the name of the chart.
*/}}
{{- define "app.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- default .Chart.Name .Values.appName | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Expand All @@ -15,7 +15,7 @@ If release name contains chart name it will be used as a full name.
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- $name := default .Chart.Name .Values.appName -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
Expand Down
4 changes: 4 additions & 0 deletions charts/app/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ spec:
protocol: TCP
name: http
selector:
{{- if .Values.appName }}
app.kubernetes.io/name: {{ .Values.appName }}
{{- else }}
app.kubernetes.io/name: {{ include "app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- end }}
7 changes: 6 additions & 1 deletion charts/app/values.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# replicaCount -- Replica count for deployments.
replicaCount: 1

# appname -- Application name. Set this value to use canary deploys.
# Keep this value consistent between canary deploys, if the stable release name
# is prod-myapp-stable and the canary release name is prod-myapp-canary, then
# the appName should be prod-myapp. The service will use this as the selector.
appName: ""

image:
repository: nginx
tag: latest
pullPolicy: IfNotPresent

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

service:
Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ async function run() {
await status("pending");

const track = getInput("track") || "stable";
const release = releaseName(getInput("release", required), track);
const appName = getInput("release", required);
const release = releaseName(appName, track);
const namespace = getInput("namespace", required);
const chart = chartName(getInput("chart", required));
const values = getValues(getInput("values"));
Expand All @@ -150,6 +151,7 @@ async function run() {

core.debug(`param: track = "${track}"`);
core.debug(`param: release = "${release}"`);
core.debug(`param: appName = "${appName}"`);
core.debug(`param: namespace = "${namespace}"`);
core.debug(`param: chart = "${chart}"`);
core.debug(`param: values = "${values}"`);
Expand All @@ -169,7 +171,8 @@ async function run() {
"--wait",
"--atomic",
`--namespace=${namespace}`,
"--values=./values.yml"
"--values=./values.yml",
`--set=appName=${appName}`,
];
if (dryRun) args.push("--dry-run");
if (version) args.push(`--set=version=${version}`);
Expand Down

0 comments on commit 6538c4c

Please sign in to comment.