Skip to content

Commit

Permalink
Merge pull request #278 from salasberryfin/chart-support-digest-and-t…
Browse files Browse the repository at this point in the history
…ag-for-image

feat: helm chart supports digest and tag for container image
  • Loading branch information
richardcase authored Dec 4, 2023
2 parents 40500ee + bf19349 commit 9985847
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ jobs:

release:
name: Create helm release
needs: [build-push-services]
needs: [multiarch]
runs-on: ubuntu-latest
env:
TAG: ${{ github.ref_name }}
CONTROLLER_IMG: ${{ vars.REGISTRY_IMAGE }}
PROD_REGISTRY: ${{ secrets.REGISTRY_ENDPOINT }}
PROD_ORG: rancher-sandbox
RELEASE_DIR: .cr-release-packages
Expand All @@ -95,12 +96,17 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get prod multiarch image digest
run: |
docker pull ${{ env.CONTROLLER_IMG }}:${{ env.TAG }}
multiarch_digest=$( docker inspect --format='{{index .RepoDigests 0}}' ${{ env.CONTROLLER_IMG }}:${{ env.TAG }} | sed 's/.*@//' )
echo "multiarch_digest=${multiarch_digest}" >> $GITHUB_ENV
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Package operator chart
run: RELEASE_TAG=${GITHUB_REF##*/} CHART_PACKAGE_DIR=${RELEASE_DIR} REGISTRY=${{ env.PROD_REGISTRY }} ORG=${{ env.PROD_ORG }} make release
run: RELEASE_TAG=${GITHUB_REF##*/} CONTROLLER_IMAGE_VERSION=${{ env.multiarch_digest }} CHART_PACKAGE_DIR=${RELEASE_DIR} REGISTRY=${{ env.PROD_REGISTRY }} ORG=${{ env.PROD_ORG }} make release

- name: Install chart-releaser
uses: helm/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ env:
RELEASE_TAG: v0.0.1
MANIFEST_IMG: controller
CONTROLLER_IMG: controller
CONTROLLER_IMAGE_VERSION: v0.0.1
PULL_POLICY: Never
CERT_MANAGER_VERSION: v1.12.3
RANCHER_VERSION: v2.7.5
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ ORG ?= rancher-sandbox
CONTROLLER_IMAGE_NAME ?= rancher-turtles
CONTROLLER_IMG ?= $(REGISTRY)/$(ORG)/$(CONTROLLER_IMAGE_NAME)
MANIFEST_IMG ?= $(CONTROLLER_IMG)-$(ARCH)
CONTROLLER_IMAGE_VERSION ?= $(shell git describe --abbrev=0 2>/dev/null)

# Relase
# Release
RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null)
PREVIOUS_TAG ?= $(shell git describe --abbrev=0 --exclude $(RELEASE_TAG) 2>/dev/null)
HELM_CHART_TAG := $(shell echo $(RELEASE_TAG) | cut -c 2-)
Expand Down Expand Up @@ -475,8 +476,8 @@ release: clean-release $(RELEASE_DIR) ## Builds and push container images using
build-chart: $(HELM) $(KUSTOMIZE) $(RELEASE_DIR) $(CHART_RELEASE_DIR) $(CHART_PACKAGE_DIR) ## Builds the chart to publish with a release
$(KUSTOMIZE) build ./config/chart > $(CHART_DIR)/templates/rancher-turtles-components.yaml
cp -rf $(CHART_DIR)/* $(CHART_RELEASE_DIR)
sed -i'' -e 's@tag: .*@tag: '"$(RELEASE_TAG)"'@' $(CHART_RELEASE_DIR)/values.yaml
sed -i'' -e 's@image: .*@image: '"$(CONTROLLER_IMG)"'@' $(CHART_RELEASE_DIR)/values.yaml
sed -i'' -e 's@imageVersion: .*@imageVersion: '"$(CONTROLLER_IMAGE_VERSION)"'@' $(CHART_RELEASE_DIR)/values.yaml
sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' $(CHART_RELEASE_DIR)/values.yaml
cd $(CHART_RELEASE_DIR) && $(HELM) dependency update
$(HELM) package $(CHART_RELEASE_DIR) --app-version=$(HELM_CHART_TAG) --version=$(HELM_CHART_TAG) --destination=$(CHART_PACKAGE_DIR)
Expand Down Expand Up @@ -504,7 +505,7 @@ test-e2e: $(GINKGO) $(HELM) $(CLUSTERCTL) kubectl e2e-image ## Run the end-to-en
.PHONY: e2e-image
e2e-image: ## Build the image for e2e tests
TAG=v0.0.1 $(MAKE) docker-build
RELEASE_TAG=v0.0.1 CONTROLLER_IMG=$(MANIFEST_IMG) $(MAKE) build-chart
RELEASE_TAG=v0.0.1 CONTROLLER_IMG=$(MANIFEST_IMG) CONTROLLER_IMAGE_VERSION=v0.0.1 $(MAKE) build-chart

.PHONY: compile-e2e
e2e-compile: ## Test e2e compilation
Expand Down
6 changes: 5 additions & 1 deletion charts/rancher-turtles/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.uid
image: '{{ .Values.rancherTurtles.image }}:{{ .Values.rancherTurtles.tag }}'
{{- if (contains "sha256:" .Values.rancherTurtles.imageVersion) }}
image: '{{ .Values.rancherTurtles.image }}@{{ .Values.rancherTurtles.imageVersion }}'
{{- else }}
image: '{{ .Values.rancherTurtles.image }}:{{ .Values.rancherTurtles.imageVersion }}'
{{- end}}
imagePullPolicy: '{{ .Values.rancherTurtles.imagePullPolicy }}'
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion charts/rancher-turtles/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rancherTurtles:
image: controller
tag: v0.0.0
imageVersion: v0.0.0
imagePullPolicy: Never
namespace: rancher-turtles-system
managerArguments: []
Expand Down
2 changes: 1 addition & 1 deletion config/chart/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace: "{{ .Values.rancherTurtles.namespace }}"
images:
- name: controller
newName: "{{ .Values.rancherTurtles.image }}"
newTag: "{{ .Values.rancherTurtles.tag }}"
newTag: "{{ .Values.rancherTurtles.imageVersion }}"
namePrefix: rancher-turtles-
bases:
- ../rbac
Expand Down
2 changes: 1 addition & 1 deletion test/testenv/turtles.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func DeployRancherTurtles(ctx context.Context, input DeployRancherTurtlesInput)

values := map[string]string{
"rancherTurtles.image": input.Image,
"rancherTurtles.tag": input.Tag,
"rancherTurtles.imageVersion": input.Tag,
"rancherTurtles.managerArguments[0]": "--insecure-skip-verify=true",
"cluster-api-operator.cluster-api.configSecret.namespace": "default",
"cluster-api-operator.cluster-api.configSecret.name": "variables",
Expand Down

0 comments on commit 9985847

Please sign in to comment.