Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keeping telepresence annotation #182

Merged
merged 1 commit into from
Sep 5, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import (
)

const (
listOptionsTimeoutSeconds int64 = 10
fieldManager = "kardinal-manager"
deleteOptionsGracePeriodSeconds int64 = 0
istioLabel = "istio-injection"
enabledIstioValue = "enabled"
listOptionsTimeoutSeconds int64 = 10
fieldManager = "kardinal-manager"
deleteOptionsGracePeriodSeconds int64 = 0
istioLabel = "istio-injection"
enabledIstioValue = "enabled"
telepresenceRestartedAtAnnotation = "telepresence.getambassador.io/restartedAt"
leoporoli marked this conversation as resolved.
Show resolved Hide resolved
)

var (
Expand Down Expand Up @@ -409,7 +410,7 @@ func (manager *ClusterManager) createOrUpdateDeployment(ctx context.Context, dep
return stacktrace.Propagate(err, "Failed to create deployment: %s", deployment.GetName())
}
} else {
deployment.ResourceVersion = existingDeployment.ResourceVersion
updateDeploymentWithRelevantValuesFromCurrentDeployment(deployment, existingDeployment)
_, err = deploymentClient.Update(ctx, deployment, globalUpdateOptions)
if err != nil {
return stacktrace.Propagate(err, "Failed to update deployment: %s", deployment.GetName())
Expand All @@ -419,6 +420,22 @@ func (manager *ClusterManager) createOrUpdateDeployment(ctx context.Context, dep
return nil
}

func updateDeploymentWithRelevantValuesFromCurrentDeployment(newDeployment *appsv1.Deployment, currentDeployment *appsv1.Deployment) {
newDeployment.ResourceVersion = currentDeployment.ResourceVersion
// merge annotations
newAnnotations := newDeployment.Spec.Template.GetAnnotations()
currentAnnotations := currentDeployment.Spec.Template.GetAnnotations()

for annotationKey, annotationValue := range currentAnnotations {
if annotationKey == telepresenceRestartedAtAnnotation {
// This key is necessary for Kardinal/Telepresence (https://www.telepresence.io/) integration
// keeping this annotation because otherwise the telepresence traffic-agent container will be removed from the pod
newAnnotations[annotationKey] = annotationValue
}
}
newDeployment.Spec.Template.Annotations = newAnnotations
}

func (manager *ClusterManager) createOrUpdateVirtualService(ctx context.Context, virtualService *v1alpha3.VirtualService) error {

virtServiceClient := manager.istioClient.clientSet.NetworkingV1alpha3().VirtualServices(virtualService.GetNamespace())
Expand Down
Loading