Skip to content

Commit

Permalink
Merge branch 'main' into feat/ErrorBoundryUsingReactRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
framitdavid authored Aug 6, 2024
2 parents c3958b3 + c527f97 commit 9980e60
Show file tree
Hide file tree
Showing 18 changed files with 470 additions and 69 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/loadbalancer-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Loadbalancer deploy
on:
push:
branches: [ main ]
paths:
- '.github/workflows/loadbalancer-deploy.yaml'
- '.github/workflows/template-docker-push.yaml'
- '.github/workflows/template-flux-config-push.yaml'
- '.github/workflows/template-helm-push.yaml'
- '.github/workflows/template-short-sha.yaml'
- 'charts/altinn-loadbalancer/**'
- 'charts/altinn-loadbalancer-config/**'

workflow_dispatch:

permissions:
id-token: write
contents: read

jobs:
get-short-sha:
uses: ./.github/workflows/template-short-sha.yaml

helm-push:
needs: get-short-sha
uses: ./.github/workflows/template-helm-push.yaml
with:
tag: 0.1.0+${{ needs.get-short-sha.outputs.short-sha }} # Helm version needs to be valid sematic version
chart-name: altinn-loadbalancer
registry-name: altinntjenestercontainerregistry.azurecr.io
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID_FC }}
tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }}

flux-config-push:
needs: [get-short-sha, helm-push]
strategy:
matrix:
environment: [dev, staging, prod]
uses: ./.github/workflows/template-flux-config-push.yaml
with:
tag: ${{ needs.get-short-sha.outputs.short-sha }}
registry-name: altinntjenestercontainerregistry.azurecr.io
environment: ${{ matrix.environment }}
config-chart-name: altinn-loadbalancer-config
artifact-name: altinn-loadbalancer
helm-set-arguments: environmentName=${{ matrix.environment }},chartVersion=0.1.0+${{ needs.get-short-sha.outputs.short-sha }}
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID_FC }}
tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }}
24 changes: 24 additions & 0 deletions charts/altinn-loadbalancer-config/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: altinn-loadbalancer
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
26 changes: 26 additions & 0 deletions charts/altinn-loadbalancer-config/templates/helm-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: altinn-loadbalancer
namespace: default
spec:
releaseName: altinn-loadbalancer
targetNamespace: default
interval: 5m
install:
remediation:
retries: 1
upgrade:
remediation:
retries: 1
chart:
spec:
version: "{{ .Values.chartVersion }}"
chart: altinn-loadbalancer
sourceRef:
kind: HelmRepository
name: studio-charts
namespace: default
values:
environment: "{{ .Values.environmentName }}"
2 changes: 2 additions & 0 deletions charts/altinn-loadbalancer-config/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
chartVersion: ""
environmentName: ""
22 changes: 22 additions & 0 deletions charts/altinn-loadbalancer/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions charts/altinn-loadbalancer/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
name: altinn-loadbalancer
description: A Helm chart for Kubernetes
version: 0.1.0
sources:
- https://github.com/Altinn/altinn-studio
6 changes: 6 additions & 0 deletions charts/altinn-loadbalancer/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ .Chart.Name }} is installed
The release is named {{ .Release.Name }}

To learn more about the release, try:
$ helm status {{ .Release.name }}
$ helm get {{ .Release.name }}
32 changes: 32 additions & 0 deletions charts/altinn-loadbalancer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "altinn-loadbalancer.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "altinn-loadbalancer.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "altinn-loadbalancer.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
152 changes: 152 additions & 0 deletions charts/altinn-loadbalancer/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: loadbalancer-config
data:
nginx.conf: |
worker_processes 1;
events { worker_connections 1024; }
http {
proxy_buffer_size 128k;
proxy_buffers 8 256k;
proxy_busy_buffers_size 512k;
large_client_header_buffers 64 16k;
client_max_body_size 50M;
upstream designer {
server altinn-designer:3000;
}
upstream repositories {
server altinn-repositories:3000;
}
upstream kwlocation {
server kuberneteswrapper:3000;
}
server {
listen 80;
{{- if not (hasKey $.Values.hosts $.Values.environment) }}
{{ fail "the chosen environment has no host" }}
{{- end }}
{{- $host := index $.Values.hosts $.Values.environment }}
server_name {{ $host }};
# Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
return 301 https://{{ $host }}$request_uri;
}
server {
listen 443 ssl http2;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
ssl_certificate /etc/nginx/ssl/altinn_studio/star.altinn.studio.cert;
ssl_certificate_key /etc/nginx/ssl/altinn_studio/star.altinn.studio.key;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/nginx/ssl/altinn_studio/star.altinn.studio.cert;
ssl_session_cache shared:SSL:40m;
ssl_session_timeout 4h;
ssl_session_tickets on;
server_name {{ $host }};
proxy_cookie_path ~*^/.* /;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
rewrite ^/.*/.*/staticfiles(.*)$ $1 last;
location / {
proxy_pass http://designer/;
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /editor {
proxy_pass http://designer/editor;
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /dashboard {
proxy_pass http://designer/dashboard;
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /preview {
proxy_pass http://designer/preview;
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /previewHub {
proxy_pass http://designer/previewHub;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /sync-hub {
proxy_pass http://designer/sync-hub;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /Home/ {
proxy_pass http://designer/Home/;
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /designer/ {
proxy_pass http://designer/designer/;
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /designerapi/ {
proxy_pass http://designer/designerapi/;
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /repos/ {
proxy_pass http://repositories/;
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
}
location /kuberneteswrapper/ {
proxy_pass http://kwlocation/;
proxy_set_header Host {{ $host }};
proxy_set_header X-Forwarded-For $remote_addr;
}
}
}
44 changes: 44 additions & 0 deletions charts/altinn-loadbalancer/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: altinn-loadbalancer
labels:
release: altinn-loadbalancer
spec:
selector:
matchLabels:
run: altinn-loadbalancer
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
run: altinn-loadbalancer
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.image.containerPorts.http }}
- containerPort: {{ .Values.image.containerPorts.https }}
{{- if .Values.volumeMounts }}
volumeMounts:
{{- range $mount := .Values.volumeMounts }}
- name: {{ $mount.name }}
mountPath: {{ $mount.mountPath }}
{{- end }}
{{- end }}
{{- if .Values.volumes }}
volumes:
{{- range $volume := .Values.volumes }}
- name: {{ $volume.name }}
{{- if $volume.configMap }}
configMap:
name: {{ $volume.configMap.name }}
{{- end }}
{{- if $volume.secret }}
secret:
secretName: {{ $volume.secret.secretName }}
{{- end }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions charts/altinn-loadbalancer/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Service
metadata:
name: altinn-loadbalancer
labels:
run: altinn-loablanacer
spec:
ports:
{{- range $port := .Values.service.ports }}
- port: {{ $port.port }}
targetPort: {{ $port.targetPort }}
protocol: {{ $port.protocol }}
name: {{ $port.name }}
{{- end }}
selector:
run: altinn-loadbalancer
type: {{ .Values.service.type }}
{{- if not (hasKey $.Values.loadbalancerIP $.Values.environment) }}
{{ fail "the chosen environment has no loadBalancerIP" }}
{{- end }}
{{- $ip := index $.Values.loadbalancerIP $.Values.environment }}
loadBalancerIP: {{ $ip }}
Loading

0 comments on commit 9980e60

Please sign in to comment.