Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: auto ingress host #35

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions .github/workflows/build_and_push.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -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
11 changes: 11 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
5 changes: 4 additions & 1 deletion helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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=/'
Expand Down Expand Up @@ -36,5 +39,5 @@ spec:
name: {{ $serviceName }}
port:
number: {{ .Values.env.port }}
host: {{ .Values.ingress.host | quote }}
host: {{ $ingressHost }}
{{- end -}}
2 changes: 2 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ global:
tracing: {}
metrics: {}
environment: {}
ingress:
domain: 'apps.aroapp.io'

enabled: true
environment: "development"
Expand Down
Loading