From 81b501e80e8939385b18e4867b60cd57213d2f7f Mon Sep 17 00:00:00 2001 From: Nir Shtein Date: Tue, 27 Sep 2022 18:57:46 +0300 Subject: [PATCH] Make port configurable in webhook, default is set to 443 (#2215) Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com> --- .../events-webhook-deployment.yaml | 2 ++ manifests/install-validating-webhook.yaml | 2 ++ webhook/cmd/start.go | 13 +++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/manifests/extensions/validating-webhook/events-webhook-deployment.yaml b/manifests/extensions/validating-webhook/events-webhook-deployment.yaml index 532c72e667..6fd8e51c49 100644 --- a/manifests/extensions/validating-webhook/events-webhook-deployment.yaml +++ b/manifests/extensions/validating-webhook/events-webhook-deployment.yaml @@ -23,4 +23,6 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + - name: PORT + value: "443" serviceAccountName: argo-events-webhook-sa diff --git a/manifests/install-validating-webhook.yaml b/manifests/install-validating-webhook.yaml index bd0b00334d..0cd42b386b 100644 --- a/manifests/install-validating-webhook.yaml +++ b/manifests/install-validating-webhook.yaml @@ -114,6 +114,8 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + - name: PORT + value: "443" image: quay.io/argoproj/argo-events:latest imagePullPolicy: Always name: webhook diff --git a/webhook/cmd/start.go b/webhook/cmd/start.go index 9e10567663..c29fcb7f7a 100644 --- a/webhook/cmd/start.go +++ b/webhook/cmd/start.go @@ -3,6 +3,7 @@ package cmd import ( "crypto/tls" "os" + "strconv" "go.uber.org/zap" "k8s.io/apimachinery/pkg/runtime" @@ -19,10 +20,12 @@ import ( eventsourceclient "github.com/argoproj/argo-events/pkg/client/eventsource/clientset/versioned" sensorclient "github.com/argoproj/argo-events/pkg/client/sensor/clientset/versioned" "github.com/argoproj/argo-events/webhook" + envpkg "github.com/argoproj/pkg/env" ) const ( namespaceEnvVar = "NAMESPACE" + portEnvVar = "PORT" ) func Start() { @@ -39,7 +42,13 @@ func Start() { namespace, defined := os.LookupEnv(namespaceEnvVar) if !defined { - logger.Fatalf("required environment variable '%s' not defined", namespaceEnvVar) + logger.Fatalf("required environment variable %q not defined", namespaceEnvVar) + } + + portStr := envpkg.LookupEnvStringOr(portEnvVar, "443") + port, err := strconv.Atoi(portStr) + if err != nil { + logger.Fatalf("port should be a number, environment variable %q not valid", portStr) } options := webhook.Options{ @@ -47,7 +56,7 @@ func Start() { DeploymentName: "events-webhook", ClusterRoleName: "argo-events-webhook", Namespace: namespace, - Port: 443, + Port: port, SecretName: "events-webhook-certs", WebhookName: "webhook.argo-events.argoproj.io", ClientAuth: tls.VerifyClientCertIfGiven,