Skip to content

Commit

Permalink
support custom vpc dns its deployment replicas (#3286)
Browse files Browse the repository at this point in the history
* support custom vpc dns its deployment replicas


* the provider is not necessary


---------

Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>
  • Loading branch information
bobz965 committed Oct 9, 2023
1 parent fa7eecf commit b94667d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
4 changes: 4 additions & 0 deletions charts/templates/kube-ovn-crd.yaml
Expand Up @@ -39,6 +39,10 @@ spec:
type: string
subnet:
type: string
replicas:
type: integer
minimum: 1
maximum: 3
status:
type: object
properties:
Expand Down
4 changes: 4 additions & 0 deletions dist/images/install.sh
Expand Up @@ -264,6 +264,10 @@ spec:
type: string
subnet:
type: string
replicas:
type: integer
minimum: 1
maximum: 3
status:
type: object
properties:
Expand Down
5 changes: 3 additions & 2 deletions pkg/apis/kubeovn/v1/types.go
Expand Up @@ -852,8 +852,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
Expand Down
24 changes: 4 additions & 20 deletions pkg/controller/vpc_dns.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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{})
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions yamls/crd.yaml
Expand Up @@ -39,6 +39,10 @@ spec:
type: string
subnet:
type: string
replicas:
type: integer
minimum: 1
maximum: 3
status:
type: object
properties:
Expand Down

0 comments on commit b94667d

Please sign in to comment.