Skip to content

Commit

Permalink
Generate service manifest based on webhook enabled value (#1476)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
viveksinghggits and mergify[bot] authored Jun 16, 2022
1 parent 8920ecb commit 4297c8d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
24 changes: 24 additions & 0 deletions helm/kanister-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,27 @@ Create the name of the service account to use
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Figure out the target port of service, this depends
on the value of bpValidatingWebhook.enabled
*/}}
{{- define "kanister-operator.targetPort" -}}
{{- if .Values.bpValidatingWebhook.enabled -}}
{{ 9443 }}
{{- else -}}
{{ 8000 }}
{{- end -}}
{{- end -}}

{{/*
Figure out the port of service, this depends
on the value of bpValidatingWebhook.enabled
*/}}
{{- define "kanister-operator.servicePort" -}}
{{- if .Values.bpValidatingWebhook.enabled -}}
{{ .Values.controller.service.port }}
{{- else -}}
{{ 8000 }}
{{- end -}}
{{- end -}}
4 changes: 2 additions & 2 deletions helm/kanister-operator/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ metadata:
name: {{ template "kanister-operator.fullname" . }}
spec:
ports:
- port: {{ .Values.controller.service.port }}
- port: {{ template "kanister-operator.servicePort" . }}
protocol: TCP
targetPort: 9443
targetPort: {{ template "kanister-operator.targetPort" . }}
selector:
app: {{ template "kanister-operator.name" . }}
status:
Expand Down
2 changes: 1 addition & 1 deletion pkg/kancontroller/kancontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func Execute() {
}

// Run HTTPS webhook server if webhook certificates are mounted in the pod
//otherwise normal HTTP server for health and prom endpoints
// otherwise normal HTTP server for health and prom endpoints
if isCACertMounted() {
go func(config *rest.Config) {
err := handler.RunWebhookServer(config)
Expand Down

0 comments on commit 4297c8d

Please sign in to comment.