Skip to content

Commit

Permalink
Merge branch 'master' into fix-ipampools-ns
Browse files Browse the repository at this point in the history
  • Loading branch information
cnvergence authored Dec 30, 2024
2 parents 464c30a + 5eb316b commit a56fac8
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL = /bin/bash

include Makefile.e2e
include e2e.mk

REGISTRY = kubeovn
DEV_TAG = dev
Expand Down
File renamed without changes.
10 changes: 4 additions & 6 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -1546,13 +1546,9 @@ func (c *Controller) getPodAttachmentNet(pod *v1.Pod) ([]*kubeovnNet, error) {
Subnet: subnet,
IsDefault: isDefault,
AllowLiveMigration: allowLiveMigration,
MacRequest: attach.MacRequest,
IPRequest: strings.Join(attach.IPRequest, ","),
}

if len(attach.IPRequest) != 0 {
ret.IPRequest = strings.Join(attach.IPRequest, ",")
}

ret.MacRequest = attach.MacRequest
result = append(result, ret)
} else {
providerName = fmt.Sprintf("%s.%s", attach.Name, attach.Namespace)
Expand All @@ -1562,6 +1558,8 @@ func (c *Controller) getPodAttachmentNet(pod *v1.Pod) ([]*kubeovnNet, error) {
Type: providerTypeIPAM,
ProviderName: providerName,
Subnet: subnet,
MacRequest: attach.MacRequest,
IPRequest: strings.Join(attach.IPRequest, ","),
})
break
}
Expand Down
31 changes: 31 additions & 0 deletions pkg/controller/service_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func (c *Controller) genLbSvcDeployment(svc *corev1.Service, nad *nadv1.NetworkA
resources.Limits[corev1.ResourceName(v)] = resource.MustParse("1")
resources.Requests[corev1.ResourceName(v)] = resource.MustParse("1")
}
nodeSelector := c.getNodeSelectorFromCm()
if nodeSelector != nil {
klog.Infof("node selector for lb-svc deploy %s: %v", name, nodeSelector)
}

dp = &v1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -129,6 +133,7 @@ func (c *Controller) genLbSvcDeployment(svc *corev1.Service, nad *nadv1.NetworkA
Resources: resources,
},
},
NodeSelector: nodeSelector,
TerminationGracePeriodSeconds: ptr.To(int64(0)),
},
},
Expand Down Expand Up @@ -458,3 +463,29 @@ func (c *Controller) delDnatRules(pod *corev1.Pod, toDel []corev1.ServicePort, s
}
return nil
}

func (c *Controller) getNodeSelectorFromCm() map[string]string {
cm, err := c.configMapsLister.ConfigMaps(c.config.PodNamespace).Get(util.VpcNatConfig)
if err != nil {
err = fmt.Errorf("failed to get ovn-vpc-nat-config, %w", err)
klog.Error(err)
return nil
}

if cm.Data["nodeSelector"] == "" {
klog.Error(errors.New("there's no nodeSelector field in ovn-vpc-nat-config"))
return nil
}
// nodeSelector used for lb-svc deployment
lines := strings.Split(cm.Data["nodeSelector"], "\n")

selectors := make(map[string]string, len(lines))
for _, line := range lines {
parts := strings.Split(strings.TrimSpace(line), ":")
if len(parts) != 2 {
continue
}
selectors[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1])
}
return selectors
}
48 changes: 24 additions & 24 deletions test/anp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ go 1.23.4

require (
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.30.3
k8s.io/client-go v0.30.3
sigs.k8s.io/controller-runtime v0.18.4
k8s.io/apimachinery v0.32.0
k8s.io/client-go v0.32.0
sigs.k8s.io/controller-runtime v0.19.3
sigs.k8s.io/network-policy-api v0.1.5
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240910150728-a0b0bb1d4134 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand All @@ -34,27 +34,27 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/ginkgo/v2 v2.20.2 // indirect
github.com/onsi/gomega v1.34.1 // indirect
github.com/onsi/ginkgo/v2 v2.22.1 // indirect
github.com/onsi/gomega v1.36.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.9.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.25.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/protobuf v1.36.1 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.30.3 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
k8s.io/api v0.32.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.5.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit a56fac8

Please sign in to comment.