Skip to content

Commit

Permalink
Unify config name and format (#2843)
Browse files Browse the repository at this point in the history
Use same naming and format convention for for NodeIPAM as it is for
other Antrea features.

Fixes: #2839
Signed-off-by: Kobi Samoray <[email protected]>
  • Loading branch information
ksamoray authored Sep 28, 2021
1 parent 138827c commit 5480b68
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 56 deletions.
14 changes: 7 additions & 7 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4033,14 +4033,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.
Expand All @@ -4054,7 +4054,7 @@ metadata:
annotations: {}
labels:
app: antrea
name: antrea-config-dtc759g79k
name: antrea-config-b72h88gb7b
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -4125,7 +4125,7 @@ spec:
fieldRef:
fieldPath: spec.serviceAccountName
- name: ANTREA_CONFIG_MAP_NAME
value: antrea-config-dtc759g79k
value: antrea-config-b72h88gb7b
image: projects.registry.vmware.com/antrea/antrea-ubuntu:latest
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down Expand Up @@ -4176,7 +4176,7 @@ spec:
key: node-role.kubernetes.io/master
volumes:
- configMap:
name: antrea-config-dtc759g79k
name: antrea-config-b72h88gb7b
name: antrea-config
- name: antrea-controller-tls
secret:
Expand Down Expand Up @@ -4457,7 +4457,7 @@ spec:
operator: Exists
volumes:
- configMap:
name: antrea-config-dtc759g79k
name: antrea-config-b72h88gb7b
name: antrea-config
- hostPath:
path: /etc/cni/net.d
Expand Down
14 changes: 7 additions & 7 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4033,14 +4033,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.
Expand All @@ -4054,7 +4054,7 @@ metadata:
annotations: {}
labels:
app: antrea
name: antrea-config-dtc759g79k
name: antrea-config-b72h88gb7b
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -4125,7 +4125,7 @@ spec:
fieldRef:
fieldPath: spec.serviceAccountName
- name: ANTREA_CONFIG_MAP_NAME
value: antrea-config-dtc759g79k
value: antrea-config-b72h88gb7b
image: projects.registry.vmware.com/antrea/antrea-ubuntu:latest
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down Expand Up @@ -4176,7 +4176,7 @@ spec:
key: node-role.kubernetes.io/master
volumes:
- configMap:
name: antrea-config-dtc759g79k
name: antrea-config-b72h88gb7b
name: antrea-config
- name: antrea-controller-tls
secret:
Expand Down Expand Up @@ -4459,7 +4459,7 @@ spec:
operator: Exists
volumes:
- configMap:
name: antrea-config-dtc759g79k
name: antrea-config-b72h88gb7b
name: antrea-config
- hostPath:
path: /etc/cni/net.d
Expand Down
14 changes: 7 additions & 7 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4033,14 +4033,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.
Expand All @@ -4054,7 +4054,7 @@ metadata:
annotations: {}
labels:
app: antrea
name: antrea-config-65f7gf8456
name: antrea-config-hfkckg6t57
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -4125,7 +4125,7 @@ spec:
fieldRef:
fieldPath: spec.serviceAccountName
- name: ANTREA_CONFIG_MAP_NAME
value: antrea-config-65f7gf8456
value: antrea-config-hfkckg6t57
image: projects.registry.vmware.com/antrea/antrea-ubuntu:latest
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down Expand Up @@ -4176,7 +4176,7 @@ spec:
key: node-role.kubernetes.io/master
volumes:
- configMap:
name: antrea-config-65f7gf8456
name: antrea-config-hfkckg6t57
name: antrea-config
- name: antrea-controller-tls
secret:
Expand Down Expand Up @@ -4460,7 +4460,7 @@ spec:
path: /home/kubernetes/bin
name: host-cni-bin
- configMap:
name: antrea-config-65f7gf8456
name: antrea-config-hfkckg6t57
name: antrea-config
- hostPath:
path: /etc/cni/net.d
Expand Down
14 changes: 7 additions & 7 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4038,14 +4038,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.
Expand All @@ -4059,7 +4059,7 @@ metadata:
annotations: {}
labels:
app: antrea
name: antrea-config-fcd8c2h5b5
name: antrea-config-4f28b82tdt
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -4139,7 +4139,7 @@ spec:
fieldRef:
fieldPath: spec.serviceAccountName
- name: ANTREA_CONFIG_MAP_NAME
value: antrea-config-fcd8c2h5b5
value: antrea-config-4f28b82tdt
image: projects.registry.vmware.com/antrea/antrea-ubuntu:latest
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down Expand Up @@ -4190,7 +4190,7 @@ spec:
key: node-role.kubernetes.io/master
volumes:
- configMap:
name: antrea-config-fcd8c2h5b5
name: antrea-config-4f28b82tdt
name: antrea-config
- name: antrea-controller-tls
secret:
Expand Down Expand Up @@ -4506,7 +4506,7 @@ spec:
operator: Exists
volumes:
- configMap:
name: antrea-config-fcd8c2h5b5
name: antrea-config-4f28b82tdt
name: antrea-config
- hostPath:
path: /etc/cni/net.d
Expand Down
14 changes: 7 additions & 7 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4038,14 +4038,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.
Expand All @@ -4059,7 +4059,7 @@ metadata:
annotations: {}
labels:
app: antrea
name: antrea-config-dhb74b822t
name: antrea-config-bmthb2m52d
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -4130,7 +4130,7 @@ spec:
fieldRef:
fieldPath: spec.serviceAccountName
- name: ANTREA_CONFIG_MAP_NAME
value: antrea-config-dhb74b822t
value: antrea-config-bmthb2m52d
image: projects.registry.vmware.com/antrea/antrea-ubuntu:latest
imagePullPolicy: IfNotPresent
livenessProbe:
Expand Down Expand Up @@ -4181,7 +4181,7 @@ spec:
key: node-role.kubernetes.io/master
volumes:
- configMap:
name: antrea-config-dhb74b822t
name: antrea-config-bmthb2m52d
name: antrea-config
- name: antrea-controller-tls
secret:
Expand Down Expand Up @@ -4462,7 +4462,7 @@ spec:
operator: Exists
volumes:
- configMap:
name: antrea-config-dhb74b822t
name: antrea-config-bmthb2m52d
name: antrea-config
- hostPath:
path: /etc/cni/net.d
Expand Down
6 changes: 3 additions & 3 deletions build/yamls/base/conf/antrea-controller.conf
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,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.
Expand Down
6 changes: 3 additions & 3 deletions cmd/antrea-controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
12 changes: 5 additions & 7 deletions cmd/antrea-controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"net"
"os"
"path"
"strings"
"time"

apiextensionclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
Expand Down Expand Up @@ -339,16 +338,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)
Expand Down Expand Up @@ -395,7 +393,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 {
Expand All @@ -406,7 +404,7 @@ func startNodeIPAM(client clientset.Interface,
client,
clusterCIDRs,
serviceCIDR,
secondaryServiceCIDR,
serviceCIDRv6,
nodeCIDRMaskSizes,
ipam.RangeAllocatorType,
)
Expand Down
14 changes: 6 additions & 8 deletions cmd/antrea-controller/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"io/ioutil"
"net"
"strings"

"github.com/spf13/pflag"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5480b68

Please sign in to comment.