Commit caaf0f3d authored by Nikos Psaromanolakis's avatar Nikos Psaromanolakis
Browse files

feat: add generic cases for different name and namespace

parent 3c5c7430
Loading
Loading
Loading
Loading
Loading
+22 −13
Original line number Diff line number Diff line
@@ -121,6 +121,15 @@ Create Fabric name and version as used by the chart label.
{{- printf "%s-%s" (include "hypo.fullname" .) $fabricApi.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create Service Monitor name and version as used by the chart label.
*/}}
{{- define "hypo.service-monitor.fullname" -}}
{{ $serviceMonitor := index .Values "service-monitor" }}
{{- printf "%s-%s" (include "hypo.fullname" .) $serviceMonitor.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}


{{/*
Create Infinispan name and version as used by the chart label.
*/}}
@@ -165,7 +174,7 @@ Create Keycloak name and version as used by the chart label.
*/}}
{{- define "hypo.keycloak.fullname" -}}
{{- if .Values.keycloak.setup -}}
{{- printf "%s-keycloak" (include "hypo.fullname" .) | trunc 63 | trimSuffix "-" -}}
{{- printf "%s-keycloak" .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

@@ -176,7 +185,7 @@ Create Grafana name and version as used by the chart label.
{{- define "hypo.grafana.fullname" -}}
{{ $kubePrometheusStack := index .Values "kube-prometheus-stack" }}
{{- if $kubePrometheusStack.setup -}}
{{- printf "%s-grafana" (include "hypo.fullname" .) -}}
{{- printf "%s-grafana" .Release.Name -}}
{{- end -}}
{{- end -}}

@@ -186,7 +195,7 @@ Create Prometheus name and version as used by the chart label.
{{- define "hypo.prometheus.fullname" -}}
{{ $kubePrometheusStack := index .Values "kube-prometheus-stack" }}
{{- if $kubePrometheusStack.setup -}}
{{- printf "%s-kube-prometheus-stack-prometheus" (include "hypo.fullname" .) -}}
{{- printf "%s-kube-prometheus-stack-prometheus" .Release.Name -}}
{{- end -}}
{{- end -}}

@@ -234,7 +243,7 @@ Create connection string for Vault Server.
{{- end -}}

{{/*
Create connection string for Vault Server.
Create connection string for Registry API.
*/}} 
{{- define "hypo.registry-api.url" -}}
{{ $registryApi := index .Values "registry-api" }}
@@ -259,7 +268,7 @@ Create connection string for Grafana.
{{- define "hypo.grafana.url" -}}
{{ $kubePrometheusStack := index .Values "kube-prometheus-stack" }}
{{- if $kubePrometheusStack.setup -}}
{{- printf "%s-grafana.%s.svc.cluster.local" (include "hypo.fullname" .) .Release.Namespace -}}
{{- printf "%s-grafana.%s.svc.cluster.local" .Release.Name .Release.Namespace -}}
{{- end -}}
{{- end -}}

@@ -269,7 +278,7 @@ Create connection string for Prometheus.
{{- define "hypo.prometheus.url" -}}
{{ $kubePrometheusStack := index .Values "kube-prometheus-stack" }}
{{- if $kubePrometheusStack.setup -}}
{{- printf "%s-kube-prometheus-st-prometheus.%s.svc.cluster.local" (include "hypo.fullname" .) .Release.Namespace -}}
{{- printf "%s-kube-prometheus-st-prometheus.%s.svc.cluster.local" .Release.Name .Release.Namespace -}}
{{- end -}}
{{- end -}}

@@ -278,7 +287,7 @@ Create connection string for Loki.
*/}} 
{{- define "hypo.loki.url" -}}
{{- if .Values.loki.setup -}}
{{- printf "%s-loki.%s.svc.cluster.local" (include "hypo.fullname" .) .Release.Namespace -}}
{{- printf "%s-loki.%s.svc.cluster.local" .Release.Name .Release.Namespace -}}
{{- end -}}
{{- end -}}

@@ -287,7 +296,7 @@ Create connection string for Tempo.
*/}} 
{{- define "hypo.tempo.url" -}}
{{- if .Values.tempo.setup -}}
{{- printf "%s-tempo.%s.svc.cluster.local" (include "hypo.fullname" .) .Release.Namespace -}}
{{- printf "%s-tempo.%s.svc.cluster.local" .Release.Name .Release.Namespace -}}
{{- end -}}
{{- end -}}

@@ -296,7 +305,7 @@ Create connection string for Zookeeper.
*/}} 
{{- define "hypo.zookeeper.url" -}}
{{- if .Values.kafka.zookeeper.enabled -}}
{{- printf "%s-zookeeper.%s.svc.cluster.local" (include "hypo.fullname" .) .Release.Namespace -}}
{{- printf "%s-zookeeper.%s.svc.cluster.local" .Release.Name .Release.Namespace -}}
{{- end -}}
{{- end -}}

@@ -305,7 +314,7 @@ Create connection string for Kafka.
*/}} 
{{- define "hypo.kafka.url" -}}
{{- if .Values.kafka.setup -}}
{{- printf "%s-%s.%s.svc.cluster.local" (include "hypo.fullname" .) .Values.kafka.nameOverride .Release.Namespace -}}
{{- printf "%s-%s.%s.svc.cluster.local" .Release.Name .Values.kafka.nameOverride .Release.Namespace -}}
{{- end -}}
{{- end -}}

@@ -315,7 +324,7 @@ Create connection string for Postgres.
{{- define "hypo.postgresql.url" -}}
{{ $postgresql := index .Values "postgresql-db" }}
{{- if $postgresql.setup -}}
{{- printf "%s-postgresql-db.%s.svc.cluster.local" (include "hypo.fullname" .) .Release.Namespace -}}
{{- printf "%s-postgresql-db.%s.svc.cluster.local" .Release.Name .Release.Namespace -}}
{{- end -}}
{{- end -}}

@@ -334,7 +343,7 @@ Create connection string for PgAdmin.
*/}} 
{{- define "hypo.pgadmin.url" -}}
{{- if .Values.pgadmin.setup -}}
{{- printf "%s-pgadmin.%s.svc.cluster.local" (include "hypo.fullname" .) .Release.Namespace -}}
{{- printf "%s-pgadmin.%s.svc.cluster.local" .Release.Name .Release.Namespace -}}
{{- end -}}
{{- end -}}

@@ -362,7 +371,7 @@ Create connection string for Otel Collector.
{{- define "hypo.otel.url" -}}
{{ $otelCollector := index .Values "otel-collector" }}
{{- if $otelCollector.enabled -}}
{{- printf "%s-otel-collector.%s.svc.cluster.local" (include "hypo.fullname" .) .Release.Namespace -}}
{{- printf "%s-otel-collector.%s.svc.cluster.local" .Release.Name .Release.Namespace -}}
{{- end -}}
{{- end -}}

+2 −1
Original line number Diff line number Diff line
{{ $ingressNginx := index .Values "ingress-nginx" }}
{{ $fabricApi := index .Values "fabric-api" }}
{{- if $fabricApi.enabled -}}
apiVersion: networking.k8s.io/v1
@@ -8,7 +9,7 @@ metadata:
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  ingressClassName: nginx
  ingressClassName: {{ $ingressNginx.controller.ingressClass }}
  rules:
  - http:
      paths:
+3 −2
Original line number Diff line number Diff line
{{ $ingressNginx := index .Values "ingress-nginx" }}
{{ $kubePrometheusStack := index .Values "kube-prometheus-stack" }}
{{- if $kubePrometheusStack.setup -}}
apiVersion: networking.k8s.io/v1
@@ -8,7 +9,7 @@ metadata:
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  ingressClassName: nginx
  ingressClassName: {{ $ingressNginx.controller.ingressClass }}
  rules:
  - http:
      paths:
+43 −14
Original line number Diff line number Diff line
{{ $ingressNginx := index .Values "ingress-nginx" }}
{{ $kubePrometheusStack := index .Values "kube-prometheus-stack" }}
apiVersion: batch/v1
kind: Job
@@ -16,7 +17,16 @@ spec:
        - name: wait-for-grafana
          image: busybox:latest
          imagePullPolicy: IfNotPresent
          args: [ 'sh', '-c', 'until nc -z -w 1 {{ template "hypo.grafana.url" . }} {{ $kubePrometheusStack.grafana.service.port }}; do echo "Sleeping for Grafana"; sleep 1; done; echo "ready!";' ]
          args:
            - sh
            - -c
            - >
              until nc -z -w 1 {{ template "hypo.grafana.url" . }} {{ $kubePrometheusStack.grafana.service.port }};
              do
                echo "Sleeping for Grafana";
                sleep 1;
              done;
              echo "ready!";

      serviceAccountName: grafana-patcher
      restartPolicy: Never
@@ -31,6 +41,12 @@ spec:
                fieldRef:
                  fieldPath: status.hostIP

            - name: RELEASE_NAME
              value: "{{ .Release.Name }}"

            - name: RELEASE_NAMESPACE
              value: "{{ .Release.Namespace }}"

          command:
            - /bin/sh
            - -c
@@ -39,24 +55,37 @@ spec:

              echo "Detected node IP: ${NODE_IP}"

              kubectl get cm hypo-grafana -o yaml > /tmp/cm.yaml
              kubectl get cm "${RELEASE_NAME}-grafana" \
                -n "${RELEASE_NAMESPACE}" \
                -o yaml > /tmp/cm.yaml

              sed -i "s|__NODE_IP__|${NODE_IP}|g" /tmp/cm.yaml

              kubectl apply -f /tmp/cm.yaml
              kubectl apply \
                -n "${RELEASE_NAMESPACE}" \
                -f /tmp/cm.yaml

              kubectl get deployment hypo-grafana -o yaml > /tmp/deploy.yaml
              kubectl get deployment "${RELEASE_NAME}-grafana" \
                -n "${RELEASE_NAMESPACE}" \
                -o yaml > /tmp/deploy.yaml

              sed -i "s|__NODE_IP__|${NODE_IP}|g" /tmp/deploy.yaml

              kubectl apply -f /tmp/deploy.yaml
              kubectl apply \
                -n "${RELEASE_NAMESPACE}" \
                -f /tmp/deploy.yaml

              kubectl rollout restart deployment/hypo-grafana
              kubectl rollout restart \
                deployment/"${RELEASE_NAME}-grafana" \
                -n "${RELEASE_NAMESPACE}"

              kubectl patch prometheus hypo-kube-prometheus-stack-prometheus \
              kubectl patch prometheus \
                "${RELEASE_NAME}-kube-prometheus-stack-prometheus" \
                -n "${RELEASE_NAMESPACE}" \
                --type merge \
                -p "{
                  \"spec\": {
                  \"externalUrl\": \"http://${NODE_IP}:30713/prometheus\"
                    \"externalUrl\": \"http://${NODE_IP}:{{ $ingressNginx.controller.service.nodePorts.http }}/prometheus\"
                  }
                }"
                
+3 −2
Original line number Diff line number Diff line
{{ $ingressNginx := index .Values "ingress-nginx" }}
{{ $peeringApi := index .Values "peering-api" }}
{{- if $peeringApi.enabled -}}
apiVersion: networking.k8s.io/v1
@@ -8,7 +9,7 @@ metadata:
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  ingressClassName: nginx
  ingressClassName: {{ $ingressNginx.controller.ingressClass }}
  rules:
  - http:
      paths:
Loading