diff --git a/Chart.yaml b/Chart.yaml index 8cf9147..7d3b3b8 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: angular +name: helm-angular-app version: 0.0.0 description: Angular helm chart appVersion: 0.0.0 diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index f9f2c29..ee9fa92 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -1,34 +1,39 @@ -{{- define "angular.traefik.path" -}} - {{ if .Values.routing.path }} && PathPrefix(`{{ .Values.routing.path }}`){{ end }} +{{- define "app.fullname" -}} + {{ .Release.Name }}-{{ .Values.name | default .Chart.Name }} {{- end -}} -{{- define "angular.routing.type" -}} -{{ if .Values.global.routing.type }}{{ .Values.global.routing.type }}{{ else }}{{ .Values.routing.type }}{{ end }} +{{- define "app.version" -}} + {{ .Values.image.tag }} {{- end -}} -{{- define "angular.labels.common" -}} -version: {{ .Values.version | default .Values.image.tag | quote }} -helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} -app.kubernetes.io/managed-by: {{ .Release.Service | quote }} -app.kubernetes.io/name: {{ .Release.Name | quote }} +{{- define "app.id" -}} + {{ if .Values.routing.backend }}{{ .Values.appId }}{{ else }}{{ template "app.fullname" $ }}{{ end }} {{- end -}} +{{- define "app.traefik.path" -}} + {{ if .Values.routing.path }} && PathPrefix(`{{ .Values.routing.path }}`){{ end }} +{{- end -}} + +{{- define "app.routing.type" -}} +{{ if .Values.global.routing.type }}{{ .Values.global.routing.type }}{{ else }}{{ .Values.routing.type }}{{ end }} +{{- 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 "common.names.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 "-" -}} +{{- define "app.ingress.host" -}} + {{ if .Values.routing.backend }} + {{ template "app.fullname" $ }}-{{ .Release.Namespace }}.{{ .Values.global.default_url | default .Values.routing.default_url }} + {{ else if .Values.routing.hostName }} + {{ .Values.routing.hostName }} + {{ else if .Values.global.hostName }} + {{ .Values.global.hostName }} + {{ else }} + {{ template "app.fullname" $ }}-{{ .Release.Namespace }}.{{ .Values.global.default_url | default .Values.routing.default_url }} + {{ end }} {{- end -}} + +{{- define "app.labels.common" -}} +version: {{ .Values.version | default .Values.image.tag | quote }} +helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} +app.kubernetes.io/managed-by: {{ .Release.Service | quote }} +app.kubernetes.io/name: {{ template "app.fullname" $ }} {{- end -}} -{{- end -}} \ No newline at end of file diff --git a/templates/config-apm.yaml b/templates/config-apm.yaml deleted file mode 100644 index d2098c0..0000000 --- a/templates/config-apm.yaml +++ /dev/null @@ -1,17 +0,0 @@ -{{ if .Values.operator.apm.enabled }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: "{{ include "common.names.fullname" . }}-apm-config" - annotations: - appId: {{ include "common.names.fullname" . }} - filename: "permissions.csv" - labels: - app: {{ include "common.names.fullname" . }} -{{ include "angular.labels.common" $ | indent 4 }} -data: -{{ if .Values.operator.apm.content }} - permissions.csv: |- -{{ $.Values.operator.apm.content | indent 4 }} -{{ end }} -{{ end }} diff --git a/templates/config-env.yaml b/templates/config-env.yaml new file mode 100644 index 0000000..7116722 --- /dev/null +++ b/templates/config-env.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: "{{ template "app.fullname" $ }}-env" + labels: + app: {{ template "app.fullname" $ }} +{{ include "app.labels.common" $ | indent 4 }} +data: + APP_VERSION: {{ .Values.image.tag }} + APP_ID: {{ template "app.id" $ }} + {{ if and .Values.routing.enabled .Values.routing.path }}APP_BASE_HREF: {{ .Values.routing.path }}{{ end }} \ No newline at end of file diff --git a/templates/config-keycloak.yaml b/templates/config-keycloak.yaml index e42a2c1..532c045 100644 --- a/templates/config-keycloak.yaml +++ b/templates/config-keycloak.yaml @@ -2,12 +2,12 @@ apiVersion: v1 kind: ConfigMap metadata: - name: "{{ include "common.names.fullname" . }}-kc-config" + name: "{{ template "app.fullname" $ }}-kc-config" annotations: tkit.kc.cli/target-realm: {{ .Values.global.operator.keycloak.realm | default .Values.operator.keycloak.realm }} labels: - app: {{ include "common.names.fullname" . }} -{{ include "angular.labels.common" $ | indent 4 }} + app: {{ template "app.fullname" $ }} +{{ include "app.labels.common" $ | indent 4 }} data: {{ if .Values.operator.keycloak.client }} client: |- diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 51ecbe3..07b65eb 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -1,20 +1,20 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "common.names.fullname" . }} + name: {{ template "app.fullname" $ }} labels: - app: {{ include "common.names.fullname" . }} -{{ include "angular.labels.common" $ | indent 4 }} + app: {{ template "app.fullname" $ }} +{{ include "app.labels.common" $ | indent 4 }} spec: replicas: {{ .Values.replicas }} selector: matchLabels: - app: {{ include "common.names.fullname" . }} + app: {{ template "app.fullname" $ }} template: metadata: labels: - app: {{ include "common.names.fullname" . }} -{{ include "angular.labels.common" $ | indent 8 }} + app: {{ template "app.fullname" $ }} +{{ include "app.labels.common" $ | indent 8 }} annotations: {{- range $map_name := .Values.inject_maps }} checksum/{{ $map_name | replace "-" "_" }}: {{ index $.Values.global ($map_name | replace "-" "_") }} @@ -23,22 +23,28 @@ spec: checksum/{{ $map_name | replace "-" "_" }}: {{ index $.Values.global ($map_name | replace "-" "_") }} {{- end }} spec: - {{- if .Values.serviceAccountSuffix }} - serviceAccountName: {{ include "common.names.fullname" . }}-{{ .Values.serviceAccountSuffix }} - {{- end }} + {{- if .Values.serviceAccount.enabled }} + {{- if .Values.serviceAccount.name }} + serviceAccountName: {{ .Values.serviceAccount.name }} + {{- else if .Values.serviceAccountSuffix }} + serviceAccountName: {{ template "quarkus.fullname" $ }}-{{ .Values.serviceAccount.suffix }} + {{ else }} + serviceAccountName: {{ template "quarkus.fullname" $ }} + {{- end }} + {{- end }} {{- if .Values.imagePullSecrets }} imagePullSecrets: - name: {{ .Values.imagePullSecrets }} {{- end }} containers: - - name: nginx + - name: {{ template "app.fullname" $ }} image: {{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }} - imagePullPolicy: Always + imagePullPolicy: {{ .Values.image.pull }} ports: - containerPort: {{ .Values.pod.port }} readinessProbe: httpGet: - path: {{ .Values.health.url }} + path: {{ .Values.livenessProbe.url }} port: {{ .Values.pod.port }} scheme: HTTP initialDelaySeconds: 3 @@ -48,42 +54,62 @@ spec: failureThreshold: 5 livenessProbe: httpGet: - path: {{ .Values.health.url }} + path: {{ .Values.readinessProbe.url }} port: {{ .Values.pod.port }} scheme: HTTP initialDelaySeconds: 3 periodSeconds: 30 timeoutSeconds: 3 successThreshold: 1 - failureThreshold: 5 - {{- $envVals := .Values.global.env -}} - {{ if .Values.routing.enabled }} - {{ if .Values.routing.path }} - {{- $appBaseHref := dict "APP_BASE_HREF" .Values.routing.path -}} - {{- $envVals = merge $appBaseHref $envVals -}} - {{ end }} - {{ end }} - {{- if (.Values.env) }} - {{- $envVals = merge .Values.env $envVals -}} - {{- end }} - + failureThreshold: 5 + startupProbe: + failureThreshold: 3 + httpGet: + path: /q/health/started + port: {{ .Values.pod.port }} + scheme: HTTP + initialDelaySeconds: 3 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 10 env: - - name: APP_VERSION - value: {{ .Values.version | default .Values.image.tag }} - {{- if $envVals }} - {{- range $key,$val := $envVals }} - - name: {{ $key }} - value: {{ tpl ($val|toString) $ | quote }} - {{- end }} - {{- end }} - {{- $im := .Values.global.inject_maps -}} - {{- if (.Values.inject_maps) }} - {{- $im = concat .Values.inject_maps .Values.global.inject_maps | uniq -}} - {{- end }} - {{- if $im }} + {{- $envVals := .Values.global.env -}} + {{- if (.Values.env) }} + {{- $envVals = merge .Values.env $envVals -}} + {{- end }} + {{- if $envVals }} + {{- range $key,$val := $envVals }} + - name: {{ $key }} + value: {{ tpl ($val|toString) $ | quote }} + {{- end }} + {{- end }} + + {{- if .Values.env_secrets }} + {{- range $secret_key,$secret_value := .Values.env_secrets }} + - name: {{ $secret_key }} + valueFrom: + secretKeyRef: + key: {{ $secret_key }} + name: {{ template "quarkus.fullname" $ }}-env + {{- end }} + {{- end }} + + {{- if .Values.envCustom }} + {{- .Values.envCustom | toYaml | trim | nindent 10 }} + {{- end }} + + {{- if or (.Values.global.inject_maps) (.Values.inject_maps) }} envFrom: -{{- range $map_name := $im }} + - configMapRef: + name: {{ template "app.fullname" $ }}-env + {{- $im := .Values.global.inject_maps -}} + {{- if (.Values.inject_maps) }} + {{- $im = concat .Values.inject_maps .Values.global.inject_maps | uniq -}} + {{- end }} + {{- if $im }} + {{- range $map_name := $im }} - configMapRef: name: {{ $map_name }} -{{- end }} - {{- end }} + {{- end }} + {{- end }} + {{- end }} \ No newline at end of file diff --git a/templates/ingress-traefik.yaml b/templates/ingress-traefik.yaml new file mode 100644 index 0000000..5b8ea5c --- /dev/null +++ b/templates/ingress-traefik.yaml @@ -0,0 +1,30 @@ +{{- if .Values.routing.enabled }} +{{- if eq (include "app.routing.type" $) "traefik" }} +kind: IngressRoute +apiVersion: traefik.io/v1alpha1 +metadata: + name: {{ template "app.fullname" $ }} + labels: + app: {{ template "app.fullname" $ }} +{{ include "app.labels.common" $ | indent 4 }} +spec: + entryPoints: + {{- range $ep := .Values.routing.entryPoints }} + - {{ $ep }} + {{ end }} + {{- range $ep := .Values.global.routing.entryPoints }} + - {{ $ep }} + {{ end }} + routes: + - kind: Rule + match: Host(`{{ template "app.ingress.host" $ }}`){{ include "app.traefik.path" $ }} + {{ if .Values.routing.traefik.middleware.enabled }} + middlewares: + - name: {{ .Values.routing.traefik.middleware.name }} + {{ end }} + services: + - kind: Service + name: {{ template "app.fullname" $ }} + port: {{ .Values.service.port }} +{{ end }} +{{ end }} diff --git a/templates/middleware-strip.yaml b/templates/middleware-strip.yaml deleted file mode 100644 index 4c8642e..0000000 --- a/templates/middleware-strip.yaml +++ /dev/null @@ -1,14 +0,0 @@ -{{- if .Values.routing.enabled }} -{{- if eq (include "angular.routing.type" $) "traefik" }} -{{- if .Values.routing.stripprefix }} -apiVersion: traefik.containo.us/v1alpha1 -kind: Middleware -metadata: - name: {{ include "common.names.fullname" . }}-{{ .Release.Namespace }}-middleware -spec: - stripPrefix: - prefixes: - - {{ .Values.routing.path }} -{{ end }} -{{ end }} -{{ end }} diff --git a/templates/operator-microfrontend.yaml b/templates/operator-microfrontend.yaml new file mode 100644 index 0000000..9cba29f --- /dev/null +++ b/templates/operator-microfrontend.yaml @@ -0,0 +1,30 @@ +{{ if .Values.operator.microfrontend.enabled }} +apiVersion: onecx.github.io/v1 +kind: Microfrontend +metadata: + name: {{ template "app.fullname" $ }} + labels: + app: {{ template "app.fullname" $ }} +{{ include "app.labels.common" $ | indent 4 }} +spec: + appId: {{ .Values.operator.microfrontend.spec.appId | default (include "app.id" .) }} + appName: {{ .Values.operator.microfrontend.spec.appName | default (include "app.fullname" .) }} + appVersion: {{ template "app.version" $ }} + classifications: {{ .Values.operator.microfrontend.spec.classifications }} + contact: {{ .Values.operator.microfrontend.spec.contact }} + description: {{ .Values.operator.microfrontend.spec.description }} + exposedModule: {{ .Values.operator.microfrontend.spec.exposedModule }} + iconName: {{ .Values.operator.microfrontend.spec.iconName }} + note: {{ .Values.operator.microfrontend.spec.note }} + productName: {{ .Values.operator.microfrontend.spec.productName | default .Release.Name }} + remoteBaseUrl: {{ .Values.operator.microfrontend.spec.remoteBaseUrl | default .Values.routing.path }} + remoteEntry: {{ .Values.operator.microfrontend.spec.remoteBaseUrl | default .Values.routing.path }}{{ .Values.operator.microfrontend.entrySuffix }} + technology: {{ .Values.operator.microfrontend.spec.technology }} + {{ if (.Values.operator.microfrontend.spec.endpoints) }} + endpoints: + {{- range $item := .Values.operator.microfrontend.spec.endpoints }} + - name: {{ $item.name }} + path: {{ $item.path }} + {{- end }} + {{- end }} +{{- end }} diff --git a/templates/operator-permission.yaml b/templates/operator-permission.yaml new file mode 100644 index 0000000..3b47a3e --- /dev/null +++ b/templates/operator-permission.yaml @@ -0,0 +1,12 @@ +{{ if .Values.operator.permission.enabled }} +apiVersion: onecx.github.io/v1 +kind: Permission +metadata: + name: {{ template "app.fullname" $ }} + labels: + app: {{ template "app.fullname" $ }} +{{ include "app.labels.common" $ | indent 4 }} +spec: + appId: {{ .Values.operator.permission.spec.appId | default (include "app.fullname" .) }} + permissions: {{ if .Values.operator.permission.spec.permissions }}{{ .Values.operator.permission.spec.permissions | toYaml | nindent 4 }}{{- end }} +{{- end }} diff --git a/templates/service.yaml b/templates/service.yaml index fb507e5..0e34f90 100644 --- a/templates/service.yaml +++ b/templates/service.yaml @@ -1,15 +1,17 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - name: {{ include "common.names.fullname" . }} + name: {{ template "app.fullname" $ }} labels: - app: {{ include "common.names.fullname" . }} -{{ include "angular.labels.common" $ | indent 4 }} + app: {{ template "app.fullname" $ }} +{{ include "app.labels.common" $ | indent 4 }} + annotations: + description: {{ template "app.fullname" $ }} spec: selector: - app: {{ include "common.names.fullname" . }} -{{ include "angular.labels.common" $ | indent 4 }} + app: {{ template "app.fullname" $ }} ports: - - protocol: TCP + - name: http + protocol: TCP port: {{ .Values.service.port }} targetPort: {{ .Values.pod.port }} diff --git a/templates/traefik.yaml b/templates/traefik.yaml deleted file mode 100644 index bb04e28..0000000 --- a/templates/traefik.yaml +++ /dev/null @@ -1,38 +0,0 @@ -{{- if .Values.routing.enabled }} -{{- if eq (include "angular.routing.type" $) "traefik" }} -kind: IngressRoute -apiVersion: traefik.containo.us/v1alpha1 -metadata: - name: {{ include "common.names.fullname" . }}-{{ .Release.Namespace }} - labels: - app: {{ include "common.names.fullname" . }} -{{ include "angular.labels.common" $ | indent 4 }} -spec: - entryPoints: - {{- range $ep := .Values.routing.entryPoints }} - - {{ $ep }} - {{ end }} - {{- range $ep := .Values.global.routing.entryPoints }} - - {{ $ep }} - {{ end }} - routes: - - kind: Rule - {{ if .Values.routing.backend }} - match: Host(`{{ include "common.names.fullname" . }}-{{ .Release.Namespace }}.{{ .Values.global.default_url | default .Values.routing.default_url }}`){{ include "angular.traefik.path" $ }} - {{ else if .Values.routing.hostName }} - match: Host(`{{ .Values.routing.hostName }}`){{ include "angular.traefik.path" $ }} - {{ else if .Values.global.hostName }} - match: Host(`{{ .Values.global.hostName }}`){{ include "angular.traefik.path" $ }} - {{ else }} - match: Host(`{{ include "common.names.fullname" . }}-{{ .Release.Namespace }}.{{ .Values.global.default_url | default .Values.routing.default_url }}`){{ include "angular.traefik.path" $ }} - {{ end }} - {{ if .Values.routing.stripprefix }} - middlewares: - - name: {{ include "common.names.fullname" . }}-{{ .Release.Namespace }}-middleware - {{ end }} - services: - - kind: Service - name: {{ include "common.names.fullname" . }} - port: {{ .Values.service.port }} -{{ end }} -{{ end }} diff --git a/values.yaml b/values.yaml index 3b5c32e..789cdf5 100644 --- a/values.yaml +++ b/values.yaml @@ -10,19 +10,35 @@ global: keycloak: realm: +# Name of the instance, default {{ .Release.Name }}-{{ .Values.name | default .Chart.Name }} +name: +# ID of the application instance, default +appId: + # Application image image: # Docker registry - registry: "oci://ghcr.io/" + registry: "ghcr.io" # Docker repository (application name) repository: "change-me" # Docker image tag (application version) tag: "master" + # pull policy Always | IfNotPresent | Never + pull: IfNotPresent # Image pull secrets imagePullSecrets: -health: +# health check configuration +livenessProbe: + url: /healthcheck + +# rediness proble configuration +readinessProbe: + url: /healthcheck + +# start up probe configuration +startupProbe: url: /healthcheck # pod @@ -37,43 +53,107 @@ service: routing: # Enable or disable route enabled: false + # Default URL default_url: "change.com" + # path path: + # host name hostName: - # traefik - type: traefik - # stripprefix for treafik - stripprefix: false + + # traefik | ingress + type: none + + traefik: + # middleware + middleware: + # middleware for treafik + enabled: false + # traefik middleware name + name: # Replicas replicas: 1 -# Service account suffix -# serviceAccountName = Release.Name-serviceAccountSuffix -serviceAccountSuffix: +# custom service account +serviceAccount: + # enable custom service accoung + enabled: false + # generate custom name . + suffix: + # fix name of the service account + name: # Inject config maps inject_maps: [] -## @param nameOverride String to partially override common.names.fullname -## -nameOverride: "" -## @param fullnameOverride String to fully override common.names.fullname -## -fullnameOverride: "" -## @param commonLabels Labels to add to all deployed objects -## + +# Custom env variables as YAML structure +envCustom: # Kubernetes operator configuration operator: - # APM operator - apm: - # enabled or disable config for operator + # permissions + permission: + # enable or disable configuration for operator enabled: false - # CSV file in string - content: + + spec: + # default deployment name (release_name-name) + appId: + # map of permissions + # resource: + # action: description + permissions: + + # microfrontend + microfrontend: + # enable or disable configuration for operator + enabled: false + + # default remote entry path suffix + entrySuffix: remoteEntry.js + + # definnition + spec: + + description: change-me + + exposedModule: change-me + + iconName: + + note: change-me + + # list of strings + classifications: [] + + # list of name and path + # - name: + # path: + endpoints: + + # technology is free text + technology: ANGULAR + + # contact email + contact: onecx@1000kit.org + + # default is app.routing.path + remoteBaseUrl: + + # default is app.routing.path + entrySuffix + remoteEntry: + + # default release name (product name) + productName: + + # default deployment name (release_name-name or appId) + appId: + + # default deployment name (release_name-name) + appName: # Keycloak operator keycloak: