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

preclude pod with host network to be managed by kmesh #634

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions pkg/utils/enroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func ShouldEnroll(pod *corev1.Pod, ns *corev1.Namespace) bool {
return false
}

// exclude pod with host network set, otherwise it will cause other pods with host network to be managed by kmesh
if pod.Spec.HostNetwork {
return false
}

// If it is a Pod of waypoint, it should not be managed by Kmesh
// Exclude istio managed gateway
if gateway, ok := pod.Labels["gateway.istio.io/managed"]; ok {
Expand Down
31 changes: 31 additions & 0 deletions pkg/utils/enroll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,37 @@ func TestShouldEnroll(t *testing.T) {
},
want: true,
},
{
name: "pod with hostnetwork",
args: args{
namespace: &corev1.Namespace{
TypeMeta: metav1.TypeMeta{
Kind: "Namespace",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "ut-test",
},
},
pod: &corev1.Pod{
TypeMeta: metav1.TypeMeta{
Kind: "Pod",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: "ut-test",
Name: "ut-pod",
Labels: map[string]string{
constants.DataPlaneModeLabel: constants.DataPlaneModeKmesh,
},
},
Spec: corev1.PodSpec{
HostNetwork: true,
},
},
},
want: false,
},
{
name: "sidecar misconfigured label",
args: args{
Expand Down
Loading