Skip to content

Commit

Permalink
Add global gw option
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmacko committed Feb 1, 2019
1 parent 35a99aa commit b95a021
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions k8s/contiv-vpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Parameter | Description | Default
`contiv.ipamConfig.vxlanCIDR` | VXLAN CIDR | `192.168.30.0/24`
`contiv.ipamConfig.nodeInterconnectCIDR` | Node interconnect CIDR, uses DHCP if empty | `""`
`contiv.ipamConfig.serviceCIDR` | Service CIDR | `""`
`contiv.ipamConfig.defaultGateway` | Default gateway for all nodes (can be overridden by a nodeconfig)| `""`
`contiv.nodeConfig.*` | List of node configs, see example section in values.yaml | `""`
`contiv.vswitch.defineMemoryLimits` | define limits for vswitch container | `false`
`contiv.vswitch.hugePages2miLimit` | limit of memory allocated by 2048Kb hugepages for vswitch container| `1024Mi`
Expand Down
3 changes: 3 additions & 0 deletions k8s/contiv-vpp/templates/vpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ data:
{{- if .Values.contiv.ipamConfig.nodeInterconnectCIDR }}
nodeInterconnectCIDR: {{ .Values.contiv.ipamConfig.nodeInterconnectCIDR }}
{{- end }}
{{- if .Values.contiv.ipamConfig.defaultGateway }}
defaultGateway: {{ .Values.contiv.ipamConfig.defaultGateway }}
{{- end }}
{{- if .Values.contiv.ipamConfig.serviceCIDR }}
serviceCIDR: {{ .Values.contiv.ipamConfig.serviceCIDR }}
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions k8s/contiv-vpp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contiv:
nodeInterconnectCIDR: 192.168.16.0/24
vxlanCIDR: 192.168.30.0/24
nodeInterconnectDHCP: false
# defaultGateway: 192.168.16.100
# serviceCIDR: "10.96.0.0/12"
# example of node configuration for VPP interfaces
# nodeConfig:
Expand Down
9 changes: 9 additions & 0 deletions plugins/contivconf/contivconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ type IPAMConfigForJSON struct {
VPPHostSubnetOneNodePrefixLen uint8 `json:"vppHostSubnetOneNodePrefixLen,omitempty"`
NodeInterconnectCIDR string `json:"nodeInterconnectCIDR,omitempty"`
VxlanCIDR string `json:"vxlanCIDR,omitempty"`
DefaultGateway string `json:"defaultGateway,omitempty"`
}

// NodeConfig represents configuration specific to a given node.
Expand Down Expand Up @@ -385,6 +386,12 @@ func (c *ContivConf) Init() (err error) {
if err != nil {
return fmt.Errorf("failed to parse VxlanCIDR: %v", err)
}
if c.config.IPAMConfig.DefaultGateway != "" {
c.ipamConfig.DefaultGateway = net.ParseIP(c.config.IPAMConfig.DefaultGateway)
if c.ipamConfig.DefaultGateway == nil {
return fmt.Errorf("failed to parse default gateway %v", c.config.IPAMConfig.DefaultGateway)
}
}

// create GoVPP channel for contiv-agent
if c.ContivAgentDeps != nil && c.UnitTestDeps == nil {
Expand Down Expand Up @@ -751,6 +758,8 @@ func (c *ContivConf) reloadNodeInterfaces() error {
nodeConfig.Gateway)
return err
}
} else if c.ipamConfig.DefaultGateway != nil {
c.defaultGw = c.ipamConfig.DefaultGateway
}
}

Expand Down
4 changes: 4 additions & 0 deletions plugins/contivconf/contivconf_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ type IPAMConfig struct {
// (NodeInterconnectCIDR does not have to be allocated in that case)
NodeInterconnectDHCP bool

// DefaultGateway is global option to set default gateway for nodes. Alternatively,
// nodeConfig can be used
DefaultGateway net.IP

// Manually selected subnets (if ContivCIDR is defined, this is overridden
// by IPAM's own allocation algorithm).
CustomIPAMSubnets
Expand Down
24 changes: 4 additions & 20 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,6 @@ spec:
---
EOL
# Generate node config for use without CRD
cat > /tmp/nodeConfig.yaml <<EOL
nodeConfig:
- name: "k8s-master"
mainInterface:
interfaceName: "GigabitEthernet0/8/0"
gateway: "192.168.16.100"
EOL
counter=1;
until ((counter > "#{num_nodes}"))
do
Expand All @@ -418,14 +408,6 @@ spec:
---
EOL
# Generate node config for use without CRD
cat <<EOL >> /tmp/nodeConfig.yaml
- name: "k8s-worker$counter"
mainInterface:
interfaceName: "GigabitEthernet0/8/0"
gateway: "192.168.16.100"
EOL
((counter++))
done
else
Expand Down Expand Up @@ -492,9 +474,11 @@ applyVPPnetwork() {
kubectl apply -f #{contiv_dir}/k8s/node-config/crd.yaml
else
if [ "#{dep_scenario}" = "nostn" ]; then
gateway_config="--set contiv.ipamConfig.defaultGateway=192.168.16.100"
fi
# Deploy contiv-vpp networking without CRD
sed -i '/# serviceCIDR:/ r /tmp/nodeConfig.yaml' "#{contiv_dir}"/k8s/contiv-vpp/values.yaml
helm template #{helm_extra_opts} --name vagrant $stn_config --set contiv.routeServiceCIDRToVPP=true --set contiv.tapv2RxRingSize=1024 --set contiv.tapv2TxRingSize=1024 "#{contiv_dir}"/k8s/contiv-vpp > "#{contiv_dir}"/k8s/contiv-vpp/manifest.yaml
helm template #{helm_extra_opts} --name vagrant $stn_config $gateway_config --set contiv.routeServiceCIDRToVPP=true --set contiv.tapv2RxRingSize=1024 --set contiv.tapv2TxRingSize=1024 "#{contiv_dir}"/k8s/contiv-vpp > "#{contiv_dir}"/k8s/contiv-vpp/manifest.yaml
kubectl apply -f #{contiv_dir}/k8s/contiv-vpp/manifest.yaml
fi
Expand Down

0 comments on commit b95a021

Please sign in to comment.