Skip to content

Commit 01f6b9a

Browse files
committed
Remove ArgoCD label from services created by kedge
Signed-off-by: ArthurSens <[email protected]>
1 parent 7661703 commit 01f6b9a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

components/ee/kedge/pkg/kedge/kubernetes.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ func createTargetService(clientset kubernetes.Interface, namespace, source, name
248248
SessionAffinity: srv.Service.Spec.SessionAffinity,
249249
},
250250
}
251+
252+
// 'app.kubernetes.io/instance' is automatically added to kedge when it is deployed by ArgoCD.
253+
// This mechanism is used so ArgoCD knows which resource it is supposed to control and which ones it isn't.
254+
// If we add this label to the resources created by kedge, ArgoCD will think that ArgoCD should be controlled,
255+
// and since their resource definitions are not in git, ArgoCD will try to delete them.
256+
labels := targetService.GetLabels()
257+
delete(labels, "app.kubernetes.io/instance")
258+
targetService.SetLabels(labels)
259+
251260
_, err := api.Services(namespace).Create(context.Background(), targetService, metav1.CreateOptions{})
252261
if err != nil {
253262
return fmt.Errorf("cannot create target service: %w", err)

0 commit comments

Comments
 (0)