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,