Add node CIDR allocation as an option to kubeadm.

This is useful for users who are used to deploying with a flannel
overlay network.
pull/6/head
Atanas Mirchev 2016-09-19 09:44:17 +02:00 committed by Ilya Dmitrichenko
parent 38b53e31f3
commit 9eeae34581
No known key found for this signature in database
GPG Key ID: E7889175A6C0CEB9
3 changed files with 26 additions and 11 deletions

View File

@ -51,6 +51,9 @@ type InitFlags struct {
CIDR net.IPNet
DNSDomain string
}
PodNetwork struct {
CIDR net.IPNet
}
CloudProvider string
Schedulable bool
}

View File

@ -65,22 +65,27 @@ func NewCmdInit(out io.Writer, s *kubeadmapi.KubeadmConfig) *cobra.Command {
&s.InitFlags.API.ExternalDNSNames, "api-external-dns-names", []string{},
`(optional) The DNS names to advertise, in case you have configured them yourself.`,
)
cmd.PersistentFlags().IPNetVar(
&s.InitFlags.Services.CIDR, "service-cidr", *kubeadmapi.DefaultServicesCIDR,
`(optional) use alternative range of IP address for service VIPs, e.g. "10.16.0.0/12"`,
`(optional) Use alterantive range of IP address for service VIPs, defaults to `+
kubeadmapi.DefaultServicesCIDRString,
)
cmd.PersistentFlags().IPNetVar(
&s.InitFlags.PodNetwork.CIDR, "pod-network-cidr", net.IPNet{},
`(optional) Specify range of IP addresses for the pod overlay network, e.g. 10.3.0.0/16.`+
`If set, the control plane will automatically attempt to allocate Pod network CIDRs for every node.`,
)
cmd.PersistentFlags().StringVar(
&s.InitFlags.Services.DNSDomain, "service-dns-domain", kubeadmapi.DefaultServiceDNSDomain,
`(optional) use alternative domain for services, e.g. "myorg.internal"`,
`(optional) Use alternative domain for services, e.g. "myorg.internal"`,
)
cmd.PersistentFlags().StringVar(
&s.InitFlags.CloudProvider, "cloud-provider", "",
`(optional) enable a specific cloud provider features (external load-balancers, storage, etc), e.g. "gce"`,
`(optional) Enable a specific cloud provider features (external load-balancers, storage, etc), e.g. "gce"`,
)
cmd.PersistentFlags().BoolVar(
&s.InitFlags.Schedulable, "schedule-workload", false,
`(optional) allow to schedule workload to the node`,
`(optional) Allow to schedule workload to the node`,
)
// TODO (phase1+) @errordeveloper make the flags below not show up in --help but rather on --advanced-help

View File

@ -262,7 +262,6 @@ func getComponentCommand(component string, s *kubeadmapi.KubeadmConfig) (command
"--cluster-signing-cert-file=" + pkiDir + "/ca.pem",
"--cluster-signing-key-file=" + pkiDir + "/ca-key.pem",
"--insecure-experimental-approve-all-kubelet-csrs-for-group=system:kubelet-bootstrap",
"--cluster-cidr=" + s.InitFlags.Services.CIDR.String(),
},
scheduler: []string{
// TODO: consider adding --address=127.0.0.1 in order to not expose the scheduler port to the rest of the world
@ -281,12 +280,20 @@ func getComponentCommand(component string, s *kubeadmapi.KubeadmConfig) (command
command = append(command, s.EnvParams["component_loglevel"])
command = append(command, baseFlags[component]...)
if component == controllerManager && s.InitFlags.CloudProvider != "" {
command = append(command, "--cloud-provider="+s.InitFlags.CloudProvider)
if component == controllerManager {
if s.InitFlags.CloudProvider != "" {
command = append(command, "--cloud-provider="+s.InitFlags.CloudProvider)
// Only append the --cloud-config option if there's a such file
if _, err := os.Stat(DefaultCloudConfigPath); err == nil {
command = append(command, "--cloud-config="+DefaultCloudConfigPath)
// Only append the --cloud-config option if there's a such file
if _, err := os.Stat(DefaultCloudConfigPath); err == nil {
command = append(command, "--cloud-config="+DefaultCloudConfigPath)
}
}
if s.InitFlags.PodNetwork.CIDR.IP != nil {
// Let the controller-manager allocate Node CIDRs for the Pod overlay network.
// Each node will get a subspace of the address CIDR provided with --cluster-cidr.
command = append(command, "--allocate-node-cidrs=true", "--cluster-cidr="+s.InitFlags.PodNetwork.CIDR.String())
}
}