Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions k3k-kubelet/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,23 @@ func (p *Provider) updatePod(ctx context.Context, pod *corev1.Pod) error {

updatePod(&hostPod, pod)

// updatePod copies the virtual pod's labels/annotations verbatim; re-assert
// the translator-owned identity metadata the virtual pod does not carry,
// otherwise every update strips it from the host pod (breaking label-selector
// services like k3k-<cluster>-kube-dns and any policy selecting on it).
if hostPod.Labels == nil {
hostPod.Labels = map[string]string{}
}

hostPod.Labels[translate.ClusterNameLabel] = p.ClusterName

if hostPod.Annotations == nil {
hostPod.Annotations = map[string]string{}
}

hostPod.Annotations[translate.ResourceNameAnnotation] = pod.Name
hostPod.Annotations[translate.ResourceNamespaceAnnotation] = pod.Namespace

if err := p.Host.Client.Update(ctx, &hostPod); err != nil {
logger.Error(err, "Unable to update Pod in host cluster")
return err
Expand Down
Loading