Skip to content

Commit

Permalink
Make port configurable in webhook, default is set to 443 (#2215)
Browse files Browse the repository at this point in the history
Signed-off-by: Nir Shtein <[email protected]>
  • Loading branch information
nirsht authored Sep 27, 2022
1 parent 07e6960 commit 81b501e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: PORT
value: "443"
serviceAccountName: argo-events-webhook-sa
2 changes: 2 additions & 0 deletions manifests/install-validating-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions webhook/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"crypto/tls"
"os"
"strconv"

"go.uber.org/zap"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -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() {
Expand All @@ -39,15 +42,21 @@ 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{
ServiceName: "events-webhook",
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,
Expand Down

0 comments on commit 81b501e

Please sign in to comment.