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

Use same instance label value for network policies #1509

Merged
merged 2 commits into from
Nov 22, 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 @@ -132,21 +132,17 @@ func BuildKubernetesNetworkPolicy(dda metav1.Object, componentName v2alpha1.Comp

// GetNetworkPolicyMetadata generates a label selector based on component
func GetNetworkPolicyMetadata(dda metav1.Object, componentName v2alpha1.ComponentName) (policyName string, podSelector metav1.LabelSelector) {
var suffix string
switch componentName {
case v2alpha1.NodeAgentComponentName:
policyName = componentagent.GetAgentName(dda)
suffix = v2alpha1.DefaultAgentResourceSuffix
case v2alpha1.ClusterAgentComponentName:
policyName = componentdca.GetClusterAgentName(dda)
suffix = v2alpha1.DefaultClusterAgentResourceSuffix
case v2alpha1.ClusterChecksRunnerComponentName:
policyName = componentccr.GetClusterChecksRunnerName(dda)
suffix = v2alpha1.DefaultClusterChecksRunnerResourceSuffix
}
podSelector = metav1.LabelSelector{
MatchLabels: map[string]string{
kubernetes.AppKubernetesInstanceLabelKey: suffix,
kubernetes.AppKubernetesInstanceLabelKey: policyName,
kubernetes.AppKubernetesPartOfLabelKey: object.NewPartOfLabelValue(dda).String(),
},
}
Expand Down Expand Up @@ -555,7 +551,7 @@ func egressCCRToDCA(podSelector metav1.LabelSelector, dda metav1.Object) cilium.
ToEndpoints: []metav1.LabelSelector{
{
MatchLabels: map[string]string{
kubernetes.AppKubernetesInstanceLabelKey: v2alpha1.DefaultClusterAgentResourceSuffix,
kubernetes.AppKubernetesInstanceLabelKey: componentdca.GetClusterAgentName(dda),
kubernetes.AppKubernetesPartOfLabelKey: fmt.Sprintf("%s-%s", dda.GetNamespace(), dda.GetName()),
},
},
Expand Down
Loading