Take certificate, route and ingress host from Argo CD server URL config

This commit is contained in:
Yann Soubeyrand 2019-11-22 20:19:17 +01:00
parent 1e2038adca
commit c897af9535
4 changed files with 26 additions and 43 deletions

View file

@ -1,4 +1,5 @@
{{- if .Values.server.certificate.enabled -}} {{- if .Values.server.certificate.enabled -}}
{{- $commonName := regexReplaceAll "^https?://([^/]+)(/.*)?$" .Values.server.config.url "${1}" }}
apiVersion: certmanager.k8s.io/v1alpha1 apiVersion: certmanager.k8s.io/v1alpha1
kind: Certificate kind: Certificate
metadata: metadata:
@ -11,14 +12,14 @@ metadata:
app.kubernetes.io/part-of: argocd app.kubernetes.io/part-of: argocd
app.kubernetes.io/component: {{ .Values.server.name }} app.kubernetes.io/component: {{ .Values.server.name }}
spec: spec:
commonName: {{ .Values.server.certificate.domain | quote }} commonName: {{ $commonName | quote }}
dnsNames: dnsNames:
- {{ .Values.server.certificate.domain | quote }} - {{ $commonName | quote }}
{{- range .Values.ingress.additionalHosts }} {{- range $dnsName := .Values.server.ingress.additionalHosts }}
- {{ . | quote }} - {{ $dnsName | quote }}
{{- end }} {{- end }}
issuerRef: issuerRef:
kind: {{ .Values.certificate.issuer.kind | quote }} kind: {{ .Values.server.certificate.issuer.kind | quote }}
name: {{ .Values.certificate.issuer.name | quote }} name: {{ .Values.server.certificate.issuer.name | quote }}
secretName: argocd-secret secretName: "argocd-secret"
{{- end }} {{- end }}

View file

@ -1,7 +1,8 @@
{{- if .Values.server.ingress.enabled -}} {{- if .Values.server.ingress.enabled -}}
{{- $host := regexReplaceAll "^https?://([^/]+)(/.*)?$" .Values.server.config.url "${1}" }}
{{- $path := default "/" (regexReplaceAll "^https?://([^/]+)(/.*)?$" .Values.server.config.url "${2}") }}
{{- $serviceName := include "argo-cd.server.fullname" . -}} {{- $serviceName := include "argo-cd.server.fullname" . -}}
{{- $servicePort := .Values.server.service.servicePortHttp -}} {{- $servicePort := .Values.server.service.servicePortHttp -}}
{{- $paths := .Values.server.ingress.paths -}}
apiVersion: extensions/v1beta1 apiVersion: extensions/v1beta1
kind: Ingress kind: Ingress
metadata: metadata:
@ -24,30 +25,17 @@ metadata:
{{- end }} {{- end }}
spec: spec:
rules: rules:
{{- if .Values.server.ingress.hosts }} {{- range $host := prepend .Values.server.ingress.additionalHosts $host }}
{{- range $host := .Values.server.ingress.hosts }} - host: {{ $host | quote }}
- host: {{ $host }}
http: http:
paths: paths:
{{- range $p := $paths }} - path: {{ $path | quote }}
- path: {{ $p }}
backend: backend:
serviceName: {{ $serviceName }} serviceName: {{ $serviceName | quote }}
servicePort: {{ $servicePort }} servicePort: {{ $servicePort }}
{{- end -}} {{- end -}}
{{- end -}}
{{- else }}
- http:
paths:
{{- range $p := $paths }}
- path: {{ $p }}
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end -}}
{{- end -}}
{{- if .Values.server.ingress.tls }} {{- if .Values.server.ingress.tls }}
tls: tls:
{{- toYaml .Values.server.ingress.tls | nindent 4 }} {{- toYaml .Values.server.ingress.tls | nindent 4 }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,4 +1,5 @@
{{- if .Values.server.route.enabled -}} {{- if .Values.server.route.enabled -}}
{{- $host := regexReplaceAll "^https?://([^/]+)(/.*)?$" .Values.server.config.url "${1}" }}
apiVersion: route.openshift.io/v1 apiVersion: route.openshift.io/v1
kind: Route kind: Route
metadata: metadata:
@ -15,16 +16,16 @@ metadata:
{{ toYaml . | indent 4 }} {{ toYaml . | indent 4 }}
{{- end }} {{- end }}
spec: spec:
host: {{ .Values.server.route.hostname | quote }} host: {{ $host | quote }}
subdomain: '' subdomain: ''
to: to:
kind: Service kind: "Service"
name: {{ template "argo-cd.server.fullname" . }} name: {{ include "argo-cd.server.fullname" . | quote }}
weight: 100 weight: 100
port: port:
targetPort: https targetPort: "https"
tls: tls:
termination: passthrough termination: "passthrough"
insecureEdgeTerminationPolicy: None insecureEdgeTerminationPolicy: "None"
wildcardPolicy: None wildcardPolicy: "None"
{{- end }} {{- end }}

View file

@ -268,9 +268,9 @@ server:
## Certificate configuration ## Certificate configuration
certificate: certificate:
enabled: false enabled: false
domain: argocd.example.com
issuer: {} issuer: {}
additionalHosts: [] # kind: ClusterIssuer
# name: letsencrypt
## Server service configuration ## Server service configuration
service: service:
@ -304,14 +304,11 @@ server:
labels: {} labels: {}
## Argo Ingress. ## Argo Ingress.
## Hostnames must be provided if Ingress is enabled.
## Secrets must be manually created in the namespace ## Secrets must be manually created in the namespace
## ##
hosts: additionalHosts:
[] []
# - argocd.example.com # - argocd.example.com
paths:
- /
tls: tls:
[] []
# - secretName: argocd-example-tls # - secretName: argocd-example-tls
@ -319,12 +316,8 @@ server:
# - argocd.example.com # - argocd.example.com
# Create a OpenShift Route with SSL passthrough for UI and CLI # Create a OpenShift Route with SSL passthrough for UI and CLI
# Consider setting 'hostname' e.g. https://argocd.apps-crc.testing/ using your Default Ingress Controller Domain
# Find your domain with: kubectl describe --namespace=openshift-ingress-operator ingresscontroller/default | grep Domain:
# If 'hostname' is an empty string "" OpenShift will create a hostname for you.
route: route:
enabled: false enabled: false
hostname: ""
## ArgoCD config ## ArgoCD config
## reference https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/argocd-cm.yaml ## reference https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/argocd-cm.yaml