Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit cff1989

Browse files
committed
adding bluegreen
1 parent 39bfd33 commit cff1989

File tree

8 files changed

+232
-0
lines changed

8 files changed

+232
-0
lines changed

charts/bluegreen/.helmignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/bluegreen/Chart.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: bluegreen
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "bluegreen.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "bluegreen.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "bluegreen.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "bluegreen.labels" -}}
37+
helm.sh/chart: {{ include "bluegreen.chart" . }}
38+
{{ include "bluegreen.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "bluegreen.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "bluegreen.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "bluegreen.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "bluegreen.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This example demonstrates a Rollout using the blue-green update strategy, which contains a manual
2+
# gate before promoting the new stack.
3+
apiVersion: argoproj.io/v1alpha1
4+
kind: Rollout
5+
metadata:
6+
name: {{ include "bluegreen.name" . }}
7+
namespace: {{ include "bluegreen.name" . }}
8+
annotations:
9+
argocd.argoproj.io/sync-wave: "2"
10+
spec:
11+
replicas: {{ .Values.replicaCount }}
12+
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
13+
selector:
14+
matchLabels:
15+
app: {{ include "bluegreen.name" . }}
16+
template:
17+
metadata:
18+
labels:
19+
app: {{ include "bluegreen.name" . }}
20+
spec:
21+
containers:
22+
- name: {{ .Values.containers.name }}
23+
image: {{ .Values.global.rollout.image }}
24+
imagePullPolicy: {{ .Values.image.pullPolicy }}
25+
ports:
26+
- containerPort: {{ .Values.containers.containerPort }}
27+
strategy:
28+
blueGreen:
29+
# activeService specifies the service to update with the new template hash at time of promotion.
30+
# This field is mandatory for the blueGreen update strategy.
31+
activeService: {{ include "bluegreen.name" . }}-active
32+
# previewService specifies the service to update with the new template hash before promotion.
33+
# This allows the preview stack to be reachable without serving production traffic.
34+
# This field is optional.
35+
previewService: {{ include "bluegreen.name" . }}-preview
36+
# autoPromotionEnabled disables automated promotion of the new stack by pausing the rollout
37+
# immediately before the promotion. If omitted, the default behavior is to promote the new
38+
# stack as soon as the ReplicaSet are completely ready/available.
39+
# Rollouts can be resumed using: `kubectl argo rollouts promote ROLLOUT`
40+
autoPromotionEnabled: {{ .Values.strategy.blueGreen.autoPromotionEnabled }}
41+

charts/bluegreen/templates/route.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- range .Values.bluegreen }}
2+
---
3+
apiVersion: route.openshift.io/v1
4+
kind: Route
5+
metadata:
6+
labels:
7+
app: {{ $.Chart.Name }}-{{ .name }}
8+
name: {{ $.Chart.Name }}-{{ .name }}
9+
annotations:
10+
argocd.argoproj.io/sync-wave: "3"
11+
spec:
12+
port:
13+
targetPort: {{ $.Values.route.targetPort }}
14+
to:
15+
kind: {{ $.Values.route.kind }}
16+
name: {{ $.Chart.Name }}-{{ .name }}
17+
weight: {{ $.Values.route.weight }}
18+
wildcardPolicy: {{ $.Values.route.wildcardPolicy | default "None" }}
19+
{{- end }}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- range .Values.bluegreen }}
2+
---
3+
kind: Service
4+
apiVersion: v1
5+
metadata:
6+
name: {{ $.Chart.Name }}-{{ .name }}
7+
annotations:
8+
argocd.argoproj.io/sync-wave: "1"
9+
spec:
10+
selector:
11+
app: {{ $.Chart.Name }}
12+
ports:
13+
- protocol: {{ $.Values.service.protocol }}
14+
port: {{ $.Values.service.port }}
15+
targetPort: {{ $.Values.service.targetPort }}
16+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: "{{ include "bluegreen.fullname" . }}-test-connection"
5+
labels:
6+
{{- include "bluegreen.labels" . | nindent 4 }}
7+
annotations:
8+
"helm.sh/hook": test
9+
spec:
10+
containers:
11+
- name: wget
12+
image: busybox
13+
command: ['wget']
14+
args: ['{{ include "bluegreen.fullname" . }}:{{ .Values.service.port }}']
15+
restartPolicy: Never

charts/bluegreen/values.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
global:
2+
rollout:
3+
image: argoproj/rollouts-demo:blue
4+
5+
replicaCount: 2
6+
revisionHistoryLimit: 2
7+
8+
bluegreen:
9+
- name: active
10+
- name: preview
11+
12+
image:
13+
pullPolicy: Always
14+
15+
containers:
16+
name: bluegreen-demo
17+
containerPort: 8080
18+
19+
strategy:
20+
blueGreen:
21+
autoPromotionEnabled: false
22+
23+
service:
24+
protocol: TCP
25+
port: 80
26+
targetPort: 8080
27+
28+
route:
29+
kind: Service
30+
weight: 100
31+
targetPort: 8080
32+
wildcardPolicy: None

0 commit comments

Comments
 (0)