Skip to content

Commit

Permalink
fix: Changing .chart.name reference, adding name override (#1129)
Browse files Browse the repository at this point in the history
Signed-off-by: Milos Backonja <[email protected]>
  • Loading branch information
milosbackonja authored Jun 3, 2024
1 parent 3608aaf commit 650ae3b
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 49 deletions.
34 changes: 33 additions & 1 deletion infrastructure/charts/agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cloud-agent.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 "cloud-agent.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 "cloud-agent.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "cors" }}
{{- if .Values.ingress.cors.enabled }}
- name: cors
Expand All @@ -21,7 +53,7 @@
{{- end }}
{{- end -}}
{{- define "labels.common" -}}
app.kubernetes.io/part-of: {{ .Chart.Name }}
app.kubernetes.io/part-of: {{ include "cloud-agent.fullname" . }}
{{- end -}}
{{- define "headers.security" }}
- name: response-rewrite
Expand Down
20 changes: 10 additions & 10 deletions infrastructure/charts/agent/templates/apisixroute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
{{- end }}
paths:
- /prism-agent/*
- /{{ .Chart.Name }}/*
- /{{ include "cloud-agent.fullname" . }}/*
backends:
- serviceName: agent-server-tapir-service
servicePort: 8085
Expand All @@ -27,7 +27,7 @@ spec:
- name: proxy-rewrite
enable: true
config:
regex_uri: ["^/(prism-agent|{{ .Chart.Name }})/(.*)","/$2"]
regex_uri: ["^/(prism-agent|{{ include "cloud-agent.fullname" . }})/(.*)","/$2"]
- name: uri-blocker
enable: true
config:
Expand Down Expand Up @@ -57,15 +57,15 @@ spec:
{{- end }}
paths:
- /prism-agent/didcomm*
- /{{ .Chart.Name }}/didcomm*
- /{{ include "cloud-agent.fullname" . }}/didcomm*
backends:
- serviceName: agent-server-didcomm-service
servicePort: 8090
plugins:
- name: proxy-rewrite
enable: true
config:
regex_uri: ["^/(prism-agent|{{ .Chart.Name }})/didcomm(.*)", "/$2"]
regex_uri: ["^/(prism-agent|{{ include "cloud-agent.fullname" . }})/didcomm(.*)", "/$2"]
{{ template "cors" . }}
{{ template "headers.requestId" . }}
{{ template "headers.security" . }}
Expand All @@ -89,7 +89,7 @@ spec:
{{- end }}
paths:
- /prism-agent/schema-registry/schemas/*
- /{{ .Chart.Name }}/schema-registry/schemas/*
- /{{ include "cloud-agent.fullname" . }}/schema-registry/schemas/*
methods:
- GET
backends:
Expand All @@ -99,7 +99,7 @@ spec:
- name: proxy-rewrite
enable: true
config:
regex_uri: ["^/(prism-agent|{{ .Chart.Name }})/schema-registry/schemas/(.*)", "/schema-registry/schemas/$2"]
regex_uri: ["^/(prism-agent|{{ include "cloud-agent.fullname" . }})/schema-registry/schemas/(.*)", "/schema-registry/schemas/$2"]
{{ template "cors" . }}
{{ template "headers.requestId" . }}
{{ template "headers.security" . }}
Expand All @@ -123,7 +123,7 @@ spec:
{{- end }}
paths:
- /prism-agent/credential-definition-registry/definitions/*
- /{{ .Chart.Name }}/credential-definition-registry/definitions/*
- /{{ include "cloud-agent.fullname" . }}/credential-definition-registry/definitions/*
methods:
- GET
backends:
Expand All @@ -133,7 +133,7 @@ spec:
- name: proxy-rewrite
enable: true
config:
regex_uri: ["^/(prism-agent|{{ .Chart.Name }})/credential-definition-registry/definitions/(.*)", "/credential-definition-registry/definitions/$2"]
regex_uri: ["^/(prism-agent|{{ include "cloud-agent.fullname" . }})/credential-definition-registry/definitions/(.*)", "/credential-definition-registry/definitions/$2"]
{{ template "cors" . }}
{{ template "headers.requestId" . }}
{{ template "headers.security" . }}
Expand All @@ -157,15 +157,15 @@ spec:
{{- end }}
paths:
- /prism-agent/docs/*
- /{{ .Chart.Name }}/docs/*
- /{{ include "cloud-agent.fullname" . }}/docs/*
backends:
- serviceName: agent-server-tapir-service
servicePort: 8085
plugins:
- name: proxy-rewrite
enable: true
config:
regex_uri: ["^/(prism-agent|{{ .Chart.Name }})/docs/(.*)","/docs/$2"]
regex_uri: ["^/(prism-agent|{{ include "cloud-agent.fullname" . }})/docs/(.*)","/docs/$2"]
{{ template "cors" . }}
{{ template "headers.requestId" . }}
{{ template "headers.security" . }}
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/charts/agent/templates/apisixtls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: apisix.apache.org/v2
kind: ApisixTls
metadata:
name: "{{ .Chart.Name }}-base-path-tls"
name: "{{ include "cloud-agent.fullname" . }}-base-path-tls"
namespace: "{{ .Release.Namespace }}"
labels:
{{ template "labels.common" . }}
Expand All @@ -12,6 +12,6 @@ spec:
- {{ . }}
{{- end }}
secret:
name: "{{ .Chart.Name }}-base-path-secret"
name: "{{ include "cloud-agent.fullname" . }}-base-path-secret"
namespace: "{{ .Release.Namespace }}"
{{- end }}
4 changes: 2 additions & 2 deletions infrastructure/charts/agent/templates/certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: "{{ .Chart.Name }}-base-path-cert"
name: "{{ include "cloud-agent.fullname" . }}-base-path-cert"
namespace: "{{ .Release.Namespace }}"
labels:
{{ template "labels.common" . }}
annotations:
argocd.argoproj.io/sync-wave: "-1"
spec:
secretName: "{{ .Chart.Name }}-base-path-secret"
secretName: "{{ include "cloud-agent.fullname" . }}-base-path-secret"
duration: 2160h0m0s # 90d
renewBefore: 360h0m0s # 15d
issuerRef:
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/charts/agent/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ data:
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Chart.Name }}-realm-import
name: {{ include "cloud-agent.fullname" . }}-realm-import
data:
{{ .Chart.Name }}.json: |
{{ include "cloud-agent.fullname" . }}.json: |
{
"realm": {{ .Values.server.keycloak.realm | quote }},
"enabled": true
Expand Down
44 changes: 22 additions & 22 deletions infrastructure/charts/agent/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Chart.Name }}-server
name: {{ include "cloud-agent.fullname" . }}-server
namespace: "{{ .Release.Namespace }}"
labels:
{{ template "labels.common" . }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ .Chart.Name }}-server
app.kubernetes.io/name: {{ include "cloud-agent.fullname" . }}-server
replicas: 1
template:
metadata:
labels:
app.kubernetes.io/name: {{ .Chart.Name }}-server
app.kubernetes.io/name: {{ include "cloud-agent.fullname" . }}-server
{{ template "labels.common" . }}
spec:
imagePullSecrets:
- name: atala-prism-dev-deployments-github-docker-registry-key
initContainers:
- name: wait-postgress-ready
image: busybox
command: ['sh', '-c', "until nc -z {{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.{{.Release.Namespace}} 5432; do echo waiting for postgress-operator; sleep 2; done;"]
command: ['sh', '-c', "until nc -z {{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.{{.Release.Namespace}} 5432; do echo waiting for postgress-operator; sleep 2; done;"]
{{- if .Values.server.keycloak.enabled }}
- name: wait-keycloak-ready
image: badouralix/curl-jq:ubuntu
Expand Down Expand Up @@ -52,7 +52,7 @@ spec:
{{- end }}
{{- end }}
containers:
- name: {{ .Chart.Name }}-server
- name: {{ include "cloud-agent.fullname" . }}-server
image: "{{ .Values.server.image.repository }}/{{ .Values.server.image.tag }}:{{ .Values.server.image.version | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.server.image.pullPolicy }}
livenessProbe:
Expand All @@ -78,99 +78,99 @@ spec:
key: salt
optional: false
- name: POLLUX_DB_HOST
value: "{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.{{.Release.Namespace}}"
value: "{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.{{.Release.Namespace}}"
- name: POLLUX_DB_PORT
value: "5432"
- name: POLLUX_DB_NAME
value: pollux
- name: POLLUX_DB_USER
valueFrom:
secretKeyRef:
name: pollux-admin.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: pollux-admin.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: username
optional: false
- name: POLLUX_DB_PASSWORD
valueFrom:
secretKeyRef:
name: pollux-admin.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: pollux-admin.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: password
optional: false
- name: POLLUX_DB_APP_USER
valueFrom:
secretKeyRef:
name: pollux-application-user.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: pollux-application-user.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: username
optional: false
- name: POLLUX_DB_APP_PASSWORD
valueFrom:
secretKeyRef:
name: pollux-application-user.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: pollux-application-user.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: password
optional: false
- name: CONNECT_DB_HOST
value: "{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.{{.Release.Namespace}}"
value: "{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.{{.Release.Namespace}}"
- name: CONNECT_DB_PORT
value: "5432"
- name: CONNECT_DB_NAME
value: connect
- name: CONNECT_DB_USER
valueFrom:
secretKeyRef:
name: connect-admin.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: connect-admin.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: username
optional: false
- name: CONNECT_DB_PASSWORD
valueFrom:
secretKeyRef:
name: connect-admin.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: connect-admin.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: password
optional: false
- name: CONNECT_DB_APP_USER
valueFrom:
secretKeyRef:
name: connect-application-user.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: connect-application-user.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: username
optional: false
- name: CONNECT_DB_APP_PASSWORD
valueFrom:
secretKeyRef:
name: connect-application-user.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: connect-application-user.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: password
optional: false
- name: AGENT_DB_HOST
value: "{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.{{.Release.Namespace}}"
value: "{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.{{.Release.Namespace}}"
- name: AGENT_DB_PORT
value: "5432"
- name: AGENT_DB_NAME
value: agent
- name: AGENT_DB_USER
valueFrom:
secretKeyRef:
name: agent-admin.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: agent-admin.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: username
optional: false
- name: AGENT_DB_PASSWORD
valueFrom:
secretKeyRef:
name: agent-admin.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: agent-admin.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: password
optional: false
- name: AGENT_DB_APP_USER
valueFrom:
secretKeyRef:
name: agent-application-user.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: agent-application-user.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: username
optional: false
- name: AGENT_DB_APP_PASSWORD
valueFrom:
secretKeyRef:
name: agent-application-user.{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster.credentials.postgresql.acid.zalan.do
name: agent-application-user.{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster.credentials.postgresql.acid.zalan.do
key: password
optional: false
- name: DIDCOMM_SERVICE_URL
value: "https://{{ index .Values.ingress.applicationUrls 0 }}/{{ .Chart.Name }}/didcomm"
value: "https://{{ index .Values.ingress.applicationUrls 0 }}/{{ include "cloud-agent.fullname" . }}/didcomm"
- name: REST_SERVICE_URL
value: "https://{{ index .Values.ingress.applicationUrls 0 }}/{{ .Chart.Name }}"
value: "https://{{ index .Values.ingress.applicationUrls 0 }}/{{ include "cloud-agent.fullname" . }}"
- name: PRISM_NODE_HOST
value: {{ .Values.vdrManager.host | quote }}
- name: PRISM_NODE_PORT
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/charts/agent/templates/postgresql.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
name: "{{ .Values.database.postgres.managingTeam }}-{{ .Chart.Name }}-postgres-cluster"
name: "{{ .Values.database.postgres.managingTeam }}-{{ include "cloud-agent.fullname" . }}-postgres-cluster"
namespace: {{ .Release.Namespace }}
labels:
{{ template "labels.common" . }}
Expand Down
18 changes: 9 additions & 9 deletions infrastructure/charts/agent/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ metadata:
name: agent-server-tapir-service
namespace: "{{ .Release.Namespace }}"
labels:
app.kubernetes.io/name: {{ .Chart.Name }}-server
app.kubernetes.io/service: {{ .Chart.Name }}-server-main
app.kubernetes.io/name: {{ include "cloud-agent.fullname" . }}-server
app.kubernetes.io/service: {{ include "cloud-agent.fullname" . }}-server-main
{{ template "labels.common" . }}
spec:
selector:
app.kubernetes.io/name: {{ .Chart.Name }}-server
app.kubernetes.io/name: {{ include "cloud-agent.fullname" . }}-server
ports:
- name: {{ .Chart.Name }}-server-main
- name: {{ include "cloud-agent.fullname" . }}-server-main
protocol: "TCP"
port: 8085
targetPort: 8085
Expand All @@ -25,14 +25,14 @@ metadata:
name: agent-server-didcomm-service
namespace: "{{ .Release.Namespace }}"
labels:
app.kubernetes.io/name: {{ .Chart.Name }}-server
app.kubernetes.io/service: {{ .Chart.Name }}-server-didcomm
app.kubernetes.io/name: {{ include "cloud-agent.fullname" . }}-server
app.kubernetes.io/service: {{ include "cloud-agent.fullname" . }}-server-didcomm
{{ template "labels.common" . }}
spec:
selector:
app.kubernetes.io/name: {{ .Chart.Name }}-server
app.kubernetes.io/name: {{ include "cloud-agent.fullname" . }}-server
ports:
- name: {{ .Chart.Name }}-server-didcomm
- name: {{ include "cloud-agent.fullname" . }}-server-didcomm
protocol: "TCP"
port: 8090
targetPort: 8090
Expand All @@ -49,7 +49,7 @@ metadata:
annotations:
external-dns.alpha.kubernetes.io/hostname: "{{ join ", " .Values.ingress.applicationUrls }}"
labels:
app.kubernetes.io/name: {{ .Chart.Name }}-server
app.kubernetes.io/name: {{ include "cloud-agent.fullname" . }}-server
app.kubernetes.io/service: agent-server-domain-name-fake
{{ template "labels.common" . }}
spec:
Expand Down
Loading

0 comments on commit 650ae3b

Please sign in to comment.