// they are not used by the CEP handlers.
Labels: nil,
Annotations: nil,
+ // OwnerReferences is needed for ztunnel xDS to extract Pod UID.
+ OwnerReferences: slim_metav1.SlimOwnerReferences(concreteObj.ObjectMeta.OwnerReferences),
},
Encryption: func() *cilium_v2.EncryptionSpec {
enc := concreteObj.Status.Encryption
// they are not used by the CEP handlers.
Labels: nil,
Annotations: nil,
+ // OwnerReferences is needed for ztunnel xDS to extract Pod UID.
+ OwnerReferences: slim_metav1.SlimOwnerReferences(ciliumEndpoint.ObjectMeta.OwnerReferences),
},
Encryption: func() *cilium_v2.EncryptionSpec {
enc := ciliumEndpoint.Status.Encryption
// they are not used by the CEP handlers.
Labels: nil,
Annotations: nil,
+ // OwnerReferences is preserved for ztunnel xDS to extract Pod UID.
+ OwnerReferences: []slim_metav1.OwnerReference{
+ {
+ Kind: "Pod",
+ APIVersion: "v1",
+ Name: "foo",
+ UID: "65dasd54d45",
+ Controller: nil,
+ },
+ },
},
Identity: &v2.EndpointIdentity{
ID: 9654,
// ztunnel uses a very stripped down representation of a Resource
// see: https://github.com/istio/ztunnel/blob/58cf2a0f943ffc23c32d889018428ddfa6175144/src/xds/client.rs#L773
res := &v3.Resource{
- Name: string(event.UID),
+ Name: event.getPodUID(),
Resource: anyPBAddr,
}
createResources = append(createResources, res)
case REMOVED:
- removedNames = append(removedNames, string(event.UID))
+ removedNames = append(removedNames, event.getPodUID())
}
}
*types.CiliumEndpoint
}
+// getPodUID returns the Pod UID from the CiliumEndpoint's OwnerReferences.
+// CiliumEndpoints are owned by Pods, so the Pod UID is available in OwnerReferences.
+// This is consistent with the ZDS server which also uses Pod UIDs.
+func (e *EndpointEvent) getPodUID() string {
+ for _, ref := range e.OwnerReferences {
+ if ref.Kind == "Pod" {
+ return string(ref.UID)
+ }
+ }
+ return ""
+}
+
// ToXDSAddress transforms the embedded Endpoint into a XDS Address capable of
// being used in a DeltaDiscoveryResponse.
//
}
w := &pb.Workload{
- Uid: string(e.UID),
+ Uid: e.getPodUID(),
// TODO(hemanthmalla) Convert this field to node name.
// zTunnel will match this with it's own node name.
Node: e.Networking.NodeIP,
require.NotNil(t, workload, "Address should contain Workload")
// Validate all required field mappings from endpoint to workload
- require.Equal(t, ep.K8sUID, workload.Uid, "Workload.Uid should match endpoint.K8sUID")
+ // The workload UID comes from OwnerReferences (Pod UID)
+ require.Equal(t, ep.K8sUID, workload.Uid, "Workload.Uid should match Pod UID from OwnerReferences")
require.Equal(t, ep.K8sPodName, workload.Name, "Workload.Name should match endpoint.K8sPodName")
require.Equal(t, ep.K8sNamespace, workload.Namespace, "Workload.Namespace should match endpoint.K8sNamespace")
// TODO(hemanthmalla): Currently we're setting zTunnel node name to host IP due to lack of nodename in CEP.
require.NotNil(t, workload, "Address should contain Workload")
// Validate all required field mappings from endpoint to workload
- require.Equal(t, ep.K8sUID, workload.Uid, "Workload.Uid should match endpoint.K8sUID")
+ // The workload UID comes from OwnerReferences (Pod UID)
+ require.Equal(t, ep.K8sUID, workload.Uid, "Workload.Uid should match Pod UID from OwnerReferences")
require.Equal(t, ep.K8sPodName, workload.Name, "Workload.Name should match endpoint.K8sPodName")
require.Equal(t, ep.K8sNamespace, workload.Namespace, "Workload.Namespace should match endpoint.K8sNamespace")
// TODO(hemanthmalla): Currently we're setting zTunnel node name to host IP due to lack of nodename in CEP.
ObjectMeta: slim_metav1.ObjectMeta{
Name: ep.K8sPodName,
Namespace: ep.K8sNamespace,
- UID: apimachineryTypes.UID(ep.K8sUID),
+ OwnerReferences: []slim_metav1.OwnerReference{
+ {
+ Kind: "Pod",
+ UID: apimachineryTypes.UID(ep.K8sUID),
+ },
+ },
},
Networking: &v2.EndpointNetworking{
return nil
}
+ // These UIDs must match what MockEndpointEventSource.ListAllEndpoints returns
expectedUIDs := []string{
"12345678-1234-1234-1234-123456789abc", // ep1
"87654321-4321-4321-4321-cba987654321", // ep2