From 79aa2a83807094b0132d43eba232809e0753cbbe Mon Sep 17 00:00:00 2001 From: mengkzhaoyun Date: Mon, 28 Dec 2020 13:57:04 +0800 Subject: [PATCH] v2.1.1 add ingress router support --- Deploy.md | 10 ++- templates/ingress/ingress.yaml | 2 + templates/ingress/ingressroute.yaml | 112 ++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 templates/ingress/ingressroute.yaml diff --git a/Deploy.md b/Deploy.md index 075dd49..04b2583 100644 --- a/Deploy.md +++ b/Deploy.md @@ -5,9 +5,9 @@ ```bash # 1.install helm install \ +--namespace=devops \ harbor \ /etc/kubernetes/helm/harbor \ ---namespace=devops \ -f /etc/kubernetes/helm/harbor/values-overrides.yaml # uninstall @@ -16,15 +16,17 @@ helm uninstall \ harbor # update -helm upgrade harbor /etc/kubernetes/helm/harbor \ +helm upgrade \ --namespace=devops \ +harbor \ +/etc/kubernetes/helm/harbor \ -f /etc/kubernetes/helm/harbor/values-overrides.yaml # template helm template \ -/etc/kubernetes/helm/harbor \ ---name=harbor \ --namespace=devops \ +harbor \ +/etc/kubernetes/helm/harbor \ -f /etc/kubernetes/helm/harbor/values-overrides.yaml > /etc/kubernetes/helm/harbor/dist.yaml ``` diff --git a/templates/ingress/ingress.yaml b/templates/ingress/ingress.yaml index 863e91f..e6a12df 100644 --- a/templates/ingress/ingress.yaml +++ b/templates/ingress/ingress.yaml @@ -1,3 +1,4 @@ +{{- if not .Capabilities.APIVersions.Has "bcc.bd-apaas.com/v1alpha1/IngressRoute" -}} {{- if eq .Values.expose.type "ingress" }} {{- $ingress := .Values.expose.ingress -}} {{- $tls := .Values.expose.tls -}} @@ -131,3 +132,4 @@ spec: {{- end }} {{- end }} +{{- end -}} \ No newline at end of file diff --git a/templates/ingress/ingressroute.yaml b/templates/ingress/ingressroute.yaml new file mode 100644 index 0000000..faa0169 --- /dev/null +++ b/templates/ingress/ingressroute.yaml @@ -0,0 +1,112 @@ +{{- $_ := set . "portal_path" "/" -}} +{{- $_ := set . "api_path" "/api/" -}} +{{- $_ := set . "service_path" "/service/" -}} +{{- $_ := set . "v2_path" "/v2/" -}} +{{- $_ := set . "chartrepo_path" "/chartrepo/" -}} +{{- $_ := set . "controller_path" "/c/" -}} +{{- $_ := set . "notary_path" "/" -}} + +{{- if .Capabilities.APIVersions.Has "bcc.bd-apaas.com/v1alpha1/IngressRoute" -}} +--- +apiVersion: bcc.bd-apaas.com/v1alpha1 +kind: IngressRoute +metadata: + name: "{{ template "harbor.ingress" . }}" + annotations: + {{- with .Values.expose.ingress.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + {{ include "harbor.labels" . | indent 4 }} +spec: + entryPoints: + - websecure + routes: + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .portal_path }}`) + kind: Rule + services: + - name: {{ template "harbor.portal" . }} + port: {{ template "harbor.portal.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .api_path }}`) + kind: Rule + services: + - name: {{ template "harbor.core" . }} + port: {{ template "harbor.core.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .service_path }}`) + kind: Rule + services: + - name: {{ template "harbor.core" . }} + port: {{ template "harbor.core.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .v2_path }}`) + kind: Rule + services: + - name: {{ template "harbor.core" . }} + port: {{ template "harbor.core.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .chartrepo_path }}`) + kind: Rule + services: + - name: {{ template "harbor.core" . }} + port: {{ template "harbor.core.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .controller_path }}`) + kind: Rule + services: + - name: {{ template "harbor.core" . }} + port: {{ template "harbor.core.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.notary }}`) && PathPrefix(`{{ .notary_path }}`) + kind: Rule + services: + - name: {{ template "harbor.notary-server" . }} + port: 4443 + tls: + certResolver: default +--- +apiVersion: bcc.bd-apaas.com/v1alpha1 +kind: IngressRoute +metadata: + name: "{{ template "harbor.ingress" . }}-http" + annotations: + {{- with .Values.ingress.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + {{ include "harbor.labels" . | indent 4 }} +spec: + entryPoints: + - web + routes: + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .portal_path }}`) + kind: Rule + services: + - name: {{ template "harbor.portal" . }} + port: {{ template "harbor.portal.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .api_path }}`) + kind: Rule + services: + - name: {{ template "harbor.core" . }} + port: {{ template "harbor.core.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .service_path }}`) + kind: Rule + services: + - name: {{ template "harbor.core" . }} + port: {{ template "harbor.core.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .v2_path }}`) + kind: Rule + services: + - name: {{ template "harbor.core" . }} + port: {{ template "harbor.core.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .chartrepo_path }}`) + kind: Rule + services: + - name: {{ template "harbor.core" . }} + port: {{ template "harbor.core.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.core }}`) && PathPrefix(`{{ .controller_path }}`) + kind: Rule + services: + - name: {{ template "harbor.core" . }} + port: {{ template "harbor.core.servicePort" . }} + - match: Host(`{{ .Values.expose.ingress.hosts.notary }}`) && PathPrefix(`{{ .notary_path }}`) + kind: Rule + services: + - name: {{ template "harbor.notary-server" . }} + port: 4443 +{{- end -}} -- 2.26.0