From 618dbee9b2b98aca3232744a6cb77495490bbf28 Mon Sep 17 00:00:00 2001 From: almog8k Date: Tue, 20 Feb 2024 17:05:47 +0200 Subject: [PATCH 1/3] chore: auto ingress host --- helm/templates/_helpers.tpl | 11 +++++++++++ helm/templates/ingress.yaml | 5 ++++- helm/values.yaml | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index c09cb5a..69a44d3 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -129,3 +129,14 @@ Returns the tracing url from global if exists or from the chart's values {{- .Values.env.metrics.url -}} {{- end -}} {{- end -}} + +{{/* +Returns the full ingress host. +*/}} +{{- define "ingress.host" -}} +{{- if .Values.ingress.host }} + {{- .Values.ingress.host -}} +{{- else -}} +{{- printf "%s-%s.%s" .Release.Name .Chart.Name .Values.global.ingress.domain | indent 1 }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index b9fcc95..2f84084 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -1,13 +1,16 @@ {{- $releaseName := .Release.Name -}} {{- $chartName := include "job-manager.name" . -}} {{- $serviceName := include "service.fullname" . -}} +{{- $ingressHost := include "ingress.host" . }} {{- if and (.Values.enabled) (.Values.ingress.enabled) -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ $releaseName }}-ingress annotations: + {{- if ne .Values.cloudProvider.flavor "openshift" }} kubernetes.io/ingress.class: "nginx" + {{- end }} {{- if eq .Values.ingress.type "nginx-org" }} nginx.org/mergeable-ingress-type: "minion" nginx.org/rewrites: 'serviceName={{ $serviceName }} rewrite=/' @@ -36,5 +39,5 @@ spec: name: {{ $serviceName }} port: number: {{ .Values.env.port }} - host: {{ .Values.ingress.host | quote }} + host: {{ $ingressHost }} {{- end -}} diff --git a/helm/values.yaml b/helm/values.yaml index 189ed63..c7912e6 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -3,6 +3,8 @@ global: tracing: {} metrics: {} environment: {} + ingress: + domain: 'apps.aroapp.io' enabled: true environment: "development" From f15bd5dfb887f06660345a5d7dead0287dede095 Mon Sep 17 00:00:00 2001 From: almog8k Date: Tue, 20 Feb 2024 17:45:51 +0200 Subject: [PATCH 2/3] fix: extra line --- helm/templates/_helpers.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 69a44d3..aebb23f 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -139,4 +139,4 @@ Returns the full ingress host. {{- else -}} {{- printf "%s-%s.%s" .Release.Name .Chart.Name .Values.global.ingress.domain | indent 1 }} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} From da91b3b92275b4055d0d425d97efb98d36967ee9 Mon Sep 17 00:00:00 2001 From: almog8k Date: Tue, 20 Feb 2024 17:59:02 +0200 Subject: [PATCH 3/3] chore: adding git work fllow build and push helm --- .github/workflows/build_and_push.yaml | 58 ++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_push.yaml b/.github/workflows/build_and_push.yaml index 9b2e7c4..4d5721c 100644 --- a/.github/workflows/build_and_push.yaml +++ b/.github/workflows/build_and_push.yaml @@ -1,11 +1,24 @@ +name: Match chart version and push to ACR + on: - workflow_dispatch: push: tags: - 'v*' + workflow_dispatch: + inputs: + version: + required: false + type: string +env: + HELM_EXPERIMENTAL_OCI: 1 + +permissions: + contents: write + pull-requests: write + jobs: - build_and_push: + build_and_push_docker: runs-on: ubuntu-latest env: Docker_Repository: ${{ secrets.ACR_URL }}/${{ github.event.repository.name }}:${{ github.ref_name }} @@ -16,5 +29,46 @@ jobs: login-server: ${{ secrets.ACR_URL }} username: ${{ secrets.ACR_PUSH_USER }} password: ${{ secrets.ACR_PUSH_TOKEN }} + - name: downcase repository + run: | + echo "Docker_Repository=${Docker_Repository,,}" >>${GITHUB_ENV} - run: docker build . -t ${{ env.Docker_Repository }} - run: docker push ${{ env.Docker_Repository }} + + build_and_push_helm: + name: publish helm to acr + runs-on: ubuntu-latest + steps: + - name: checkout repo from latest commit + uses: actions/checkout@v2 + + - name: install helm + uses: Azure/setup-helm@v1 + with: + version: 'v3.6.3' + + - name: login to acr using helm + run: | + helm registry login ${{ secrets.ACR_URL }} --username ${{ secrets.ACR_PUSH_USER }} --password ${{ secrets.ACR_PUSH_TOKEN }} + + - name: Get Chart name + run: | + export "CHART=$(cat Chart.yaml | grep name | awk '{print $2; exit}')" + echo "CHART=$CHART" >> $GITHUB_ENV + working-directory: ./helm + + - name: Get version + run: | + export "VER=$(cat Chart.yaml | grep version | awk '{print $2; exit}')" + echo "VER=$VER" >> $GITHUB_ENV + working-directory: ./helm + + - name: save helm chart to local registry + run: | + helm chart save . '${{ secrets.ACR_URL }}/helm/${{ env.CHART }}:${{ env.VER }}' + working-directory: ./helm + + - name: publish chart to acr + run: | + helm chart push ${{ secrets.ACR_URL }}/helm/${{ env.CHART }}:${{ env.VER }} + working-directory: ./helm