Skip to content

Commit

Permalink
webhook: support inject default config if in CRD mode
Browse files Browse the repository at this point in the history
  • Loading branch information
l1b0k committed Dec 4, 2023
1 parent 29093c6 commit efd289c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/controller/webhook/mutating.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit efd289c

Please sign in to comment.