feat(argo-rollouts): Add rollouts dashboard ingress support (#870)

* Add rollouts dashboard ingress support

Signed-off-by: Sergey Shaykhullin <sergeyshaykhullin@gmail.com>

* Fix eol

Signed-off-by: Sergey Shaykhullin <sergeyshaykhullin@gmail.com>

* Bump version

Signed-off-by: Sergey Shaykhullin <sergeyshaykhullin@gmail.com>

* Update Chart.yaml

Signed-off-by: Sergey Shaykhullin <sergeyshaykhullin@gmail.com>

* Fix service duplication

* Extend warning in terms of exposing the dashboard

Signed-off-by: Marco Kilchhofer <mkilchhofer@users.noreply.github.com>

* Adapt API overrides to other charts (apiVersionOverrides)

Also add missing param 'kubeVersionOverride' to README.

Signed-off-by: Marco Kilchhofer <mkilchhofer@users.noreply.github.com>

* Use consistent code style for empty lists

Signed-off-by: Marco Kilchhofer <mkilchhofer@users.noreply.github.com>

* Fix README `[/]` -> `["/"]`

Signed-off-by: Marco Kilchhofer <mkilchhofer@users.noreply.github.com>

Co-authored-by: Marco Kilchhofer <mkilchhofer@users.noreply.github.com>
This commit is contained in:
Sergey Shaykhullin 2022-01-10 23:44:51 +03:00 committed by GitHub
parent e32f580733
commit 1794ba17bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 205 additions and 8 deletions

View file

@ -62,3 +62,25 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{/*
Return the appropriate apiVersion for ingress
*/}}
{{- define "argo-rollouts.ingress.apiVersion" -}}
{{- if .Values.apiVersionOverrides.ingress -}}
{{- print .Values.apiVersionOverrides.ingress -}}
{{- else if semverCompare "<1.14-0" (include "argo-rollouts.kubeVersion" $) -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" (include "argo-rollouts.kubeVersion" $) -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end -}}
{{- end -}}
{{/*
Return the target Kubernetes version
*/}}
{{- define "argo-rollouts.kubeVersion" -}}
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride }}
{{- end -}}

View file

@ -40,7 +40,7 @@ spec:
{{- end }}
name: argo-rollouts-dashboard
ports:
- containerPort: 3100
- containerPort: {{ .Values.dashboard.service.targetPort }}
name: dashboard
securityContext:
{{- toYaml .Values.dashboard.containerSecurityContext | nindent 10 }}

View file

@ -0,0 +1,89 @@
{{- if and .Values.dashboard.enabled .Values.dashboard.ingress.enabled -}}
{{- $serviceName := include "argo-rollouts.fullname" . -}}
{{- $servicePort := .Values.dashboard.service.port -}}
{{- $paths := .Values.dashboard.ingress.paths -}}
{{- $extraPaths := .Values.dashboard.ingress.extraPaths -}}
{{- $pathType := .Values.dashboard.ingress.pathType -}}
apiVersion: {{ include "argo-rollouts.ingress.apiVersion" . }}
kind: Ingress
metadata:
{{- if .Values.dashboard.ingress.annotations }}
annotations:
{{- range $key, $value := .Values.dashboard.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
name: {{ template "argo-rollouts.fullname" . }}-dashboard
labels:
{{- include "argo-rollouts.labels" . | nindent 4 }}
{{- if .Values.dashboard.ingress.labels }}
{{- toYaml .Values.dashboard.ingress.labels | nindent 4 }}
{{- end }}
spec:
{{- if eq (include "argo-rollouts.ingress.apiVersion" $) "networking.k8s.io/v1" }}
{{- with .Values.dashboard.ingress.ingressClassName }}
ingressClassName: {{ . }}
{{- end }}
{{- end }}
rules:
{{- if .Values.dashboard.ingress.hosts }}
{{- range $host := .Values.dashboard.ingress.hosts }}
- host: {{ $host }}
http:
paths:
{{- if $extraPaths }}
{{- toYaml $extraPaths | nindent 10 }}
{{- end }}
{{- range $p := $paths }}
- path: {{ $p }}
{{- if eq (include "argo-rollouts.ingress.apiVersion" $) "networking.k8s.io/v1" }}
pathType: {{ $pathType }}
{{- end }}
backend:
{{- if eq (include "argo-rollouts.ingress.apiVersion" $) "networking.k8s.io/v1" }}
service:
name: {{ $serviceName }}
port:
{{- if kindIs "float64" $servicePort }}
number: {{ $servicePort }}
{{- else }}
name: {{ $servicePort }}
{{- end }}
{{- else }}
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- end -}}
{{- end -}}
{{- else }}
- http:
paths:
{{- if $extraPaths }}
{{- toYaml $extraPaths | nindent 10 }}
{{- end }}
{{- range $p := $paths }}
- path: {{ $p }}
{{- if eq (include "argo-rollouts.ingress.apiVersion" $) "networking.k8s.io/v1" }}
pathType: {{ $pathType }}
{{- end }}
backend:
{{- if eq (include "argo-rollouts.ingress.apiVersion" $) "networking.k8s.io/v1" }}
service:
name: {{ $serviceName }}
port:
{{- if kindIs "float64" $servicePort }}
number: {{ $servicePort }}
{{- else }}
name: {{ $servicePort }}
{{- end }}
{{- else }}
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end }}
{{- end -}}
{{- end -}}
{{- if .Values.dashboard.ingress.tls }}
tls:
{{- toYaml .Values.dashboard.ingress.tls | nindent 4 }}
{{- end -}}
{{- end -}}

View file

@ -6,8 +6,14 @@ metadata:
labels:
app.kubernetes.io/component: {{ .Values.dashboard.component }}
{{- include "argo-rollouts.labels" . | nindent 4 }}
{{- with .Values.serviceAnnotations }}
{{- with .Values.dashboard.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- with .Values.serviceAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.dashboard.service.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
@ -24,10 +30,10 @@ spec:
{{- end }}
type: {{ .Values.dashboard.service.type }}
ports:
- name: dashboard
- name: {{ .Values.dashboard.service.portName }}
protocol: TCP
port: 3100
targetPort: 3100
port: {{ .Values.dashboard.service.port }}
targetPort: {{ .Values.dashboard.service.targetPort }}
selector:
app.kubernetes.io/component: {{ .Values.dashboard.component }}
{{- include "argo-rollouts.selectorLabels" . | nindent 4 }}