feat(tls): centrally managed TLS for webhook and proxy-webhook (SRVKP-9612, SRVKP-9613)#3406
feat(tls): centrally managed TLS for webhook and proxy-webhook (SRVKP-9612, SRVKP-9613)#3406jkhelil wants to merge 3 commits intotektoncd:mainfrom
Conversation
… by webhook Move setupAPIServerTLSWatch, tlsProfileChanged, and customProfilesEqual out of the TektonConfig controller into pkg/reconciler/openshift/common as exported functions (SetupAPIServerTLSWatch, APIServerTLSProfileChanged). Both the operator controller and the webhook binary can now call the shared helper independently. Also moves the SKIP_APISERVER_TLS_WATCH constant to occommon.SkipAPIServerTLSWatch to avoid duplication between controller.go and the upcoming webhook main.go. Co-authored-by: Cursor <cursoragent@cursor.com>
…nject as WEBHOOK_TLS_* env vars
At startup the webhook calls occommon.SetupAPIServerTLSWatch (the same helper
used by the TektonConfig controller) to initialise the shared APIServer lister
and register a watcher. When the cluster TLS profile changes the webhook exits
with code 1; Kubernetes restartPolicy: Always restarts it so the new instance
picks up the updated profile.
After the watch is set up, GetTLSProfileFromAPIServer + TLSEnvVarsFromProfile
convert the current profile into "1.2"/"1.3" + comma-separated IANA cipher
strings and inject them as WEBHOOK_TLS_MIN_VERSION / WEBHOOK_TLS_CIPHER_SUITES /
WEBHOOK_TLS_CURVE_PREFERENCES before Knative bootstraps. Knative's
DefaultConfigFromEnv("WEBHOOK_") inside webhook.New() picks them up automatically.
No changes to kwebhook.Options, Deployment manifests, or the Kubernetes webhook.
Co-authored-by: Cursor <cursoragent@cursor.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
…tup, inject as WEBHOOK_TLS_* env vars Same pattern as cmd/openshift/webhook/main.go: cfg and signalCtx are created first, SetupAPIServerTLSWatch populates the shared lister and watches for TLS profile changes (os.Exit(1) on change), then GetTLSProfileFromAPIServer + TLSEnvVarsFromProfile inject WEBHOOK_TLS_* env vars before Knative bootstraps. Both openshift and kubernetes proxy-webhook/main.go now inline the context setup (namespace scope + kwebhook.WithOptions) directly, the same way the regular webhooks do. proxy.Getctx() is removed from controller.go — it was only a thin wrapper around signals.NewContext() + webhook.WithOptions and is no longer needed. Co-authored-by: Cursor <cursoragent@cursor.com>
Cluster Evidence — TLS Profile PropagationTested on a live OpenShift cluster with the code from this PR. Environment1. RBAC — ClusterRole & ClusterRoleBinding2. TLS Profile Propagated — both webhooks negotiate TLS 1.3Both webhooks negotiate TLS 1.3 / TLS_AES_128_GCM_SHA256, consistent with the 3. Change Detection — webhook restarts on profile updateLog lines from the previous run of each pod (captured via Both webhooks detected the profile change via the shared 4. Proxy webhook — actively serving admission requests |
|
/kind enhancement |
|
@anithapriyanatarajan: The label(s) DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/kind feature |
Changes
Implements centrally managed TLS for both the
tekton-operator-webhookandtekton-operator-proxy-webhookon OpenShift by inheriting the cluster-wide TLSsecurity profile from the OpenShift
APIServerresource.tekton-operator-webhook (fixes SRVKP-9612)
cmd/openshift/webhook/main.go: at startup, sets up anAPIServerinformervia the shared
occommon.SetupAPIServerTLSWatch. Reads the current TLSprofile with
occommon.GetTLSProfileFromAPIServer+TLSEnvVarsFromProfileand injects
WEBHOOK_TLS_MIN_VERSIONandWEBHOOK_TLS_CIPHER_SUITESasprocess-level env vars before Knative bootstraps. On TLS profile change, the
webhook calls
os.Exit(1)so Kubernetes restarts it with the updated settings.tekton-operator-proxy-webhook (fixes SRVKP-9613)
cmd/openshift/proxy-webhook/main.go: same pattern as the webhook above.signals.NewContext()is now called once inmain()and reused throughout,avoiding a panic from double-initialisation of the signal handler.
proxy.Getctx()is removed fromcontroller.go— context setup is nowinlined directly in
main(), consistent with all other webhook binaries.cmd/kubernetes/proxy-webhook/main.go: context setup also inlined; no TLSwatch (Kubernetes-only binary).
cmd/openshift/operator/kodata/webhook/webhook.yaml: addsget/list/watchon
apiservers.config.openshift.ioto thetekton-operators-proxy-adminClusterRole so the proxy webhook can read the TLS profile at startup.
Shared infrastructure
pkg/reconciler/openshift/common/apiserver_watch.go(new): extractsSetupAPIServerTLSWatch,APIServerTLSProfileChanged, andSkipAPIServerTLSWatchinto a reusable package. Both the TektonConfigcontroller and the webhook binaries now call the same function.
pkg/reconciler/openshift/common/apiserver_watch_test.go(new): unit testsfor
APIServerTLSProfileChanged.pkg/reconciler/openshift/tektonconfig/controller.go: simplified to delegateto
occommon.SetupAPIServerTLSWatch; privatetlsProfileChangedandcustomProfilesEqualfunctions removed.pkg/reconciler/openshift/tektonpipeline/extension.go: addscommon.ReplaceNamespaceInClusterRoleBindingto the OpenShift TektonPipelineextension transformers so the proxy-webhook
ClusterRoleBindingsubjectnamespace is correctly set to the target namespace (e.g.
openshift-pipelines)instead of the static placeholder
tekton-pipelines.TLS version safety
WEBHOOK_TLS_MIN_VERSIONis only set when the effective value is"1.2"or"1.3". Profiles that permit older versions (e.g. the OpenShiftOldprofilewhich uses
VersionTLS10) are handled gracefully: the min-version env var isskipped and Knative falls back to its safe default of TLS 1.2. Cipher suites
from the profile are still propagated in all cases.
Submitter Checklist
make test lintbefore submitting a PRSee the contribution guide for more details.
Release Notes