From 33bc9a626759673ea9b2ffc3aa1fb737636bf008 Mon Sep 17 00:00:00 2001 From: bobz965 Date: Mon, 9 Oct 2023 09:32:31 +0800 Subject: [PATCH] support custom vpc dns its deployment replicas (#3286) * support custom vpc dns its deployment replicas * the provider is not necessary --------- Signed-off-by: bobz965 --- charts/templates/kube-ovn-crd.yaml | 4 ++++ dist/images/install.sh | 4 ++++ pkg/apis/kubeovn/v1/types.go | 5 +++-- pkg/controller/vpc_dns.go | 24 ++++-------------------- yamls/crd.yaml | 4 ++++ 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/charts/templates/kube-ovn-crd.yaml b/charts/templates/kube-ovn-crd.yaml index fac0dad0237..c87b59c3ef0 100644 --- a/charts/templates/kube-ovn-crd.yaml +++ b/charts/templates/kube-ovn-crd.yaml @@ -39,6 +39,10 @@ spec: type: string subnet: type: string + replicas: + type: integer + minimum: 1 + maximum: 3 status: type: object properties: diff --git a/dist/images/install.sh b/dist/images/install.sh index 30e21c08216..5bcb7656eb9 100755 --- a/dist/images/install.sh +++ b/dist/images/install.sh @@ -264,6 +264,10 @@ spec: type: string subnet: type: string + replicas: + type: integer + minimum: 1 + maximum: 3 status: type: object properties: diff --git a/pkg/apis/kubeovn/v1/types.go b/pkg/apis/kubeovn/v1/types.go index d81c123ebc6..babd254d88e 100644 --- a/pkg/apis/kubeovn/v1/types.go +++ b/pkg/apis/kubeovn/v1/types.go @@ -853,8 +853,9 @@ type VpcDns struct { } type VpcDNSSpec struct { - Vpc string `json:"vpc"` - Subnet string `json:"subnet"` + Replicas int32 `json:"replicas"` + Vpc string `json:"vpc"` + Subnet string `json:"subnet"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/controller/vpc_dns.go b/pkg/controller/vpc_dns.go index cee1dd15760..38071d4c556 100644 --- a/pkg/controller/vpc_dns.go +++ b/pkg/controller/vpc_dns.go @@ -193,12 +193,6 @@ func (c *Controller) handleAddOrUpdateVPCDNS(key string) error { return err } - if err := c.checkOvnDefaultSpecProvider(); err != nil { - err := fmt.Errorf("failed to check %s spec provider, %v", util.DefaultSubnet, err) - klog.Error(err) - return err - } - if err := c.checkVpcDNSDuplicated(vpcDNS); err != nil { err = fmt.Errorf("failed to deploy %s, %v", vpcDNS.Name, err) klog.Error(err) @@ -277,6 +271,10 @@ func (c *Controller) createOrUpdateVpcDNSDep(vpcDNS *kubeovnv1.VpcDns) error { return err } + if vpcDNS.Spec.Replicas != 0 { + newDp.Spec.Replicas = &vpcDNS.Spec.Replicas + } + if needToCreateDp { _, err := c.config.KubeClient.AppsV1().Deployments(c.config.PodNamespace). Create(context.Background(), newDp, metav1.CreateOptions{}) @@ -491,20 +489,6 @@ func (c *Controller) checkOvnNad() error { return nil } -func (c *Controller) checkOvnDefaultSpecProvider() error { - cachedSubnet, err := c.subnetsLister.Get(util.DefaultSubnet) - if err != nil { - klog.Error(err) - return fmt.Errorf("failed to get default subnet %v", err) - } - - if cachedSubnet.Spec.Provider != nadProvider { - return fmt.Errorf("the %s provider does not exist", nadProvider) - } - - return nil -} - func (c *Controller) resyncVpcDNSConfig() { cm, err := c.configMapsLister.ConfigMaps(c.config.PodNamespace).Get(util.VpcDNSConfig) if err != nil && !k8serrors.IsNotFound(err) { diff --git a/yamls/crd.yaml b/yamls/crd.yaml index a081d1819b6..86943ce0789 100644 --- a/yamls/crd.yaml +++ b/yamls/crd.yaml @@ -39,6 +39,10 @@ spec: type: string subnet: type: string + replicas: + type: integer + minimum: 1 + maximum: 3 status: type: object properties: