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 all 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
7 changes: 6 additions & 1 deletion 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 is the port that the webhook server serves at.",
)
cmd.Flags().String(
operator.SetDefaultSecurityContextFlag,
"auto-detect",
Expand Down Expand Up @@ -557,7 +562,7 @@ func startOperator(ctx context.Context) error {
}
opts.MetricsBindAddress = fmt.Sprintf(":%d", metricsPort) // 0 to disable

opts.Port = WebhookPort
opts.Port = viper.GetInt(operator.WebhookPortFlag)
mgr, err := ctrl.NewManager(cfg, opts)
if err != nil {
log.Error(err, "Failed to create controller manager")
Expand Down
1 change: 1 addition & 0 deletions deploy/eck-operator/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ data:
manage-webhook-certs: false
webhook-cert-dir: {{ .Values.webhook.certsDir }}
{{- end }}
webhook-port: {{ .Values.webhook.port }}
{{- end }}
{{- if .Values.managedNamespaces }}
namespaces: [{{ join "," .Values.managedNamespaces }}]
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.port }}
from:
- ipBlock:
cidr: "{{ $kubeAPIServerIP }}/32"
Expand Down
4 changes: 2 additions & 2 deletions 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.port }}
name: https-webhook
protocol: TCP
{{- end }}
Expand Down Expand Up @@ -117,7 +117,7 @@ spec:
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.webhook.hostNetwork }}
{{- if .Values.hostNetwork }}
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
{{- 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.port }}
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
# port is the port that the validating webhook binds to.
port: 9443

# 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
)