diff --git a/Chart.yaml b/Chart.yaml index fde30de..96f9ec0 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -4,9 +4,8 @@ version: 2.0.0 description: Quarkus helm chart appVersion: 2.0.0 keywords: -- app -- quarkus + - app + - quarkus maintainers: -- name: Tkit Developer - email: tkit-dev@1000kit.org - + - name: Tkit Developer + email: tkit-dev@1000kit.org diff --git a/README.md b/README.md index d60105a..098c480 100644 --- a/README.md +++ b/README.md @@ -5,35 +5,36 @@ Default helm template for OneCX Quarkus application. ## Add to Quarkus apps Add latest `0.x.x` version. + ```yaml - dependencies: - - name: helm-quarkus-app - alias: app - version: ^0 - repository: oci://ghcr.io/onecx/charts +dependencies: + - name: helm-quarkus-app + alias: app + version: ^0 + repository: oci://ghcr.io/onecx/charts ``` ### Config maps -* inject_maps - inject custom map environment variables +- inject_maps - inject custom map environment variables ### Secrets -* env_secrets - map of env key and value which will be put in the secrets `{{ .Release.Name }}-env` - +- env_secrets - map of env key and value which will be put in the secrets `{{ .Release.Name }}-{{ .Values.name | default .Chart.Name }}-env` ### Database Default the internal database is `disabled` -The password for the database is store in the `{{ .Release.Name }}-db-config` secrets. +The password for the database is store in the `{{ .Release.Name }}-{{ .Values.name | default .Chart.Name }}-db-config` secrets. The database is created by the `tkit-db-operator` #### Default configuration External database. -* global.host, global.port will be use to setup the JDBC connection. -* Username, password and database will be set to Release.Name + +- global.host, global.port will be use to setup the JDBC connection. +- Username, password and database will be set to Release.Name ``` app: @@ -43,4 +44,3 @@ app: db: enabled: true ``` - diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 2428eb1..687cccb 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -1,3 +1,7 @@ +{{- define "quarkus.fullname" -}} + {{ .Release.Name }}-{{ .Values.name | default .Chart.Name }} +{{- end -}} + {{- define "quarkus.traefik.path" -}} {{ if .Values.routing.path }} && PathPrefix(`{{ .Values.routing.path }}`){{ end }} {{- end -}} @@ -12,7 +16,7 @@ {{- else if .Values.service.name -}} {{- .Values.service.name -}} {{- else -}} - {{- .Release.Name }} + {{- template "quarkus.fullname" $ }} {{- end -}} {{- end -}} @@ -22,7 +26,7 @@ {{- else if .Values.db.host -}} {{- .Values.db.host -}} {{- else -}} - {{- .Release.Name }}-postgresql + {{- template "quarkus.fullname" $ }}-postgresql {{- end -}} {{- end -}} @@ -39,9 +43,9 @@ {{- .Values.db.database -}} {{- else -}} {{- if not .Values.db.internal -}} - {{ .Release.Namespace | replace "1000kit" "tkit" | replace "-" "_" }}_{{ .Release.Name | replace "-" "_" }} + {{ .Release.Namespace | replace "1000kit" "tkit" | replace "-" "_" }}_{{ template "quarkus.fullname" $ | replace "-" "_" }} {{- else -}} - {{ .Release.Name | replace "-" "_" }} + {{ template "quarkus.fullname" $ | replace "-" "_" }} {{- end -}} {{- end -}} {{- end -}} @@ -50,7 +54,7 @@ {{- if .Values.db.password -}} {{- .Values.db.password -}} {{- else -}} - {{ .Release.Name | replace "-" "_" }} + {{ template "quarkus.fullname" $ | replace "-" "_" }} {{- end -}} {{- end -}} @@ -59,9 +63,9 @@ {{- .Values.db.username -}} {{- else -}} {{- if not .Values.db.internal -}} - {{ .Release.Namespace | replace "1000kit" "tkit" | replace "-" "_" }}_{{ .Release.Name | replace "-" "_" }} + {{ .Release.Namespace | replace "1000kit" "tkit" | replace "-" "_" }}_{{ template "quarkus.fullname" $ | replace "-" "_" }} {{- else -}} - {{ .Release.Name | replace "-" "_" }} + {{ template "quarkus.fullname" $ | replace "-" "_" }} {{- end -}} {{- end -}} {{- end -}} @@ -102,6 +106,6 @@ 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 }} +app.kubernetes.io/name: {{ template "quarkus.fullname" $ }} {{- end -}} diff --git a/templates/config-apm.yaml b/templates/config-apm.yaml index b4e3c2c..b7d9ef3 100644 --- a/templates/config-apm.yaml +++ b/templates/config-apm.yaml @@ -3,12 +3,12 @@ apiVersion: v1 kind: ConfigMap metadata: - name: "{{ .Release.Name }}-apm-config" + name: "{{ template "quarkus.fullname" $ }}-apm-config" annotations: - appId: {{ .Release.Name }} + appId: {{ template "quarkus.fullname" $ }} filename: "permissions.csv" labels: - app: {{ .Release.Name }} + app: {{ template "quarkus.fullname" $ }} {{ include "quarkus.labels.common" $ | indent 4 }} data: permissions.csv: |- diff --git a/templates/config-data-mgmt.yaml b/templates/config-data-mgmt.yaml index 3a05e48..1152388 100644 --- a/templates/config-data-mgmt.yaml +++ b/templates/config-data-mgmt.yaml @@ -3,14 +3,14 @@ apiVersion: v1 kind: ConfigMap metadata: - name: "{{ .Release.Name }}-data-mgmt-config" + name: "{{ template "quarkus.fullname" $ }}-data-mgmt-config" labels: - app: {{ .Release.Name }} + app: {{ template "quarkus.fullname" $ }} {{ include "quarkus.labels.common" $ | indent 4 }} data: datasource-config: |- { - "fileNamePrefix": "{{ .Values.operator.data.mgmt.prefix | default .Release.Name }}", + "fileNamePrefix": "{{ .Values.operator.data.mgmt.prefix | default (include "quarkus.fullname" $) }}", "dbType": "{{ .Values.operator.data.mgmt.dbType }}", "url": {{ include "quarkus.db.url" $ }}, "user": "{{ include "quarkus.db.username" $ }}", diff --git a/templates/config-db.yaml b/templates/config-db.yaml index 5151b6a..bdedca5 100644 --- a/templates/config-db.yaml +++ b/templates/config-db.yaml @@ -2,11 +2,11 @@ apiVersion: v1 kind: Secret metadata: - name: {{ .Release.Name }}-db-config + name: {{ template "quarkus.fullname" $ }}-db-config annotations: org.tkit.db.operator/database: {{ include "quarkus.db.host" $ }} labels: - app: {{ .Release.Name }} + app: {{ template "quarkus.fullname" $ }} {{ include "quarkus.labels.common" $ | indent 4 }} type: Opaque stringData: diff --git a/templates/config-keycloak.yaml b/templates/config-keycloak.yaml index bae4023..e007881 100644 --- a/templates/config-keycloak.yaml +++ b/templates/config-keycloak.yaml @@ -2,11 +2,11 @@ apiVersion: v1 kind: ConfigMap metadata: - name: "{{ .Release.Name }}-kc-config" + name: "{{ template "quarkus.fullname" $ }}-kc-config" annotations: tkit.kc.cli/target-realm: {{ .Values.global.operator.keycloak.realm | default .Values.operator.keycloak.realm }} labels: - app: {{ .Release.Name }} + app: {{ template "quarkus.fullname" $ }} {{ include "quarkus.labels.common" $ | indent 4 }} data: {{ if .Values.operator.keycloak.client }} diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 9260873..eb3484e 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -1,19 +1,19 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ .Release.Name }} + name: {{ template "quarkus.fullname" $ }} labels: - app: {{ .Release.Name }} + app: {{ template "quarkus.fullname" $ }} {{ include "quarkus.labels.common" $ | indent 4 }} spec: replicas: {{ .Values.replicas }} selector: matchLabels: - app: {{ .Release.Name }} + app: {{ template "quarkus.fullname" $ }} template: metadata: labels: - app: {{ .Release.Name }} + app: {{ template "quarkus.fullname" $ }} {{ include "quarkus.labels.common" $ | indent 8 }} annotations: {{- range $map_name := .Values.inject_maps }} @@ -23,30 +23,30 @@ spec: checksum/{{ $map_name | replace "-" "_" }}: {{ index $.Values.global ($map_name | replace "-" "_") }} {{- end }} {{- if .Values.operator.keycloak.enabled }} - checksum/{{ $.Release.Name }}-config-keycloak: {{ include (print $.Template.BasePath "/config-keycloak.yaml") . | sha256sum }} + checksum/{{ template "quarkus.fullname" $ }}-config-keycloak: {{ include (print $.Template.BasePath "/config-keycloak.yaml") . | sha256sum }} {{- end }} {{- if and (.Values.operator.apm.enabled) (.Values.operator.apm.permissions) }} - checksum/{{ $.Release.Name }}-config-apm: {{ include (print $.Template.BasePath "/config-apm.yaml") . | sha256sum }} + checksum/{{ template "quarkus.fullname" $ }}-config-apm: {{ include (print $.Template.BasePath "/config-apm.yaml") . | sha256sum }} {{- end }} {{- if and (.Values.db.enabled) (.Values.operator.data.mgmt.enabled) }} - checksum/{{ $.Release.Name }}-config-data-mgmt: {{ include (print $.Template.BasePath "/config-data-mgmt.yaml") . | sha256sum }} + checksum/{{ template "quarkus.fullname" $ }}-config-data-mgmt: {{ include (print $.Template.BasePath "/config-data-mgmt.yaml") . | sha256sum }} {{- end }} {{- if .Values.db.enabled }} - checksum/{{ $.Release.Name }}-config-db: {{ include (print $.Template.BasePath "/config-db.yaml") . | sha256sum }} + checksum/{{ template "quarkus.fullname" $ }}-config-db: {{ include (print $.Template.BasePath "/config-db.yaml") . | sha256sum }} {{- end }} {{- if .Values.env_secrets }} - checksum/{{ $.Release.Name }}-env: {{ include (print $.Template.BasePath "/secret-env.yaml") . | sha256sum }} + checksum/{{ template "quarkus.fullname" $ }}-env: {{ include (print $.Template.BasePath "/secret-env.yaml") . | sha256sum }} {{- end }} spec: {{- if .Values.serviceAccountSuffix }} - serviceAccountName: {{ .Release.Name }}-{{ .Values.serviceAccountSuffix }} + serviceAccountName: {{ template "quarkus.fullname" $ }}-{{ .Values.serviceAccountSuffix }} {{- end }} {{- if .Values.imagePullSecrets }} imagePullSecrets: - name: {{ .Values.imagePullSecrets }} {{- end }} containers: - - name: {{ .Release.Name }} + - name: {{ template "quarkus.fullname" $ }} image: {{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }} imagePullPolicy: Always ports: @@ -80,7 +80,7 @@ spec: - name: {{ .Values.template.db_property_password }} valueFrom: secretKeyRef: - name: {{ .Release.Name }}-db-config + name: {{ template "quarkus.fullname" $ }}-db-config key: password {{- end }} {{- $envVals := .Values.global.env -}} @@ -100,7 +100,7 @@ spec: valueFrom: secretKeyRef: key: {{ $secret_key }} - name: {{ $.Release.Name }}-env + name: {{ template "quarkus.fullname" $ }}-env {{- end }} {{- end }} @@ -138,7 +138,7 @@ spec: - name: PGPASSWORD valueFrom: secretKeyRef: - name: {{ .Release.Name }}-db-config + name: {{ template "quarkus.fullname" $ }}-db-config key: password - name: DISABLE_WELCOME_MESSAGE value: "true" diff --git a/templates/ingress.yaml b/templates/ingress.yaml index 80cfd44..18c4f4b 100644 --- a/templates/ingress.yaml +++ b/templates/ingress.yaml @@ -3,20 +3,22 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: {{ .Release.Name }}-ingress + name: {{ template "quarkus.fullname" $ }}-ingress labels: - app: {{ .Release.Name }} -{{ include "quarkus.labels.common" $ | indent 4 }} - annotations: + app: {{ template "quarkus.fullname" $ }} +{{ include "quarkus.labels.common" $ | indent 4 }} + annotations: {{- if (.Values.prometheus | default false) }} prometheus.io/ingress: '{{ .Values.routing.prometheus.ingress | default "true" }}' prometheus.io/ingress_path: '{{ .Values.routing.prometheus.ingress_path | default $.Values.livenessProbe.url }}' -{{- end }} +{{- end }} +{{- if .Values.routing.stripprefix }} + traefik.ingress.kubernetes.io/router.middlewares: '{{ .Release.Namespace }}-{{ template "quarkus.fullname" $ }}-middleware@kubernetescrd' +{{- end }} {{ toYaml .Values.routing.ingress.annotations | indent 4 }} spec: rules: - - host: {{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.global.default_url | default .Values.routing.default_url }} - http: + - http: paths: - path: {{ .Values.routing.path | default "/" }} pathType: Prefix @@ -25,5 +27,12 @@ spec: name: {{ include "quarkus.routing.service" $ }} port: number: {{ .Values.routing.service.port | default .Values.service.port }} + {{ if .Values.routing.ingress.host.override }} + host: {{ .Values.routing.ingress.host.override }}.{{ .Values.global.default_url | default .Values.routing.default_url }} + {{ else if .Values.routing.ingress.host.name }} + host: {{ .Values.routing.ingress.host.name }}-{{ .Release.Namespace }}.{{ .Values.global.default_url | default .Values.routing.default_url }} + {{ else }} + host: {{ template "quarkus.fullname" $ }}-{{ .Release.Namespace }}.{{ .Values.global.default_url | default .Values.routing.default_url }} + {{- end }} {{ end }} {{ end }} \ No newline at end of file diff --git a/templates/middleware-strip.yaml b/templates/middleware-strip.yaml index b53d5cb..1337b69 100644 --- a/templates/middleware-strip.yaml +++ b/templates/middleware-strip.yaml @@ -4,7 +4,7 @@ apiVersion: traefik.containo.us/v1alpha1 kind: Middleware metadata: - name: {{ .Release.Name }}-{{ .Release.Namespace }}-middleware + name: {{ template "quarkus.fullname" $ }}-middleware spec: stripPrefix: prefixes: diff --git a/templates/secret-env.yaml b/templates/secret-env.yaml index dfe111c..53690b3 100644 --- a/templates/secret-env.yaml +++ b/templates/secret-env.yaml @@ -2,9 +2,9 @@ apiVersion: v1 kind: Secret metadata: - name: {{ .Release.Name }}-env + name: {{ template "quarkus.fullname" $ }}-env labels: - app: {{ .Release.Name }} + app: {{ template "quarkus.fullname" $ }} {{ include "quarkus.labels.common" $ | indent 4 }} stringData: {{- range $key,$val := .Values.env_secrets }} diff --git a/templates/service.yaml b/templates/service.yaml index 9dd4020..a53bdf3 100644 --- a/templates/service.yaml +++ b/templates/service.yaml @@ -1,14 +1,17 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - name: {{ .Release.Name }} + name: {{ template "quarkus.fullname" $ }} labels: - app: {{ .Release.Name }} -{{ include "quarkus.labels.common" $ | indent 4 }} + app: {{ template "quarkus.fullname" $ }} +{{ include "quarkus.labels.common" $ | indent 4 }} + annotations: + description: {{ template "quarkus.fullname" $ }} spec: selector: - app: {{ .Release.Name }} + app: {{ template "quarkus.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 index 19cfc52..4c1a6ce 100644 --- a/templates/traefik.yaml +++ b/templates/traefik.yaml @@ -3,9 +3,9 @@ kind: IngressRoute apiVersion: traefik.containo.us/v1alpha1 metadata: - name: {{ .Release.Name }}-{{ .Release.Namespace }} + name: {{ template "quarkus.fullname" $ }} labels: - app: {{ .Release.Name }} + app: {{ template "quarkus.fullname" $ }} {{ include "quarkus.labels.common" $ | indent 4 }} spec: entryPoints: @@ -17,20 +17,20 @@ spec: {{ end }} routes: - kind: Rule - {{ if .Values.global.hostName }} - match: Host(`{{ .Values.global.hostName }}`){{ include "quarkus.traefik.path" $ }} - {{ else if .Values.routing.hostName }} - match: Host(`{{ .Values.routing.hostName }}`){{ include "quarkus.traefik.path" $ }} - {{ else }} - match: Host(`{{ .Release.Name }}-{{ .Release.Namespace }}.{{ .Values.global.default_url | default .Values.routing.default_url }}`){{ include "quarkus.traefik.path" $ }} - {{ end }} - {{ if .Values.routing.stripprefix }} + {{ if .Values.routing.ingress.host.override }} + match: Host(`{{ .Values.routing.ingress.host.override }}.{{ .Values.global.default_url | default .Values.routing.default_url }}`){{ include "quarkus.traefik.path" $ }} + {{ else if .Values.routing.ingress.host.name }} + match: Host(`{{ .Values.routing.ingress.host.name }}-{{ .Release.Namespace }}.{{ .Values.global.default_url | default .Values.routing.default_url }}`){{ include "quarkus.traefik.path" $ }} + {{ else }} + match: Host(`{{ template "quarkus.fullname" $ }}-{{ .Release.Namespace }}.{{ .Values.global.default_url | default .Values.routing.default_url }}`){{ include "quarkus.traefik.path" $ }} + {{- end }} + {{- if .Values.routing.stripprefix }} middlewares: - - name: {{ .Release.Name }}-{{ .Release.Namespace }}-middleware + - name: {{ template "quarkus.fullname" $ }}-middleware {{ end }} services: - kind: Service - name: {{ .Release.Name }} + name: {{ template "quarkus.fullname" $ }} port: {{ .Values.service.port }} {{ end }} {{ end }} diff --git a/values.yaml b/values.yaml index 321eb11..a5de218 100644 --- a/values.yaml +++ b/values.yaml @@ -13,6 +13,9 @@ global: host: admin: {} +# Name of the instance, default {{ .Release.Name }}-{{ .Values.name | default .Chart.Name }} +name: + # Application image image: # Docker registry @@ -25,10 +28,10 @@ image: # Image pull secrets imagePullSecrets: -# health +# health livenessProbe: url: /q/health/live - + readinessProbe: url: /q/health/ready @@ -66,6 +69,13 @@ routing: ingress: annotations: ingress.kubernetes.io/ssl-redirect: "false" + # host configuration + host: + # prio1 if the name is define generate domain . + override: + # prio2 if the name is define generate domain -. + name: + # else --. # custom service name and port for the routing service: name: @@ -75,7 +85,7 @@ routing: replicas: 1 # Service account suffix -# serviceAccountName = Release.Name-serviceAccountSuffix +# serviceAccountName = {{ .Release.Name }}-{{ .Values.name | default .Chart.Name }}-serviceAccountSuffix serviceAccountSuffix: # Inject config maps @@ -85,19 +95,19 @@ inject_maps: [] db: # Enable or disable database connection enabled: false - + # Database name database: - + # Database username username: - + # Database password password: # Database port port: 5432 - + # JDBC url. Generated # url: "jdbc:postgresql://localhost:5432/changeit" @@ -123,7 +133,7 @@ operator: prefix: # schema schema: public - + # APM operator apm: # enabled or disable config for operator