Skip to content

fix(k8s): preserve service network fields on redeploy - #4013

Open
Elvand-Lie wants to merge 1 commit into
knative:mainfrom
Elvand-Lie:fix/preserve-service-network-fields
Open

fix(k8s): preserve service network fields on redeploy#4013
Elvand-Lie wants to merge 1 commit into
knative:mainfrom
Elvand-Lie:fix/preserve-service-network-fields

Conversation

@Elvand-Lie

@Elvand-Lie Elvand-Lie commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Changes

The raw Kubernetes deployer reconstructs a corev1.Service when redeploying a function. On updates, it previously preserved only the existing Service's ResourceVersion.

Because the generated Service does not contain the network configuration allocated by Kubernetes, redeploying an existing function could submit an empty spec.clusterIP and fail with:

Service "<function-name>" is invalid: spec.clusterIP: Invalid value: "": field is immutable

This change preserves the existing Service's ClusterIP, ClusterIPs, IPFamilies, and IPFamilyPolicy before calling Update, while continuing to generate mutable fields such as ports, selectors, labels, and annotations from the function configuration.

New Service creation is unchanged, so Kubernetes continues to allocate and default its network fields.

The KEDA deployer inherits the fix because it delegates workload deployment to the raw Kubernetes deployer.

Regression tests cover IPv4 single-stack, IPv6 single-stack, dual-stack, preservation of generated mutable fields, and the initial Service creation path.

Testing

  • Tests done and verified locally: unit test suites (make test), linting and repository checks (make check), and test coverage for single-stack IPv4/IPv6 and dual-stack Service network field preservation.
  • Manual redeployment with func deploy --deployer=raw verified against a Kubernetes cluster, confirming existing Service ClusterIP and network configuration are preserved across updates.
  • Fork CI passed the repository's precheck, unit, integration, template, Podman, and runtime E2E suites.

/kind bug

Release Note

Fixed raw and KEDA function redeployments failing when updating an existing Kubernetes Service.

Docs

NONE

@knative-prow knative-prow Bot added the kind/bug Bugs label Aug 18, 2026
@knative-prow

knative-prow Bot commented Aug 18, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Elvand-Lie
Once this PR has been reviewed and has the lgtm label, please assign lkingland for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 size/L 🤖 PR changes 100-499 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels Aug 18, 2026
@knative-prow

knative-prow Bot commented Aug 18, 2026

Copy link
Copy Markdown

Hi @Elvand-Lie. 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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.

The raw deployer reconstructs a Service during redeployment and previously
copied only ResourceVersion from the existing Service. This omitted the
Service's allocated ClusterIP configuration, causing Kubernetes to reject
the update with an immutable clusterIP error.

Preserve ClusterIP, ClusterIPs, IPFamilies, and IPFamilyPolicy from the
existing Service while continuing to generate mutable Service fields from
the function configuration.

The KEDA deployer inherits the fix through its embedded raw deployer.
@Elvand-Lie
Elvand-Lie force-pushed the fix/preserve-service-network-fields branch from aefc46d to 1aec7b1 Compare August 18, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Bugs needs-ok-to-test 🤖 Needs an org member to approve testing size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant