-
Notifications
You must be signed in to change notification settings - Fork 765
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
SidecarSet inject sidecar container to all Pods in some namespaces #1369
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,10 @@ func PodMatchedSidecarSet(c client.Client, pod *corev1.Pod, sidecarSet *appsv1al | |
if err != nil { | ||
return false, err | ||
} | ||
// if no selector set, return true | ||
if selector.String() == "" { | ||
return true, nil | ||
} | ||
|
||
if !selector.Empty() && selector.Matches(labels.Set(pod.Labels)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove the !selector.Empty() |
||
return true, nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1244,6 +1244,32 @@ func TestPodMatchedSidecarSet(t *testing.T) { | |
}, | ||
expect: false, | ||
}, | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need modidy the sidecarSet webhook and controller. And you must add e2e for this scenario. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, please review my latest pr, thanks |
||
name: "test6", | ||
getSidecarSet: func() *appsv1alpha1.SidecarSet { | ||
demo := &appsv1alpha1.SidecarSet{ | ||
ObjectMeta: metav1.ObjectMeta{Name: "sidecarset-test"}, | ||
Spec: appsv1alpha1.SidecarSetSpec{ | ||
Namespace: "app1", | ||
}, | ||
} | ||
return demo | ||
}, | ||
getPod: func() *corev1.Pod { | ||
demo := &corev1.Pod{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "test-pod", | ||
Labels: map[string]string{"app": "nginx"}, | ||
Namespace: "app1", | ||
}, | ||
} | ||
return demo | ||
}, | ||
getNs: func() []*corev1.Namespace { | ||
return nil | ||
}, | ||
expect: true, | ||
}, | ||
} | ||
|
||
for _, cs := range cases { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if selector.Empty() {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selector.Empty() return false when no selector set, so I turned to selector.String() == ""