The Unified and Autonomous Development Platform
feat(chart): add `service.ssh.separateService to control whether use a single or separate services for HTTP and SSH
Nex Zhu87b7f9773212
diff --git a/server-product/helm/templates/ingress.yaml b/server-product/helm/templates/ingress.yamlindex 77d8073ce1..804c3256ff 100644--- a/server-product/helm/templates/ingress.yaml+++ b/server-product/helm/templates/ingress.yaml@@ -2,7 +2,7 @@apiVersion: networking.k8s.io/v1kind: Ingressmetadata:- name: {{ include "onedev.fullname" . }}-http+ name: {{ include "onedev.fullname" . }}{{- with .Values.ingress.annotations }}annotations:{{- if and $.Values.ingress.enableDefaultIssuer $.Values.letsencrypt.email }}@@ -26,7 +26,7 @@ spec:pathType: Prefixbackend:service:- name: {{ include "onedev.fullname" . }}-http+ name: {{ include "onedev.fullname" . }}port:number: 80{{- end }}diff --git a/server-product/helm/templates/service.yaml b/server-product/helm/templates/service.yamlindex 29359c5cb2..1bbf896f39 100644--- a/server-product/helm/templates/service.yaml+++ b/server-product/helm/templates/service.yaml@@ -1,51 +1,62 @@-{{ $http := .Values.service.http }}+{{ $main := .Values.service.main }}+{{ $ssh := .Values.service.ssh }}+apiVersion: v1kind: Servicemetadata:- name: {{ include "onedev.fullname" . }}-http+ name: {{ include "onedev.fullname" . }}labels:{{- include "onedev.labels" . | nindent 4 }}tier: onedevannotations:- {{- toYaml $http.annotations | nindent 4 }}+ {{- toYaml $main.annotations | nindent 4 }}spec:- {{ $type := $http.type | default (ternary "LoadBalancer" "ClusterIP" (not .Values.ingress.host)) }}+ {{ $type := $main.type | default (ternary "LoadBalancer" "ClusterIP" (not .Values.ingress.host)) }}type: {{ $type }}{{- if eq $type "LoadBalancer" }}- {{- if $http.loadBalancerIP }}- loadBalancerIP: {{ $http.loadBalancerIP }}+ {{- if $main.loadBalancerIP }}+ loadBalancerIP: {{ $main.loadBalancerIP }}{{- end }}- {{- if $http.loadBalancerSourceRanges }}+ {{- if $main.loadBalancerSourceRanges }}loadBalancerSourceRanges:- {{- range $http.loadBalancerSourceRanges }}+ {{- range $main.loadBalancerSourceRanges }}- {{ . }}{{- end }}{{- end }}{{- else if eq $type "ClusterIP" }}- {{- if $http.clusterIP }}- clusterIP: {{ $http.clusterIP }}+ {{- if $main.clusterIP }}+ clusterIP: {{ $main.clusterIP }}{{- end }}{{- end }}- {{- if $http.externalIPs }}+ {{- if $main.externalIPs }}externalIPs:- {{- toYaml $http.externalIPs | nindent 4 }}+ {{- toYaml $main.externalIPs | nindent 4 }}{{- end }}- {{- if $http.externalTrafficPolicy }}- externalTrafficPolicy: {{ $http.externalTrafficPolicy }}+ {{- if $main.externalTrafficPolicy }}+ externalTrafficPolicy: {{ $main.externalTrafficPolicy }}{{- end }}ports:- name: http- port: {{ $http.port }}- {{- if $http.nodePort }}- nodePort: {{ $http.nodePort }}+ port: {{ $main.port }}+ {{- if $main.nodePort }}+ nodePort: {{ $main.nodePort }}{{- end }}targetPort: 6610protocol: TCP+ {{- if not $ssh.separateService }}+ - name: ssh+ port: {{ $ssh.port }}+ {{- if $ssh.nodePort }}+ nodePort: {{ $ssh.nodePort }}+ {{- end }}+ targetPort: 6610+ protocol: TCP+ {{- end }}selector:{{- include "onedev.selectorLabels" . | nindent 4 }}tier: onedev----{{ $ssh := .Values.service.ssh }}+{{- if $ssh.separateService }}apiVersion: v1kind: Servicemetadata:@@ -56,7 +67,7 @@ metadata:annotations:{{- toYaml $ssh.annotations | nindent 4 }}spec:- {{ $type := $ssh.type | default (ternary "LoadBalancer" "ClusterIP" (not .Values.ingress.host)) }}+ {{ $type := $ssh.type | default "ClusterIP" }}type: {{ $type }}{{- if eq $type "LoadBalancer" }}{{ if $ssh.loadBalancerIP }}@@ -83,7 +94,7 @@ spec:ports:- name: sshport: {{ $ssh.port }}- {{- if $ssh.nodePort }}+ {{- if $ssh.nodePort }}nodePort: {{ $ssh.nodePort }}{{- end }}targetPort: 6611@@ -91,6 +102,7 @@ spec:selector:{{- include "onedev.selectorLabels" . | nindent 4 }}tier: onedev+{{- end }}---apiVersion: v1kind: Servicediff --git a/server-product/helm/values.yaml b/server-product/helm/values.yamlindex f0c6905084..df42014259 100644--- a/server-product/helm/values.yaml+++ b/server-product/helm/values.yaml@@ -9,22 +9,26 @@ nodeSelector:kubernetes.io/os: linuxservice:- http:- # type: ClusterIP+ main:port: 80+ #nodePort:+ # type: ClusterIP# clusterIP: None#loadBalancerIP:- #nodePort:#externalTrafficPolicy:#externalIPs:loadBalancerSourceRanges: []annotations:ssh:- # type: LoadBalancer+ # If separateService is enabled, a separate service is created for SSH with the following options,+ # otherwise, a port for SSH will be added in the main service with the following options.+ separateService: falseport: 22+ #nodePort:+ ## The following options are only useful when separateService is set to true+ # type: LoadBalancer# clusterIP: None#loadBalancerIP:- #nodePort:#externalTrafficPolicy:#externalIPs:loadBalancerSourceRanges: []