From 3a8d2038acd6fa6307d476c32339394d6e9b60fa Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Tue, 28 Sep 2021 12:41:49 +0300 Subject: [PATCH] Unify config name and format (#2843) Use same naming and format convention for for NodeIPAM as it is for other Antrea features. Fixes: #2839 Signed-off-by: Kobi Samoray --- build/yamls/antrea-aks.yml | 16 ++++++++-------- build/yamls/antrea-eks.yml | 16 ++++++++-------- build/yamls/antrea-gke.yml | 16 ++++++++-------- build/yamls/antrea-ipsec.yml | 16 ++++++++-------- build/yamls/antrea.yml | 16 ++++++++-------- build/yamls/base/conf/antrea-controller.conf | 6 +++--- cmd/antrea-controller/config.go | 6 +++--- cmd/antrea-controller/controller.go | 12 +++++------- cmd/antrea-controller/options.go | 14 ++++++-------- 9 files changed, 57 insertions(+), 61 deletions(-) diff --git a/build/yamls/antrea-aks.yml b/build/yamls/antrea-aks.yml index 98d2cb025af..14cff31b8a6 100644 --- a/build/yamls/antrea-aks.yml +++ b/build/yamls/antrea-aks.yml @@ -3417,7 +3417,7 @@ rules: - apiGroups: - "" resourceNames: - - antrea-config-99dtkgmckh + - antrea-config-k4kb8fm255 resources: - configmaps verbs: @@ -3916,14 +3916,14 @@ data: # Enable the integrated Node IPAM controller within the Antrea controller. # enableNodeIPAM: false - # CIDR Ranges for Pods in cluster. Value can contain a single CIDR range, or multiple ranges, separated by commas. + # CIDR Ranges for Pods in cluster. String array containing single CIDR range, or multiple ranges. # The CIDRs could be either IPv4 or IPv6. Value ignored when enableNodeIPAM is false. - # clusterCIDRs: + # clusterCIDRs: [] # CIDR Ranges for Services in cluster. It is not necessary to specify it when there is no overlap with clusterCIDRs. # Value ignored when enableNodeIPAM is false. # serviceCIDR: - # secondaryServiceCIDR: + # serviceCIDRv6: # Mask size for IPv4 Node CIDR in IPv4 or dual-stack cluster. Value ignored when enableNodeIPAM is false # or when IPv4 Pod CIDR is not configured. Valid range is 16 to 30. @@ -3937,7 +3937,7 @@ metadata: annotations: {} labels: app: antrea - name: antrea-config-99dtkgmckh + name: antrea-config-k4kb8fm255 namespace: kube-system --- apiVersion: v1 @@ -4008,7 +4008,7 @@ spec: fieldRef: fieldPath: spec.serviceAccountName - name: ANTREA_CONFIG_MAP_NAME - value: antrea-config-99dtkgmckh + value: antrea-config-k4kb8fm255 image: projects.registry.vmware.com/antrea/antrea-ubuntu:latest imagePullPolicy: IfNotPresent livenessProbe: @@ -4059,7 +4059,7 @@ spec: key: node-role.kubernetes.io/master volumes: - configMap: - name: antrea-config-99dtkgmckh + name: antrea-config-k4kb8fm255 name: antrea-config - name: antrea-controller-tls secret: @@ -4355,7 +4355,7 @@ spec: operator: Exists volumes: - configMap: - name: antrea-config-99dtkgmckh + name: antrea-config-k4kb8fm255 name: antrea-config - hostPath: path: /etc/cni/net.d diff --git a/build/yamls/antrea-eks.yml b/build/yamls/antrea-eks.yml index 18d11b0246b..54f3830206c 100644 --- a/build/yamls/antrea-eks.yml +++ b/build/yamls/antrea-eks.yml @@ -3417,7 +3417,7 @@ rules: - apiGroups: - "" resourceNames: - - antrea-config-99dtkgmckh + - antrea-config-k4kb8fm255 resources: - configmaps verbs: @@ -3916,14 +3916,14 @@ data: # Enable the integrated Node IPAM controller within the Antrea controller. # enableNodeIPAM: false - # CIDR Ranges for Pods in cluster. Value can contain a single CIDR range, or multiple ranges, separated by commas. + # CIDR Ranges for Pods in cluster. String array containing single CIDR range, or multiple ranges. # The CIDRs could be either IPv4 or IPv6. Value ignored when enableNodeIPAM is false. - # clusterCIDRs: + # clusterCIDRs: [] # CIDR Ranges for Services in cluster. It is not necessary to specify it when there is no overlap with clusterCIDRs. # Value ignored when enableNodeIPAM is false. # serviceCIDR: - # secondaryServiceCIDR: + # serviceCIDRv6: # Mask size for IPv4 Node CIDR in IPv4 or dual-stack cluster. Value ignored when enableNodeIPAM is false # or when IPv4 Pod CIDR is not configured. Valid range is 16 to 30. @@ -3937,7 +3937,7 @@ metadata: annotations: {} labels: app: antrea - name: antrea-config-99dtkgmckh + name: antrea-config-k4kb8fm255 namespace: kube-system --- apiVersion: v1 @@ -4008,7 +4008,7 @@ spec: fieldRef: fieldPath: spec.serviceAccountName - name: ANTREA_CONFIG_MAP_NAME - value: antrea-config-99dtkgmckh + value: antrea-config-k4kb8fm255 image: projects.registry.vmware.com/antrea/antrea-ubuntu:latest imagePullPolicy: IfNotPresent livenessProbe: @@ -4059,7 +4059,7 @@ spec: key: node-role.kubernetes.io/master volumes: - configMap: - name: antrea-config-99dtkgmckh + name: antrea-config-k4kb8fm255 name: antrea-config - name: antrea-controller-tls secret: @@ -4357,7 +4357,7 @@ spec: operator: Exists volumes: - configMap: - name: antrea-config-99dtkgmckh + name: antrea-config-k4kb8fm255 name: antrea-config - hostPath: path: /etc/cni/net.d diff --git a/build/yamls/antrea-gke.yml b/build/yamls/antrea-gke.yml index 50b7b5ba274..3dbaf01e4a0 100644 --- a/build/yamls/antrea-gke.yml +++ b/build/yamls/antrea-gke.yml @@ -3417,7 +3417,7 @@ rules: - apiGroups: - "" resourceNames: - - antrea-config-cf84k5688d + - antrea-config-g28k2t6c9k resources: - configmaps verbs: @@ -3916,14 +3916,14 @@ data: # Enable the integrated Node IPAM controller within the Antrea controller. # enableNodeIPAM: false - # CIDR Ranges for Pods in cluster. Value can contain a single CIDR range, or multiple ranges, separated by commas. + # CIDR Ranges for Pods in cluster. String array containing single CIDR range, or multiple ranges. # The CIDRs could be either IPv4 or IPv6. Value ignored when enableNodeIPAM is false. - # clusterCIDRs: + # clusterCIDRs: [] # CIDR Ranges for Services in cluster. It is not necessary to specify it when there is no overlap with clusterCIDRs. # Value ignored when enableNodeIPAM is false. # serviceCIDR: - # secondaryServiceCIDR: + # serviceCIDRv6: # Mask size for IPv4 Node CIDR in IPv4 or dual-stack cluster. Value ignored when enableNodeIPAM is false # or when IPv4 Pod CIDR is not configured. Valid range is 16 to 30. @@ -3937,7 +3937,7 @@ metadata: annotations: {} labels: app: antrea - name: antrea-config-cf84k5688d + name: antrea-config-g28k2t6c9k namespace: kube-system --- apiVersion: v1 @@ -4008,7 +4008,7 @@ spec: fieldRef: fieldPath: spec.serviceAccountName - name: ANTREA_CONFIG_MAP_NAME - value: antrea-config-cf84k5688d + value: antrea-config-g28k2t6c9k image: projects.registry.vmware.com/antrea/antrea-ubuntu:latest imagePullPolicy: IfNotPresent livenessProbe: @@ -4059,7 +4059,7 @@ spec: key: node-role.kubernetes.io/master volumes: - configMap: - name: antrea-config-cf84k5688d + name: antrea-config-g28k2t6c9k name: antrea-config - name: antrea-controller-tls secret: @@ -4358,7 +4358,7 @@ spec: path: /home/kubernetes/bin name: host-cni-bin - configMap: - name: antrea-config-cf84k5688d + name: antrea-config-g28k2t6c9k name: antrea-config - hostPath: path: /etc/cni/net.d diff --git a/build/yamls/antrea-ipsec.yml b/build/yamls/antrea-ipsec.yml index 1411a50eabf..804ce777563 100644 --- a/build/yamls/antrea-ipsec.yml +++ b/build/yamls/antrea-ipsec.yml @@ -3417,7 +3417,7 @@ rules: - apiGroups: - "" resourceNames: - - antrea-config-9dh28h4g8d + - antrea-config-k2g27bhk9h resources: - configmaps verbs: @@ -3921,14 +3921,14 @@ data: # Enable the integrated Node IPAM controller within the Antrea controller. # enableNodeIPAM: false - # CIDR Ranges for Pods in cluster. Value can contain a single CIDR range, or multiple ranges, separated by commas. + # CIDR Ranges for Pods in cluster. String array containing single CIDR range, or multiple ranges. # The CIDRs could be either IPv4 or IPv6. Value ignored when enableNodeIPAM is false. - # clusterCIDRs: + # clusterCIDRs: [] # CIDR Ranges for Services in cluster. It is not necessary to specify it when there is no overlap with clusterCIDRs. # Value ignored when enableNodeIPAM is false. # serviceCIDR: - # secondaryServiceCIDR: + # serviceCIDRv6: # Mask size for IPv4 Node CIDR in IPv4 or dual-stack cluster. Value ignored when enableNodeIPAM is false # or when IPv4 Pod CIDR is not configured. Valid range is 16 to 30. @@ -3942,7 +3942,7 @@ metadata: annotations: {} labels: app: antrea - name: antrea-config-9dh28h4g8d + name: antrea-config-k2g27bhk9h namespace: kube-system --- apiVersion: v1 @@ -4022,7 +4022,7 @@ spec: fieldRef: fieldPath: spec.serviceAccountName - name: ANTREA_CONFIG_MAP_NAME - value: antrea-config-9dh28h4g8d + value: antrea-config-k2g27bhk9h image: projects.registry.vmware.com/antrea/antrea-ubuntu:latest imagePullPolicy: IfNotPresent livenessProbe: @@ -4073,7 +4073,7 @@ spec: key: node-role.kubernetes.io/master volumes: - configMap: - name: antrea-config-9dh28h4g8d + name: antrea-config-k2g27bhk9h name: antrea-config - name: antrea-controller-tls secret: @@ -4404,7 +4404,7 @@ spec: operator: Exists volumes: - configMap: - name: antrea-config-9dh28h4g8d + name: antrea-config-k2g27bhk9h name: antrea-config - hostPath: path: /etc/cni/net.d diff --git a/build/yamls/antrea.yml b/build/yamls/antrea.yml index 3541e4ad18d..a6750631aad 100644 --- a/build/yamls/antrea.yml +++ b/build/yamls/antrea.yml @@ -3417,7 +3417,7 @@ rules: - apiGroups: - "" resourceNames: - - antrea-config-t4dt6g6kf5 + - antrea-config-c48mcgtk29 resources: - configmaps verbs: @@ -3921,14 +3921,14 @@ data: # Enable the integrated Node IPAM controller within the Antrea controller. # enableNodeIPAM: false - # CIDR Ranges for Pods in cluster. Value can contain a single CIDR range, or multiple ranges, separated by commas. + # CIDR Ranges for Pods in cluster. String array containing single CIDR range, or multiple ranges. # The CIDRs could be either IPv4 or IPv6. Value ignored when enableNodeIPAM is false. - # clusterCIDRs: + # clusterCIDRs: [] # CIDR Ranges for Services in cluster. It is not necessary to specify it when there is no overlap with clusterCIDRs. # Value ignored when enableNodeIPAM is false. # serviceCIDR: - # secondaryServiceCIDR: + # serviceCIDRv6: # Mask size for IPv4 Node CIDR in IPv4 or dual-stack cluster. Value ignored when enableNodeIPAM is false # or when IPv4 Pod CIDR is not configured. Valid range is 16 to 30. @@ -3942,7 +3942,7 @@ metadata: annotations: {} labels: app: antrea - name: antrea-config-t4dt6g6kf5 + name: antrea-config-c48mcgtk29 namespace: kube-system --- apiVersion: v1 @@ -4013,7 +4013,7 @@ spec: fieldRef: fieldPath: spec.serviceAccountName - name: ANTREA_CONFIG_MAP_NAME - value: antrea-config-t4dt6g6kf5 + value: antrea-config-c48mcgtk29 image: projects.registry.vmware.com/antrea/antrea-ubuntu:latest imagePullPolicy: IfNotPresent livenessProbe: @@ -4064,7 +4064,7 @@ spec: key: node-role.kubernetes.io/master volumes: - configMap: - name: antrea-config-t4dt6g6kf5 + name: antrea-config-c48mcgtk29 name: antrea-config - name: antrea-controller-tls secret: @@ -4360,7 +4360,7 @@ spec: operator: Exists volumes: - configMap: - name: antrea-config-t4dt6g6kf5 + name: antrea-config-c48mcgtk29 name: antrea-config - hostPath: path: /etc/cni/net.d diff --git a/build/yamls/base/conf/antrea-controller.conf b/build/yamls/base/conf/antrea-controller.conf index 1edc20143fe..33796fc9aea 100644 --- a/build/yamls/base/conf/antrea-controller.conf +++ b/build/yamls/base/conf/antrea-controller.conf @@ -63,14 +63,14 @@ nodeIPAM: # Enable the integrated Node IPAM controller within the Antrea controller. # enableNodeIPAM: false -# CIDR Ranges for Pods in cluster. Value can contain a single CIDR range, or multiple ranges, separated by commas. +# CIDR Ranges for Pods in cluster. String array containing single CIDR range, or multiple ranges. # The CIDRs could be either IPv4 or IPv6. Value ignored when enableNodeIPAM is false. -# clusterCIDRs: +# clusterCIDRs: [] # CIDR Ranges for Services in cluster. It is not necessary to specify it when there is no overlap with clusterCIDRs. # Value ignored when enableNodeIPAM is false. # serviceCIDR: -# secondaryServiceCIDR: +# serviceCIDRv6: # Mask size for IPv4 Node CIDR in IPv4 or dual-stack cluster. Value ignored when enableNodeIPAM is false # or when IPv4 Pod CIDR is not configured. Valid range is 16 to 30. diff --git a/cmd/antrea-controller/config.go b/cmd/antrea-controller/config.go index 90ceae4a1c7..d1630de7115 100644 --- a/cmd/antrea-controller/config.go +++ b/cmd/antrea-controller/config.go @@ -24,11 +24,11 @@ type NodeIPAMConfig struct { EnableNodeIPAM bool `yaml:"enableNodeIPAM,omitempty"` // CIDR Ranges for Pods in cluster. Value can contain a single CIDR range, or multiple ranges, separated by commas. // The CIDRs could be either IPv4 or IPv6. Value ignored when EnableNodeIPAM is false. - ClusterCIDRs string `yaml:"clusterCIDRs,omitempty"` + ClusterCIDRs []string `yaml:"clusterCIDRs,omitempty"` // CIDR Ranges for Services in cluster. It is not necessary to specify it when there is no overlap with clusterCIDRs. // Value ignored when EnableNodeIPAM is false. - ServiceCIDR string `yaml:"serviceCIDR,omitempty"` - SecondaryServiceCIDR string `yaml:"secondaryServiceCIDR,omitempty"` + ServiceCIDR string `yaml:"serviceCIDR,omitempty"` + ServiceCIDRv6 string `yaml:"serviceCIDRv6,omitempty"` // Mask size for IPv4 Node CIDR in IPv4 or dual-stack cluster. Value ignored when EnableNodeIPAM is false // or when IPv4 Pod CIDR is not configured. NodeCIDRMaskSizeIPv4 int `yaml:"nodeCIDRMaskSizeIPv4,omitempty"` diff --git a/cmd/antrea-controller/controller.go b/cmd/antrea-controller/controller.go index c073cfc1262..39c383c5580 100644 --- a/cmd/antrea-controller/controller.go +++ b/cmd/antrea-controller/controller.go @@ -20,7 +20,6 @@ import ( "net" "os" "path" - "strings" "time" apiextensionclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" @@ -357,16 +356,15 @@ func run(o *Options) error { go networkPolicyStatusController.Run(stopCh) } if features.DefaultFeatureGate.Enabled(features.NodeIPAM) && o.config.NodeIPAM.EnableNodeIPAM { - cidrSplit := strings.Split(strings.TrimSpace(o.config.NodeIPAM.ClusterCIDRs), ",") - clusterCIDRs, _ := netutils.ParseCIDRs(cidrSplit) + clusterCIDRs, _ := netutils.ParseCIDRs(o.config.NodeIPAM.ClusterCIDRs) _, serviceCIDR, _ := net.ParseCIDR(o.config.NodeIPAM.ServiceCIDR) - _, secondaryServiceCIDR, _ := net.ParseCIDR(o.config.NodeIPAM.SecondaryServiceCIDR) + _, serviceCIDRv6, _ := net.ParseCIDR(o.config.NodeIPAM.ServiceCIDRv6) err = startNodeIPAM( client, informerFactory, clusterCIDRs, serviceCIDR, - secondaryServiceCIDR, + serviceCIDRv6, o.config.NodeIPAM.NodeCIDRMaskSizeIPv4, o.config.NodeIPAM.NodeCIDRMaskSizeIPv6, stopCh) @@ -418,7 +416,7 @@ func startNodeIPAM(client clientset.Interface, informerFactory informers.SharedInformerFactory, clusterCIDRs []*net.IPNet, serviceCIDR *net.IPNet, - secondaryServiceCIDR *net.IPNet, + serviceCIDRv6 *net.IPNet, nodeCIDRMaskSizeIPv4 int, nodeCIDRMaskSizeIPv6 int, stopCh <-chan struct{}) error { @@ -429,7 +427,7 @@ func startNodeIPAM(client clientset.Interface, client, clusterCIDRs, serviceCIDR, - secondaryServiceCIDR, + serviceCIDRv6, nodeCIDRMaskSizes, ipam.RangeAllocatorType, ) diff --git a/cmd/antrea-controller/options.go b/cmd/antrea-controller/options.go index 96856af3cec..e1ddb57320b 100644 --- a/cmd/antrea-controller/options.go +++ b/cmd/antrea-controller/options.go @@ -19,7 +19,6 @@ import ( "fmt" "io/ioutil" "net" - "strings" "github.com/spf13/pflag" "gopkg.in/yaml.v2" @@ -88,10 +87,9 @@ func (o *Options) validate(args []string) error { func (o *Options) validateNodeIPAMControllerOptions() error { // Validate ClusterCIDRs - cidrSplit := strings.Split(strings.TrimSpace(o.config.NodeIPAM.ClusterCIDRs), ",") - cidrs, err := netutils.ParseCIDRs(cidrSplit) + cidrs, err := netutils.ParseCIDRs(o.config.NodeIPAM.ClusterCIDRs) if err != nil { - return fmt.Errorf("cluster CIDRs %s is invalid", o.config.NodeIPAM.ClusterCIDRs) + return fmt.Errorf("cluster CIDRs %v is invalid", o.config.NodeIPAM.ClusterCIDRs) } hasIP4, hasIP6 := false, false @@ -116,17 +114,17 @@ func (o *Options) validateNodeIPAMControllerOptions() error { } } - // Validate ServiceCIDR and SecondaryServiceCIDR. Service CIDRs can be empty when there is no overlap with ClusterCIDR + // Validate ServiceCIDR and ServiceCIDRv6. Service CIDRs can be empty when there is no overlap with ClusterCIDR if o.config.NodeIPAM.ServiceCIDR != "" { _, _, err = net.ParseCIDR(o.config.NodeIPAM.ServiceCIDR) if err != nil { return fmt.Errorf("service CIDR %s is invalid", o.config.NodeIPAM.ServiceCIDR) } } - if o.config.NodeIPAM.SecondaryServiceCIDR != "" { - _, _, err = net.ParseCIDR(o.config.NodeIPAM.SecondaryServiceCIDR) + if o.config.NodeIPAM.ServiceCIDRv6 != "" { + _, _, err = net.ParseCIDR(o.config.NodeIPAM.ServiceCIDRv6) if err != nil { - return fmt.Errorf("secondary service CIDR %s is invalid", o.config.NodeIPAM.SecondaryServiceCIDR) + return fmt.Errorf("secondary service CIDR %s is invalid", o.config.NodeIPAM.ServiceCIDRv6) } } return nil