Skip to content

Commit b578baf

Browse files
authored
feat(template): Support registry-specific Helm values (#583)
* ci(template): Bump actions * ci: Bump actions * feat(template): Support registry-specific Helm values * fix(template): Interpolate operator name
1 parent 85f035c commit b578baf

10 files changed

Lines changed: 55 additions & 20 deletions

File tree

.github/workflows/pr_pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
persist-credentials: false
2020
fetch-depth: 0
21-
- uses: stackabletech/actions/run-pre-commit@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
21+
- uses: stackabletech/actions/run-pre-commit@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
2222
with:
2323
python-version: ${{ env.PYTHON_VERSION }}
2424
hadolint: ${{ env.HADOLINT_VERSION }}

template/.github/workflows/build.yaml.j2

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
- name: Check for changed files
5050
id: check
51-
uses: stackabletech/actions/detect-changes@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
51+
uses: stackabletech/actions/detect-changes@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
5252
with:
5353
patterns: |
5454
- '.github/workflows/build.yaml'
@@ -166,7 +166,7 @@ jobs:
166166

167167
- name: Build Container Image
168168
id: build
169-
uses: stackabletech/actions/build-container-image@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
169+
uses: stackabletech/actions/build-container-image@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
170170
with:
171171
image-name: ${{ env.OPERATOR_NAME }}
172172
image-index-manifest-tag: ${{ steps.version.outputs.OPERATOR_VERSION }}
@@ -175,7 +175,7 @@ jobs:
175175

176176
- name: Publish Container Image
177177
if: ${{ !github.event.pull_request.head.repo.fork }}
178-
uses: stackabletech/actions/publish-image@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
178+
uses: stackabletech/actions/publish-image@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
179179
with:
180180
image-registry-uri: oci.stackable.tech
181181
image-registry-username: robot$sdp+github-action-build
@@ -203,7 +203,7 @@ jobs:
203203
persist-credentials: false
204204

205205
- name: Publish and Sign Image Index
206-
uses: stackabletech/actions/publish-image-index-manifest@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
206+
uses: stackabletech/actions/publish-image-index-manifest@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
207207
with:
208208
image-registry-uri: oci.stackable.tech
209209
image-registry-username: robot$sdp+github-action-build
@@ -230,7 +230,7 @@ jobs:
230230
submodules: recursive
231231

232232
- name: Package, Publish, and Sign Helm Chart
233-
uses: stackabletech/actions/publish-helm-chart@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
233+
uses: stackabletech/actions/publish-helm-chart@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
234234
with:
235235
chart-registry-uri: oci.stackable.tech
236236
chart-registry-username: robot$sdp-charts+github-action-build
@@ -260,7 +260,7 @@ jobs:
260260
runs-on: ubuntu-latest
261261
steps:
262262
- name: Run OpenShift Preflight Check
263-
uses: stackabletech/actions/run-openshift-preflight@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
263+
uses: stackabletech/actions/run-openshift-preflight@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
264264
with:
265265
image-index-uri: oci.stackable.tech/sdp/${{ env.OPERATOR_NAME }}:${{ needs.build-container-image.outputs.operator-version }}
266266
image-architecture: ${{ matrix.arch }}
@@ -300,7 +300,7 @@ jobs:
300300
persist-credentials: false
301301

302302
- name: Send Notification
303-
uses: stackabletech/actions/send-slack-notification@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
303+
uses: stackabletech/actions/send-slack-notification@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
304304
with:
305305
publish-helm-chart-result: ${{ needs.publish-helm-chart.result }}
306306
publish-manifests-result: ${{ needs.publish-index-manifest.result }}

template/.github/workflows/integration-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
# TODO: Enable the scheduled runs which hard-code what profile to use
4242
- name: Run Integration Test
4343
id: test
44-
uses: stackabletech/actions/run-integration-test@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
44+
uses: stackabletech/actions/run-integration-test@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
4545
with:
4646
replicated-api-token: ${{ secrets.REPLICATED_API_TOKEN }}
4747
test-mode-input: ${{ inputs.test-mode-input }}
@@ -51,7 +51,7 @@ jobs:
5151

5252
- name: Send Notification
5353
if: ${{ failure() || github.run_attempt > 1 }}
54-
uses: stackabletech/actions/send-slack-notification@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
54+
uses: stackabletech/actions/send-slack-notification@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
5555
with:
5656
slack-token: ${{ secrets.SLACK_INTEGRATION_TEST_TOKEN }}
5757
failed-tests: ${{ steps.test.outputs.failed-tests }}

template/.github/workflows/pr_pre-commit.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
persist-credentials: false
2828
submodules: recursive
2929
fetch-depth: 0
30-
- uses: stackabletech/actions/run-pre-commit@9848c5593dff4793aacba240116a648c02f20fa4 # v0.13.1
30+
- uses: stackabletech/actions/run-pre-commit@ac6f1d3b87f68826b9a5838d13864ef8e88dcf40 # v0.14.0
3131
with:
3232
python-version: ${{ env.PYTHON_VERSION }}
3333
rust: ${{ env.RUST_TOOLCHAIN_VERSION }}

template/Makefile.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,9 @@ run-dev: check-nix check-kubernetes
7676

7777
stop-dev: check-nix check-kubernetes
7878
nix run --extra-experimental-features "nix-command flakes" -f. tilt -- down
79+
80+
helm-install:
81+
helm install \
82+
--values deploy/helm/${OPERATOR_NAME}/values.yaml \
83+
--values deploy/helm/${OPERATOR_NAME}/values/$(OCI_REGISTRY_HOSTNAME).yaml \
84+
${OPERATOR_NAME} deploy/helm/${OPERATOR_NAME}

template/Tiltfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
# Load the metadata first, so that we immediately get access to the operator name
2+
meta = read_json('nix/meta.json')
3+
operator_name = meta['operator']['name']
4+
15
# If tilt_options.json exists read it and load the default_registry value from it
26
settings = read_json('tilt_options.json', default={})
3-
registry = settings.get('default_registry', 'oci.stackable.tech/sandbox')
7+
registry = settings.get('default_registry', 'oci.stackable.tech')
8+
repository = settings.get('default_repository', 'sandbox' + '/' + operator_name)
49

510
# Configure default registry either read from config file above, or with default value of "oci.stackable.tech/sandbox"
611
default_registry(registry)
712

8-
meta = read_json('nix/meta.json')
9-
operator_name = meta['operator']['name']
10-
1113
custom_build(
12-
registry + '/' + operator_name,
13-
'make regenerate-nix && nix-build . -A docker --argstr dockerName "${EXPECTED_REGISTRY}/' + operator_name + '" && ./result/load-image | docker load',
14+
registry + '/' + repository,
15+
'make regenerate-nix && nix-build . -A docker --argstr dockerName "${EXPECTED_REGISTRY}/' + repository + '" && ./result/load-image | docker load',
1416
deps=['rust', 'Cargo.toml', 'Cargo.lock', 'default.nix', "nix", 'build.rs', 'vendor'],
1517
ignore=['*.~undo-tree~'],
1618
# ignore=['result*', 'Cargo.nix', 'target', *.yaml],
@@ -28,13 +30,15 @@ k8s_kind('DaemonSet', image_json_path='{.spec.template.metadata.annotations.inte
2830
# supported by helm(set).
2931
helm_values = settings.get('helm_values', None)
3032

31-
helm_override_image_repository = 'image.repository=' + registry + '/' + operator_name
33+
helm_override_image_registry = 'image.registry=' + registry
34+
helm_override_image_repository = 'image.repository=' + repository
3235

3336
k8s_yaml(helm(
3437
'deploy/helm/' + operator_name,
3538
name=operator_name,
3639
namespace="stackable-operators",
3740
set=[
41+
helm_override_image_registry,
3842
helm_override_image_repository,
3943
],
4044
values=helm_values,

template/deploy/helm/[[operator]]/.helmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# Patterns to ignore when building packages.
77
# This supports shell glob matching, relative path matching, and
88
# negation (prefixed with !). Only one pattern per line.
9+
# Ignore the file itself
10+
.helmignore
911
.DS_Store
1012
# Common VCS dirs
1113
.git/
@@ -26,3 +28,5 @@
2628
.idea/
2729
*.tmproj
2830
.vscode/
31+
# Partial, unmerged, registry-specific values files
32+
values/

template/deploy/helm/[[operator]]/templates/_helpers.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,10 @@ Labels for Kubernetes objects created by helm test
7777
{{- define "operator.testLabels" -}}
7878
helm.sh/test: {{ include "operator.chart" . }}
7979
{{- end }}
80+
81+
{{/*
82+
Build the full container image reference.
83+
*/}}
84+
{{- define "operator.image" -}}
85+
{{- printf "%s/%s:%s" .Values.image.registry .Values.image.repository (.Values.image.tag | default .Chart.AppVersion) -}}
86+
{{- end }}

template/deploy/helm/[[operator]]/templates/deployment.yaml.j2

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
template:
1717
metadata:
1818
annotations:
19-
internal.stackable.tech/image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
19+
internal.stackable.tech/image: {{ include "operator.image" . }}
2020
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
2121
{{- with .Values.podAnnotations }}
2222
{{- toYaml . | nindent 8 }}
@@ -38,7 +38,7 @@ spec:
3838
- name: {{ include "operator.appname" . }}
3939
securityContext:
4040
{{- toYaml .Values.securityContext | nindent 12 }}
41-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
41+
image: {{ include "operator.image" . }}
4242
imagePullPolicy: {{ .Values.image.pullPolicy }}
4343
resources:
4444
{{- toYaml .Values.resources | nindent 12 }}
@@ -71,6 +71,15 @@ spec:
7171
- name: OPERATOR_SERVICE_NAME
7272
value: {{ include "operator.fullname" . }}
7373

74+
# The URI of the image registry, like "oci.stackable.tech". Used to derive product image
75+
# name.
76+
- name: IMAGE_REGISTRY_URI
77+
value: {{ .Values.image.registry }}
78+
79+
# The image repository, like "sdp/airflow-operator"
80+
- name: IMAGE_REPOSITORY
81+
value: {{ .Values.image.repository }}
82+
7483
# Operators need to know the node name they are running on, to e.g. discover the
7584
# Kubernetes domain name from the kubelet API.
7685
- name: KUBERNETES_NODE_NAME
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
# Values overlay for chart packages published to oci.stackable.tech.
3+
image:
4+
registry: oci.stackable.tech
5+
repository: sdp/{[ operator.name }]

0 commit comments

Comments
 (0)