Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add operator flag to define webhook port #6691

Merged
merged 16 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ func Command() *cobra.Command {
DefaultWebhookName,
"Name of the Kubernetes ValidatingWebhookConfiguration resource. Only used when enable-webhook is true.",
)
cmd.Flags().Int(
operator.WebhookPortFlag,
WebhookPort,
"Port to bind the webhook to. Used primarily in-conjunction with hostNetworking",
KrisJohnstone marked this conversation as resolved.
Show resolved Hide resolved
)
cmd.Flags().String(
operator.SetDefaultSecurityContextFlag,
"auto-detect",
Expand Down
2 changes: 1 addition & 1 deletion deploy/eck-operator/templates/operator-network-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
ingress:
{{- if .Values.webhook.enabled }}
- ports:
- port: 9443
- port: {{ .Values.webhook.webhookPort }}
from:
- ipBlock:
cidr: "{{ $kubeAPIServerIP }}/32"
Expand Down
2 changes: 1 addition & 1 deletion deploy/eck-operator/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ spec:
protocol: TCP
{{- end }}
{{- if .Values.webhook.enabled }}
- containerPort: 9443
- containerPort: {{ .Values.webhook.webhookPort }}
name: https-webhook
protocol: TCP
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion deploy/eck-operator/templates/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ spec:
ports:
- name: https
port: 443
targetPort: 9443
targetPort: {{ .Values.webhook.webhookPort }}
selector:
{{- include "eck-operator.selectorLabels" . | nindent 4 }}
{{- if .Values.webhook.manageCerts }}
Expand Down
11 changes: 7 additions & 4 deletions deploy/eck-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,13 @@ webhook:
# objectSelector corresponds to the objectSelector property of the webhook.
# Setting this restricts the webhook to act only on objects that match the selector.
objectSelector: {}
# HostNetwork allows a Pod to use the Node network namespace.
# This is required to allow for communication with the kube API when using some alternate CNIs in conjunction with webhook enabled.
# CAUTION: Proceed at your own risk. This setting has security concerns such as allowing malicious users to access workloads running on the host.
hostNetwork: false
# Set the port that the validating webhook binds too.
webhookPort: 9443
KrisJohnstone marked this conversation as resolved.
Show resolved Hide resolved

# hostNetwork allows a Pod to use the Node network namespace.
# This is required to allow for communication with the kube API when using some alternate CNIs in conjunction with webhook enabled.
# CAUTION: Proceed at your own risk. This setting has security concerns such as allowing malicious users to access workloads running on the host.
hostNetwork: false

softMultiTenancy:
# enabled determines whether the operator is installed with soft multi-tenancy extensions.
Expand Down
1 change: 1 addition & 0 deletions docs/operating-eck/operator-config.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ECK can be configured using either command line flags or environment variables.
|webhook-cert-dir |"{TempDir}/k8s-webhook-server/serving-certs" |Path to the directory that contains the webhook server key and certificate.
|webhook-name |"elastic-webhook.k8s.elastic.co" |Name of the Kubernetes ValidatingWebhookConfiguration resource. Only used when `enable-webhook` is true.
|webhook-secret |"" | K8s secret mounted into the path designated by webhook-cert-dir to be used for webhook certificates.
|webhook-port | 9443 | Port to listen for incoming validation requests.
|===


Expand Down
1 change: 1 addition & 0 deletions docs/operating-eck/webhook.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ You can customise almost all aspects of the webhook setup by changing the <<{p}-
|webhook-cert-dir | /tmp/k8s-webhook-server/serving-certs | Path to mount the certificate.
|webhook-name | elastic-webhook.k8s.elastic.co | Name of the `ValidatingWebhookConfiguration` resource.
|webhook-secret | elastic-webhook-server-cert | Name of the secret containing the certificate for the webhook server.
|webhook-port | 9443 | Port to listen for incoming validation requests.
|===


Expand Down
1 change: 1 addition & 0 deletions pkg/controller/common/operator/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ const (
WebhookCertDirFlag = "webhook-cert-dir"
WebhookNameFlag = "webhook-name"
WebhookSecretFlag = "webhook-secret"
WebhookPortFlag = "webhook-port"
KrisJohnstone marked this conversation as resolved.
Show resolved Hide resolved
)