Skip to content

Commit e35a439

Browse files
committed
upkeep: migrert canary hit
Levde før i helm-charts repoet, med manuell oppdatering av image.
1 parent 1b64a68 commit e35a439

File tree

9 files changed

+247
-1
lines changed

9 files changed

+247
-1
lines changed

.github/workflows/master.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ jobs:
2626
- hookd
2727
- deploy
2828
- deployd
29-
- canary-deployer
29+
- deploy-canary
3030
- deploy-action
3131
include:
3232
- component: hookd
3333
chart: true
3434
- component: deployd
3535
chart: true
36+
- component: deploy-canary
37+
chart: true
3638
steps:
3739
- uses: actions/checkout@v4 # ratchet:exclude
3840
- uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # ratchet:azure/setup-helm@v3

charts/deploy-canary/.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/deploy-canary/Chart.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: deploy-canary
3+
sources:
4+
- https://github.com/nais/helm-charts/tree/main/features/deploy-canary
5+
description: Canary component of the nais deploy system
6+
type: application
7+
version: 0.1.2

charts/deploy-canary/Feature.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
dependencies:
2+
- allOf:
3+
- hookd
4+
- nais-verification
5+
environmentKinds:
6+
- management
7+
values:
8+
ignoredClusters:
9+
config:
10+
type: string_array
11+
clusters:
12+
description: List of clusters to deploy the canary image into
13+
computed:
14+
template: |
15+
{{- $ignored := .Configs.ignoredClusters}}
16+
{{- range eachOf .Envs "name" }}
17+
{{- if not (has . $ignored) }}
18+
- {{ . }}
19+
{{- end }}
20+
{{- end }}
21+
deploy_server:
22+
description: Deploy server host:port pair
23+
displayName: Deploy server
24+
computed:
25+
template: '"{{ subdomain . "deploy" }}:443"'
26+
image.imagePullPolicy:
27+
config:
28+
type: string
29+
image.repository:
30+
config:
31+
type: string
32+
image.tag:
33+
config:
34+
type: string
35+
timeout:
36+
description: How much time the deploy system is allowed to use per deploy
37+
config:
38+
type: string
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Canary deployer is a CronJob that tries to use NAIS deploy to deploy a canary image to a set of clusters.
2+
3+
The monitoring system reads metrics from the canary image, and can tell if the deploy system is lagging.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "deploycanary.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 "deploycanary.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 "deploycanary.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "deploycanary.labels" -}}
37+
app: {{ include "deploycanary.name" . }}
38+
helm.sh/chart: {{ include "deploycanary.chart" . }}
39+
{{ include "deploycanary.selectorLabels" . }}
40+
app.kubernetes.io/managed-by: {{ .Release.Service }}
41+
{{- end }}
42+
43+
{{/*
44+
Selector labels
45+
*/}}
46+
{{- define "deploycanary.selectorLabels" -}}
47+
app.kubernetes.io/name: {{ include "deploycanary.name" . }}
48+
app.kubernetes.io/instance: {{ .Release.Name }}
49+
{{- end }}
50+
51+
{{/*
52+
Create the name of the service account to use
53+
*/}}
54+
{{- define "deploycanary.serviceAccountName" -}}
55+
{{- if .Values.serviceAccount.create }}
56+
{{- default (include "deploycanary.fullname" .) .Values.serviceAccount.name }}
57+
{{- else }}
58+
{{- default "default" .Values.serviceAccount.name }}
59+
{{- end }}
60+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
apiVersion: batch/v1
3+
kind: CronJob
4+
metadata:
5+
name: {{ include "deploycanary.name" . }}
6+
labels:
7+
{{- include "deploycanary.labels" . | nindent 4 }}
8+
spec:
9+
schedule: "*/5 * * * *"
10+
startingDeadlineSeconds: 600
11+
successfulJobsHistoryLimit: 1
12+
suspend: false
13+
concurrencyPolicy: Forbid
14+
failedJobsHistoryLimit: 1
15+
jobTemplate:
16+
spec:
17+
template:
18+
metadata:
19+
annotations:
20+
linkerd.io/inject: disabled
21+
labels:
22+
app: canary-deployer
23+
spec:
24+
volumes:
25+
- name: tmp
26+
emptyDir:
27+
medium: Memory
28+
{{- with .Values.imagePullSecrets }}
29+
imagePullSecrets:
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
restartPolicy: Never
33+
securityContext:
34+
seccompProfile:
35+
type: RuntimeDefault
36+
runAsUser: 65534
37+
runAsNonRoot: true
38+
runAsGroup: 65534
39+
fsGroup: 65534
40+
containers:
41+
- image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
42+
imagePullPolicy: {{ .Values.image.pullPolicy }}
43+
name: canary-deployer
44+
securityContext:
45+
capabilities:
46+
drop:
47+
- ALL
48+
seccompProfile:
49+
type: RuntimeDefault
50+
allowPrivilegeEscalation: false
51+
readOnlyRootFilesystem: true
52+
env:
53+
- name: DEPLOY_SERVER
54+
value: {{ .Values.deploy_server }}
55+
- name: CLUSTERS
56+
value: {{ join " " .Values.clusters }}
57+
- name: NAMESPACE
58+
value: {{ .Values.namespace }}
59+
- name: TIMEOUT
60+
value: {{ .Values.timeout }}
61+
- name: APIKEY
62+
valueFrom:
63+
secretKeyRef:
64+
name: nais-verification-deploy-key
65+
key: DEPLOY_API_KEY
66+
volumeMounts:
67+
- name: tmp
68+
mountPath: /tmp
69+
readOnly: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{- if .Capabilities.APIVersions.Has "networking.gke.io/v1alpha3" }}
2+
apiVersion: networking.gke.io/v1alpha3
3+
kind: FQDNNetworkPolicy
4+
metadata:
5+
name: {{ .Release.Name }}-fqdn
6+
annotations:
7+
fqdnnetworkpolicies.networking.gke.io/aaaa-lookups: "skip"
8+
spec:
9+
egress:
10+
- to:
11+
- fqdns:
12+
- {{ (split ":" .Values.deploy_server)._0 }}
13+
ports:
14+
- port: {{ (split ":" .Values.deploy_server)._1 }}
15+
protocol: TCP
16+
podSelector:
17+
matchLabels:
18+
app: canary-deployer
19+
policyTypes:
20+
- Egress
21+
{{- end }}

charts/deploy-canary/values.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Default values for deploy-canary.
2+
3+
imagePullSecrets: []
4+
5+
# ignored clusters, used by fasit template
6+
ignoredClusters: []
7+
8+
# list of cluster ids that canary should deploy to.
9+
clusters:
10+
- foo
11+
- bar
12+
13+
image:
14+
repository: "europe-north1-docker.pkg.dev/nais-io/nais/images/canary-deployer"
15+
tag: "2024-06-17-122647-049ad8a"
16+
pullPolicy: IfNotPresent
17+
18+
deploy_server: deploy.dev-nais.cloud.nais.io:443
19+
20+
namespace: nais-verification
21+
22+
# How much time is the deploy system allowed to use for deploying?
23+
timeout: 15s

0 commit comments

Comments
 (0)