Registry Mirror
Skip to content

Conversation

@Itx-Psycho0

@Itx-Psycho0 Itx-Psycho0 commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

What

This is the first step toward #3403, as agreed in #3682 (comment) (Option 1 with a bit of Option 3).

  • Add k8s.ClusterDomain() (pkg/k8s/cluster_domain.go). It returns DefaultClusterDomain (cluster.local) for now.
  • Use it in the two places that hard-coded cluster.local:
    • pkg/k8s/deployer.go: Trigger subscriber host
    • pkg/keda/deployer.go: interceptor bridge Service ExternalName

There is no behavior change. The flag, the per-context user config and the operator lookup can go inside the helper once the contract on #3403 is settled, without touching the deployers again.

The earlier per-function deploy.clusterDomain field is gone.

The two remaining cluster.local strings are intentional: pkg/cluster/kubernetes.go configures the local dev cluster func creates (its domain is fixed), and pkg/pipelines/tekton/templates.go only mentions it in a comment.

Tests

  • TestClusterDomain: the helper returns cluster.local.
  • TestSyncTriggers_SubscriberUsesClusterDomain: the created Trigger's subscriber host is <fn>.<ns>.svc. + ClusterDomain().
  • Test_interceptorBridgeService_usesClusterDomain: the bridge ExternalName is <interceptor>.<ns>.svc. + ClusterDomain().

I checked that the call-site tests really go through the helper by making it return a different domain temporarily. Both call-site tests still passed and only TestClusterDomain failed.

make check is clean, and the unit tests pass for pkg/k8s, pkg/keda, pkg/deployer and pkg/knative.

Refs #3403

@knative-prow
knative-prow Bot requested review from dsimansk and jrangelramos May 8, 2026 17:31
@knative-prow knative-prow Bot added size/L 🤖 PR changes 100-499 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 8, 2026
@knative-prow

knative-prow Bot commented May 8, 2026

Copy link
Copy Markdown

Hi @Itx-Psycho0. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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-sigs/prow repository.

@Itx-Psycho0

Copy link
Copy Markdown
Contributor Author

Hi maintainers,

I've implemented a fix for issue #3403 that makes the cluster domain configurable in the KEDA deployer.

Summary:

  • Added a ClusterDomain field to DeploySpec that allows users to configure the cluster domain
  • Updated the KEDA deployer to use this field when building the interceptor proxy service URL
  • Defaults to "cluster.local" for backward compatibility
  • Added comprehensive unit tests

The implementation is backward compatible and follows the existing patterns in the codebase. All tests pass and linting is clean.

I'd appreciate your review when you have a chance.

@lkingland @creydr @matejvasek

Thanks!

@matejvasek
matejvasek requested review from creydr, gauron99 and lkingland and removed request for dsimansk and jrangelramos May 13, 2026 12:30
@matejvasek

Copy link
Copy Markdown
Contributor

Is this only keda specific?

@matejvasek

Copy link
Copy Markdown
Contributor

@creydr please look at this.

@matejvasek

Copy link
Copy Markdown
Contributor

Isn't cluster domain setting of a cluster, not a function?

@gauron99

Copy link
Copy Markdown
Contributor

Is this only keda specific?

wouldnt this also touch on raw k8s deployer?

@Itx-Psycho0

Copy link
Copy Markdown
Contributor Author

You're absolutely right on all points. Let me address the concerns:

"Is this only KEDA specific?"
No, it's not. The cluster domain affects any deployer that builds internal service URLs. The raw K8s deployer likely has similar hardcoded references to cluster.local.

"Isn't cluster domain setting of a cluster, not a function?"
You're correct, the cluster domain is a cluster-level configuration, not a function-level one. Putting it in DeploySpec (per-function) is architecturally wrong.

Proposed Better Solution - Auto-detect cluster domain from the cluster's DNS configuration
Make it a global/cluster-level config (not per-function)
Apply to all deployers (KEDA, raw K8s, Knative if needed)

Implementation approach:
Add cluster domain detection in the deployer initialization
Fall back to "cluster.local" if detection fails
Allow override via global config (not per-function)
Apply consistently across all deployers

Should I rework the PR with this approach? I can:
Move cluster domain to a global config
Add auto-detection logic
Apply it to both KEDA and raw K8s deployers
Add tests for all deployers

Let me know if this direction makes sense!
@gauron99 @matejvasek

@lkingland lkingland added ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test 🤖 Needs an org member to approve testing labels May 16, 2026
@lkingland

lkingland commented May 16, 2026 •

Copy link
Copy Markdown
Member

This one is... nontrivial.

However, if you're interested in tackling it (with @creydr's help I hope, nudge nudge) your other PRs have been quite nice, so I am sure we can figure out a good solution.

I've added comments to the parent issue #3403

@lkingland

lkingland commented May 16, 2026 •

Copy link
Copy Markdown
Member

Here, I had AI do some research and break it down into actionable steps. Beware potential hallucinations may follow:

Shared contract (decide first — blocks everything else)

  • Pick the ConfigMap coordinates. Propose func-system/cluster-config; agree namespace + name as a stable client/server contract.
  • Define the schema. At minimum clusterDomain. Reserve keys for defaultRegistry, installedComponents, supportedRuntimes, defaultNamespace. Document forward-compat
    rules (unknown keys ignored, never repurpose a key).
  • Decide kubeconfig-context as the cluster identity key on the CLI side (used for cache directory and user-override scoping).

Operator (depends on contract)

  • Add cluster-domain detection that parses /etc/resolv.conf search entries in the operator pod (port of Knative's GetClusterDomainName logic).
  • Reconcile the cluster-config ConfigMap on operator startup, creating/owning it via metadata.ownerReferences to the operator Deployment so it cleans up on
    uninstall.
  • Add a periodic reconciliation timer (e.g., 1h) so post-install kubelet reconfigs eventually propagate.
  • Emit a ConfigMap event on change so consumers can watch instead of poll if they want to.
  • Document the ConfigMap as the operator's public API surface in the operator README.

CLI core helper

  • Introduce a single func ClusterDomain(...) helper that every deployer goes through. No deployer should reference cluster.local directly.
  • Implement the precedence chain inside the helper:
    a. --cluster-domain flag value (if set on the command)
    b. ~/.config/func user override for the active kubeconfig context
    c. func-system/cluster-config ConfigMap read from the cluster
    d. cluster.local
  • Add CLI cache at ~/.cache/func//cluster.json with a short TTL (default ~1h, env override). Invalidate when kubeconfig context changes.
  • Add --cluster-domain flag to func deploy (and any other commands that build cluster-internal URLs) as the explicit override.
  • Improve the fallback error UX: when a deploy fails on the cluster.local default with no operator and no user override, the error message should say "assumed
    cluster.local; set X to override" — not silent.

Global config (~/.config/func)

  • Add a clusters: section keyed by kubeconfig context name, each with a clusterDomain field (and reserved space for the same future keys as the cluster ConfigMap).
  • Define a single source of truth for config schema so the in-cluster ConfigMap and the user-local file share field names.
  • Add a func config cluster set clusterDomain subcommand (or similar) so users don't have to hand-edit YAML.

Deployers (consume — depends on CLI helper)

  • pkg/keda/deployer.go:231 — replace hardcoded ExternalName with ClusterDomain(...) lookup.
  • pkg/k8s/deployer.go:322 — replace hardcoded Trigger filter Host with same.
  • pkg/pipelines/tekton/templates.go — audit and replace any cluster.local literals (verify which need it; some Tekton templates may run inside the cluster and could
    use env-var injection instead).
  • Grep for any remaining cluster.local literals in pkg/ and cmd/ and either route through the helper or annotate why they're intentional (e.g., test fixtures).

Docs

  • New reference page: "Cluster Configuration" — explains the operator ConfigMap, the user-local override, the flag, and the precedence order.
  • Troubleshooting entry for the symptom (KEDA interceptor unreachable / Trigger filter 404s) pointing at the override.
  • Note in operator README that the cluster-config ConfigMap is part of the operator's contract.

Suggested PR sequence

  1. Contract + helper skeleton (no behavior change yet — helper just returns cluster.local)
  2. Deployers wired through the helper (still cluster.local, but centralized)
  3. Global config schema + user override path
  4. Operator side (detection + ConfigMap publish)
  5. CLI ConfigMap reader + cache
  6. Docs + troubleshooting

@lkingland lkingland moved this to New in Functions Traige Jun 2, 2026
@knative-prow-robot knative-prow-robot added the needs-rebase Cannot be merged due to conflicts with HEAD. label Aug 31, 2026
@lkingland

lkingland commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Thanks @Itx-Psycho0. As discussed, the per-function field isn't the right home for a cluster-level setting, so I'm closing this in favour of settling the cluster-config contract on #3403 first. Your tests here will be a good starting point once that's decided.

@lkingland lkingland closed this Oct 28, 2026
@github-project-automation github-project-automation Bot moved this from New to Done in Functions Traige Oct 28, 2026
@Itx-Psycho0

Copy link
Copy Markdown
Contributor Author

/reopen

@knative-prow knative-prow Bot reopened this Nov 7, 2026
@knative-prow

knative-prow Bot commented Nov 7, 2026

Copy link
Copy Markdown

@Itx-Psycho0: Reopened this PR.

Details

In response to this:

/reopen

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-sigs/prow repository.

@github-project-automation github-project-automation Bot moved this from Done to Planning in Functions Traige Nov 7, 2026
@Itx-Psycho0

Copy link
Copy Markdown
Contributor Author

Thanks @Itx-Psycho0. As discussed, the per-function field isn't the right home for a cluster-level setting, so I'm closing this in favour of settling the cluster-config contract on #3403 first. Your tests here will be a good starting point once that's decided.

@lkingland
I totally get why you closed this. After reading through your detailed breakdown and @creydr's points about the CRD approach, I realize my initial fix was way too simple - just putting clusterDomain in the per-function config doesn't solve the real problem.

The full solution you outlined makes sense:

Operator detects cluster domain from /etc/resolv.conf
Stores it in a CRD status (not ConfigMap, per @creydr's point about GitOps)
CLI reads from: flag → user config → operator CRD → cluster.local fallback
Apply to all deployers (KEDA, raw K8s, maybe Tekton)
I reopened this because I want to work on it properly, but I need direction on where to start. Looking at your suggested PR sequence, should I:

Option 1: Start fresh with PR #1 from your sequence - create the ClusterDomain() helper that just returns "cluster.local" for now, and wire all deployers through it? This would centralize the hardcoded references without changing behavior yet.

Option 2: Wait until you and @creydr finalize the CRD contract (cluster-scoped singleton vs namespaced, RBAC grants, exact schema), then start implementing once that's decided?

Option 3: Close this PR again and track progress on issue #3403 until the design is settled, then open a new PR series?

The tests I added here cover the KEDA deployer part, so those can definitely be reused later. But I don't want to keep this PR open if it's blocking or confusing - happy to close it and work on the proper solution in a new PR once the approach is agreed.

Let me know what works best!

@lkingland

Copy link
Copy Markdown
Member

Thanks @Itx-Psycho0, that's a good summary.

Option 1 with a pinch of Option 3 sounds good to me:

A single ClusterDomain() helper which returns cluster.local for now, with the with the two places that hard-code it (pkg/k8s/deployer.go and pkg/keda/deployer.go) updated.

That gives us no behavior change, and we can plug in the full path when it becomes avaiailable. The flag, the user config and the operator lookup once the question on #3403 is settled.

The raw Kubernetes deployer (Trigger subscriber host) and the KEDA
deployer (interceptor bridge ExternalName) each hard-coded
"cluster.local" when building <name>.<namespace>.svc.<domain>
addresses.

Add k8s.ClusterDomain(), which returns DefaultClusterDomain
("cluster.local") for now, and use it in both places. There is no
behavior change. Resolving the domain from a flag, the user config or
the operator can be added inside the helper once the contract on
knative#3403 is settled, without touching the deployers again.

Tests cover the helper's default and check that both call sites build
their address from ClusterDomain().

Refs knative#3403

Signed-off-by: Itx-Psycho0 <anuragh3re@gmail.com>
@Itx-Psycho0
Itx-Psycho0 force-pushed the fix/3403-configurable-cluster-domain branch from 4407fe7 to f18b405 Compare November 25, 2026 06:57
@knative-prow-robot knative-prow-robot removed the needs-rebase Cannot be merged due to conflicts with HEAD. label Nov 25, 2026
@Itx-Psycho0 Itx-Psycho0 changed the title feat: make cluster domain configurable in KEDA deployer refactor: route in-cluster service addresses through k8s.ClusterDomain() Nov 25, 2026
@Itx-Psycho0

Itx-Psycho0 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@lkingland Thanks! I've updated this PR to match what you described:

Added k8s.ClusterDomain(), which returns cluster.local for now
pkg/k8s/deployer.go (Trigger subscriber host) and pkg/keda/deployer.go (interceptor bridge ExternalName) now use it
Removed the per-function clusterDomain field
Added tests for the helper and for both call sites

There is no behavior change, and the branch is rebased on current main. The flag, the user config and the operator lookup can be added inside the helper once #3403 is settled.

@lkingland lkingland added the lifecycle/frozen 🤖 Issue or PR should not be auto-closed due to staleness. label Nov 25, 2026
@lkingland

Copy link
Copy Markdown
Member

Thanks @Itx-Psycho0, looks good to me. Assuming the tests pass:

/remove-lifecycle frozen
/lgtm
/approve

@knative-prow knative-prow Bot removed the lifecycle/frozen 🤖 Issue or PR should not be auto-closed due to staleness. label Nov 25, 2026
@knative-prow knative-prow Bot added the lgtm 🤖 PR is ready to be merged. label Nov 25, 2026
@knative-prow

knative-prow Bot commented Nov 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Itx-Psycho0, lkingland

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved 🤖 PR has been approved by an approver from all required OWNERS files. label Nov 25, 2026
@knative-prow
knative-prow Bot merged commit f39f6bd into knative:main Nov 25, 2026
45 checks passed
@github-project-automation github-project-automation Bot moved this from Planning to Done in Functions Traige Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. lgtm 🤖 PR is ready to be merged. ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants