Skip to content

[CORE-12314] Use two ServiceEndpoint instances for host-network and pod-network#4474

Open
coutinhop wants to merge 1 commit intotigera:masterfrom
coutinhop:pedro-CORE-12314
Open

[CORE-12314] Use two ServiceEndpoint instances for host-network and pod-network#4474
coutinhop wants to merge 1 commit intotigera:masterfrom
coutinhop:pedro-CORE-12314

Conversation

@coutinhop
Copy link
Member

@coutinhop coutinhop commented Feb 25, 2026

Description

Use two separate ServiceEndpoint instances (Endpoint and PodNetworkEndpoint)
instead of a single struct, to distinguish between host-network and pod-network
K8s API server endpoints. Simplify EnvVars() by removing hostNetworked/provider
params — callers pick the appropriate instance. Remove Docker EE proxy.local
special-case, which is now handled implicitly.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Release Note

Split kubernetes-services-endpoint configmap into KUBERNETES_SERVICE_HOST/PORT for host-networked pods (previous behaviour) and KUBERNETES_SERVICE_HOST_POD_NETWORK and KUBERNETES_SERVICE_PORT_POD_NETWORK for pod-networked pods.

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

// ServiceEndpoint is the Host/Port of the K8s endpoint.
// HostNetworkHost/HostNetworkPort are used for host-networked pods, while
// PodNetworkHost/PodNetworkPort are used for pod-networked pods.
type ServiceEndpoint struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to extend this struct? Or just to use two instances?

ep := ServiceEndpoint{}
hostNetEP := ServiceEndpoint{}

^ This feels a bit conceptually cleaner to me? I think this will make the code a lot clearer.

}
}

if provider == operator.ProviderDockerEE && !hostNetworked && k8s.Host == dockerEEProxyLocal {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change intentional? Would this be a breaking change for MKE?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was intentional, my reasoning was that if we are making a change for !hostNetworked then this condition would be redundant... but if we do change the default behaviour in this PR then this might need to be restored...

k8sapi.Endpoint.HostNetworkHost = cm.Data["KUBERNETES_SERVICE_HOST"]
k8sapi.Endpoint.HostNetworkPort = cm.Data["KUBERNETES_SERVICE_PORT"]
k8sapi.Endpoint.PodNetworkHost = cm.Data["KUBERNETES_SERVICE_HOST_POD_NETWORK"]
k8sapi.Endpoint.PodNetworkPort = cm.Data["KUBERNETES_SERVICE_PORT_POD_NETWORK"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think this is a breaking change - today, both pods share the same configuraiton.

I think we want to keep that behavior if the POD_NETWORK fields aren't present (i.e., use the host network ones).

At a minimum, we need a release note. Ideally we wouldn't break anyone on upgrade, though!

@coutinhop coutinhop changed the title Split ServiceEndpoint into host-network and pod-network fields [CORE-12314] Use two ServiceEndpoint instances for host-network and pod-network Mar 14, 2026
…od-network

Use two separate ServiceEndpoint instances (Endpoint and PodNetworkEndpoint)
instead of a single struct, to distinguish between host-network and pod-network
K8s API server endpoints. Simplify EnvVars() by removing hostNetworked/provider
params — callers pick the appropriate instance. Remove Docker EE proxy.local
special-case, which is now handled implicitly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants