Skip to content

Commit

Permalink
Merge pull request #387 from camptocamp/dont_copy_annotations
Browse files Browse the repository at this point in the history
feat: Filter annotations forwarded the agents
  • Loading branch information
Vampouille authored Oct 19, 2023
2 parents e9f13e0 + a7304bb commit fea7057
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pkg/orchestrators/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,14 +612,33 @@ func (o *KubernetesOrchestrator) getAgentLabels() map[string]string {
return agentLabels
}

func contains(keys []string, key string) bool {
for _, k := range keys {
if k == key {
return true
}
}
return false
}

func (o *KubernetesOrchestrator) getAgentAnnotations() map[string]string {
agentAnnotations := map[string]string{}

var splittedAnnotation []string

// List of annotations to not forward to agent
excludedAnnotations := []string{"k8s.ovn.org/pod-networks", "k8s.v1.cni.cncf.io/network-status"}

for _, rawAnnotation := range strings.Split(o.config.AgentAnnotationsInline, ",") {
splittedAnnotation = strings.Split(rawAnnotation, "=")
if len(splittedAnnotation) > 1 {
agentAnnotations[splittedAnnotation[0]] = splittedAnnotation[1]
key := splittedAnnotation[0]
value := splittedAnnotation[1]

// Check if this annotations is excluded
if !contains(excludedAnnotations, key) {
agentAnnotations[key] = value
}
}
}
return agentAnnotations
Expand Down

0 comments on commit fea7057

Please sign in to comment.