From efd289c9cd26323f82fbd96d4b594d114feebf44 Mon Sep 17 00:00:00 2001 From: l1b0k Date: Mon, 4 Dec 2023 15:34:55 +0800 Subject: [PATCH] webhook: support inject default config if in CRD mode --- pkg/controller/webhook/mutating.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/controller/webhook/mutating.go b/pkg/controller/webhook/mutating.go index efbf58ac..2c9db55f 100644 --- a/pkg/controller/webhook/mutating.go +++ b/pkg/controller/webhook/mutating.go @@ -22,14 +22,15 @@ import ( "net/http" "strconv" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "github.com/AliyunContainerService/terway/deviceplugin" "github.com/AliyunContainerService/terway/pkg/apis/network.alibabacloud.com/v1beta1" "github.com/AliyunContainerService/terway/pkg/utils" "github.com/AliyunContainerService/terway/types" "github.com/AliyunContainerService/terway/types/controlplane" "github.com/AliyunContainerService/terway/types/daemon" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" "gomodules.xyz/jsonpatch/v2" corev1 "k8s.io/api/core/v1" @@ -124,9 +125,12 @@ func podWebhook(ctx context.Context, req *webhook.AdmissionRequest, client clien return webhook.Errored(1, err) } if podNetworking == nil { - if !types.PodUseENI(pod) && controlplane.GetConfig().IPAMType != types.IPAMTypeCRD { - l.V(5).Info("no selector is matched or CRD is not ready") - return webhook.Allowed("not match") + if controlplane.GetConfig().IPAMType != types.IPAMTypeCRD { + if !types.PodUseENI(pod) { + l.V(5).Info("no selector is matched or CRD is not ready") + return webhook.Allowed("not match") + } + // allow use default config if in CRD mode } networks.PodNetworks = append(networks.PodNetworks, controlplane.PodNetworks{Interface: eth0})