Skip to content

Commit 7561d85

Browse files
committed
added blue-green pattern example
1 parent b5aedb6 commit 7561d85

10 files changed

Lines changed: 286 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v2
2+
name: nearbycicdexample
3+
description: "This example shows some of the CD capabilities available in Nearby One"
4+
type: application
5+
version: v15-bluegreen
6+
appVersion: 15
7+
maintainers:
8+
- name: Devel Team
9+
email: devel@nearbycomputing.com
10+
url: nearbycomputing.com
11+
keywords:
12+
# categories
13+
- CI/CD
14+
icon: https://blocklogos.s3.eu-west-1.amazonaws.com/nearbycomputing.png
15+
deprecated: false
16+
annotations:
17+
vendor: Nearby Computing
18+
displayName: Continuous Delivery (CD) Example
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
deployments:
2+
nginx:
3+
variables:
4+
appname: nginx
5+
imagePullSecret:
6+
enabled: false
7+
create: false
8+
name: nginx-image-secret
9+
rolloutStrategy:
10+
enabled: true
11+
crontab:
12+
- schedule: "* * * * *"
13+
timeZone: UTC
14+
values:
15+
service:
16+
type: ErrorPort
17+
port: 80
18+
httpsPort: 443
19+
nodePorts:
20+
http: "31088"
21+
https: "31843"
22+
configuration:
23+
chart:
24+
name: nginx
25+
baseRegistryUrl: registry.nearbycomputing.com
26+
repo: chartrepo/cicd
27+
version: ~15
28+
auth:
29+
enabled: false
30+
31+
32+
placement:
33+
test:
34+
site:
35+
label: a969608c-be2a-43bd-a223-de092c6af813
36+
production:
37+
site:
38+
label: f1d4c81d-47c4-42a9-9ee1-86a56ebd8a2d
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{- define "imagePullSecret" }}
2+
{{- with .Values.deployments.nginx.configuration.chart.auth }}
3+
{{- printf "{\"auths\":{\"https://%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" $.Values.deployments.nginx.variables.images.nginx.repo .username .password .email (printf "%s:%s" .username .password | b64enc) | b64enc }}
4+
{{- end }}
5+
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.deployments.secretCreator.configuration.chart.auth.enabled }}
2+
3+
apiVersion: v1
4+
kind: Secret
5+
metadata:
6+
name: {{ .Values.deployments.secretCreator.configuration.chart.auth.secret.name }}
7+
namespace: {{ .Values.Block.InstanceId }}
8+
type: Opaque
9+
stringData:
10+
{{ .Values.deployments.secretCreator.configuration.chart.auth.secret.key }}: {{ .Values.deployments.secretCreator.configuration.chart.auth.password }}
11+
12+
{{- end }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{- if .Values.deployments.nginx.variables.imagePullSecret.enabled }}
2+
{{- if .Values.deployments.nginx.variables.imagePullSecret.create }}
3+
4+
apiVersion: blocks/v1beta1
5+
kind: ChartDeployment
6+
metadata:
7+
name: {{ .Values.deployments.nginx.variables.appname }}-{{ .Values.Block.InstanceId }}
8+
namespace: {{ .Values.Block.InstanceId }}
9+
spec:
10+
template:
11+
metadata:
12+
labels:
13+
application: {{ .Values.deployments.nginx.variables.appname }}-{{ .Values.Block.InstanceId }}
14+
spec:
15+
k8sClusterSelector:
16+
matchLabels:
17+
site.nbycomp.com/{{ .Values.placement.site.label }}: "true"
18+
chart: {{ .Values.deployments.secretCreator.configuration.chart.name }}
19+
version: {{ .Values.deployments.secretCreator.configuration.chart.version }}
20+
repo:
21+
url: https://{{ .Values.deployments.secretCreator.configuration.chart.baseRegistryUrl }}/{{ .Values.deployments.secretCreator.configuration.chart.repo }}
22+
username: {{ .Values.deployments.secretCreator.configuration.chart.auth.username | quote }}
23+
password:
24+
secretKeyRef:
25+
name: {{ .Values.deployments.secretCreator.configuration.chart.auth.secret.name }}
26+
key: {{ .Values.deployments.secretCreator.configuration.chart.auth.secret.key }}
27+
values: |
28+
secrets:
29+
- name: {{ .Values.deployments.nginx.variables.imagePullSecret.name }}
30+
namespace: {{ .Values.deployments.nginx.variables.overrideNamespace | default .Release.Namespace }}
31+
type: data
32+
dockerconfigjson: {{ template "imagePullSecret" . }}
33+
{{- end }}
34+
{{- end }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
apiVersion: blocks/v1beta1
2+
kind: ChartDeployment
3+
metadata:
4+
name: {{ .Values.deployments.nginx.variables.appname }}-prod
5+
{{- if .Values.deployments.nginx.variables.overrideNamespace }}
6+
namespace: {{ .Values.deployments.nginx.variables.overrideNamespace }}
7+
{{- else }}
8+
namespace: {{ .Values.Block.InstanceId }}
9+
{{- end }}
10+
spec:
11+
connectionListSelectors:
12+
validatedVersions:
13+
requires: 1
14+
limit: 1
15+
matchLabels:
16+
application: {{ .Values.deployments.nginx.variables.appname }}
17+
block: {{ .Values.Block.InstanceId }}
18+
kind: blueGrenValidation
19+
template:
20+
metadata:
21+
labels:
22+
application: {{ .Values.deployments.nginx.variables.appname }}
23+
block: {{ .Values.Block.InstanceId }}
24+
type: production
25+
spec:
26+
k8sClusterSelector:
27+
matchLabels:
28+
site.nbycomp.com/{{ .Values.placement.production.site.label }}: "true"
29+
chart: {{ .Values.deployments.nginx.configuration.chart.name }}
30+
version: {{ .Values.deployments.nginx.configuration.chart.version | quote }}
31+
{{- if .Values.deployments.nginx.variables.rolloutStrategy.enabled }}
32+
rolloutStrategy:
33+
crontab:
34+
{{ toYaml .Values.deployments.nginx.variables.rolloutStrategy.crontab | indent 10 }}
35+
{{- end }}
36+
repo:
37+
url: https://{{ .Values.deployments.nginx.configuration.chart.baseRegistryUrl }}/{{ .Values.deployments.nginx.configuration.chart.repo }}
38+
{{- if .Values.deployments.nginx.configuration.chart.auth.enabled }}
39+
username: {{ .Values.deployments.nginx.configuration.chart.auth.username | quote }}
40+
password:
41+
secretKeyRef:
42+
name: {{ .Values.deployments.nginx.configuration.chart.auth.secret.name }}
43+
key: {{ .Values.deployments.nginx.configuration.chart.auth.secret.key }}
44+
{{- end }}
45+
values: |
46+
{{ toYaml .Values.deployments.nginx.variables.values | indent 8 }}
47+
podLabels:
48+
CICDvalidatedVersion: {{`{{ .Connections.validatedVersions.latestValidatedVersion }}`}}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: blocks/v1beta1
2+
kind: ChartDeployment
3+
metadata:
4+
name: {{ .Values.deployments.nginx.variables.appname }}-test
5+
{{- if .Values.deployments.nginx.variables.overrideNamespace }}
6+
namespace: {{ .Values.deployments.nginx.variables.overrideNamespace }}
7+
{{- else }}
8+
namespace: {{ .Values.Block.InstanceId }}
9+
{{- end }}
10+
spec:
11+
template:
12+
metadata:
13+
labels:
14+
application: {{ .Values.deployments.nginx.variables.appname }}
15+
block: {{ .Values.Block.InstanceId }}
16+
type: test
17+
spec:
18+
k8sClusterSelector:
19+
matchLabels:
20+
site.nbycomp.com/{{ .Values.placement.test.site.label }}: "true"
21+
chart: {{ .Values.deployments.nginx.configuration.chart.name }}
22+
version: {{ .Values.deployments.nginx.configuration.chart.version | quote }}
23+
{{- if .Values.deployments.nginx.variables.rolloutStrategy.enabled }}
24+
rolloutStrategy:
25+
crontab:
26+
{{ toYaml .Values.deployments.nginx.variables.rolloutStrategy.crontab | indent 10 }}
27+
{{- end }}
28+
repo:
29+
url: https://{{ .Values.deployments.nginx.configuration.chart.baseRegistryUrl }}/{{ .Values.deployments.nginx.configuration.chart.repo }}
30+
{{- if .Values.deployments.nginx.configuration.chart.auth.enabled }}
31+
username: {{ .Values.deployments.nginx.configuration.chart.auth.username | quote }}
32+
password:
33+
secretKeyRef:
34+
name: {{ .Values.deployments.nginx.configuration.chart.auth.secret.name }}
35+
key: {{ .Values.deployments.nginx.configuration.chart.auth.secret.key }}
36+
{{- end }}
37+
values: |
38+
{{ toYaml .Values.deployments.nginx.variables.values | indent 8 }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.deployments.nginx.configuration.chart.auth.enabled }}
2+
3+
apiVersion: v1
4+
kind: Secret
5+
metadata:
6+
name: {{ .Values.deployments.nginx.configuration.chart.auth.secret.name }}
7+
{{- if .Values.deployments.nginx.variables.overrideNamespace }}
8+
namespace: {{ .Values.deployments.nginx.variables.overrideNamespace }}
9+
{{- else }}
10+
namespace: {{ .Values.Block.InstanceId }}
11+
{{- end }}
12+
type: Opaque
13+
stringData:
14+
{{ .Values.deployments.nginx.configuration.chart.auth.secret.key }}: {{ .Values.deployments.nginx.configuration.chart.auth.password }}
15+
16+
{{- end }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: blocks/v1beta1
2+
kind: ConnectionSet
3+
metadata:
4+
name: test-ready-{{ .Values.Block.InstanceId }}
5+
spec:
6+
targetListSelector:
7+
kind: ChartRelease
8+
matchLabels:
9+
application: {{ .Values.deployments.nginx.variables.appname }}
10+
block: {{ .Values.Block.InstanceId }}
11+
type: test
12+
template:
13+
metadata:
14+
labels:
15+
application: {{ .Values.deployments.nginx.variables.appname }}
16+
block: {{ .Values.Block.InstanceId }}
17+
kind: blueGrenValidation
18+
spec:
19+
value: |
20+
latestValidatedVersion: {{`{{ .Target.status.installedChartVersion }}`}}
21+
22+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Block:
2+
InstanceId: 12345678-9012-3456-7890-123456789012
3+
4+
deployments:
5+
nginx:
6+
variables:
7+
appname: nginx
8+
imagePullSecret:
9+
enabled: false
10+
create: false
11+
name: nginx-image-secret
12+
rolloutStrategy:
13+
enbaled: true
14+
crontab:
15+
- schedule: "0 3 * * *"
16+
timeZone: UTC
17+
configuration:
18+
chart:
19+
name: nginx
20+
baseRegistryUrl: registry.nearbycomputing.com
21+
repo: chartrepo/cicd
22+
version: "15.0"
23+
auth:
24+
enabled: true
25+
username: robot$pocs
26+
password: juGCRixi3lw6fMMQtePiEgQZ4qweao0B
27+
secret:
28+
name: pullsecret-etcd
29+
key: secretKey
30+
31+
32+
secretCreator:
33+
variables:
34+
appname: secret-manager
35+
configuration:
36+
chart:
37+
version: 0.0.1
38+
name: secret-creator
39+
baseRegistryUrl: registry.nearbycomputing.com
40+
repo: chartrepo/apps
41+
auth:
42+
enabled: false
43+
username: robot$pocs
44+
password: juGCRixi3lw6fMMQtePiEgQZ4qweao0B
45+
secret:
46+
name: pullsecret-secret-injector-chart
47+
key: secretKey
48+
49+
placement:
50+
test:
51+
site:
52+
label: placeholder
53+
production:
54+
site:
55+
label: placeholder

0 commit comments

Comments
 (0)