-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to exclude end ips (#155)
* Update doc to reflect using cidr will exclude network address and broadcast address by default Signed-off-by: Lubron Zhan <[email protected]>
- Loading branch information
1 parent
7262739
commit 11c3012
Showing
9 changed files
with
281 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package config | ||
|
||
import v1 "k8s.io/api/core/v1" | ||
|
||
const ( | ||
// ConfigMapSearchOrderKey is the key in the ConfigMap that defines whether IPs are allocated from the beginning or from the end. | ||
ConfigMapSearchOrderKey = "search-order" | ||
|
||
// ConfigMapSkipStartIPsKey is the key in the ConfigMap that has the IPs to skip at the start and end of the CIDR | ||
ConfigMapSkipEndIPsKey = "skip-end-ips-in-cidr" | ||
|
||
// ConfigMapServiceInterfacePrefix is prefix of the key in the ConfigMap for specifying the service interface for that namespace | ||
ConfigMapServiceInterfacePrefix = "interface" | ||
) | ||
|
||
// KubevipLBConfig defines the configuration for the kube-vip load balancer in the kubevip configMap | ||
// TODO: move all config into here so that it can be easily accessed and processed | ||
type KubevipLBConfig struct { | ||
ReturnIPInDescOrder bool | ||
SkipEndIPsInCIDR bool | ||
} | ||
|
||
// GetKubevipLBConfig returns the KubevipLBConfig from the ConfigMap | ||
func GetKubevipLBConfig(cm *v1.ConfigMap) *KubevipLBConfig { | ||
c := &KubevipLBConfig{} | ||
if searchOrder, ok := cm.Data[ConfigMapSearchOrderKey]; ok { | ||
if searchOrder == "desc" { | ||
c.ReturnIPInDescOrder = true | ||
} | ||
} | ||
if skip, ok := cm.Data[ConfigMapSkipEndIPsKey]; ok { | ||
if skip == "true" { | ||
c.SkipEndIPsInCIDR = true | ||
} | ||
} | ||
return c | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.