mirror of https://github.com/kubernetes/kops.git
Merge pull request #5460 from rdrgmnzs/BindPrimaryIP
Allow kubelet to bind the hosts primary IP
This commit is contained in:
commit
21f97545f3
|
|
@ -278,6 +278,15 @@ func (c *NodeupModelContext) UseNodeAuthorizer() bool {
|
|||
return c.Cluster.Spec.NodeAuthorization.NodeAuthorizer != nil
|
||||
}
|
||||
|
||||
// UsesSecondaryIP checks if the CNI in use attaches secondary interfaces to the host.
|
||||
func (c *NodeupModelContext) UsesSecondaryIP() bool {
|
||||
if (c.Cluster.Spec.Networking.CNI != nil && c.Cluster.Spec.Networking.CNI.UsesSecondaryIP) || c.Cluster.Spec.Networking.AmazonVPC != nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// UseBootstrapTokens checks if we are using bootstrap tokens
|
||||
func (c *NodeupModelContext) UseBootstrapTokens() bool {
|
||||
if c.IsMaster {
|
||||
|
|
|
|||
|
|
@ -172,8 +172,9 @@ func (b *KubeletBuilder) buildSystemdEnvironmentFile(kubeletConfig *kops.Kubelet
|
|||
if b.UsesCNI() {
|
||||
flags += " --cni-bin-dir=" + b.CNIBinDir()
|
||||
flags += " --cni-conf-dir=" + b.CNIConfDir()
|
||||
// If we are using the AmazonVPC plugin we need to bind the kubelet to the local ipv4 address
|
||||
if b.Cluster.Spec.Networking.AmazonVPC != nil {
|
||||
}
|
||||
|
||||
if b.UsesSecondaryIP() {
|
||||
sess := session.Must(session.NewSession())
|
||||
metadata := ec2metadata.New(sess)
|
||||
localIpv4, err := metadata.GetMetadata("local-ipv4")
|
||||
|
|
@ -182,7 +183,6 @@ func (b *KubeletBuilder) buildSystemdEnvironmentFile(kubeletConfig *kops.Kubelet
|
|||
}
|
||||
flags += " --node-ip=" + localIpv4
|
||||
}
|
||||
}
|
||||
|
||||
if b.Cluster.Spec.Networking != nil && b.Cluster.Spec.Networking.Kubenet != nil {
|
||||
// Kubenet is neither CNI nor not-CNI, so we need to pass it `--cni-bin-dir` also
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ type ExternalNetworkingSpec struct {
|
|||
// Networking is not managed by kops - we can create options here that directly configure e.g. weave
|
||||
// but this is useful for arbitrary network modes or for modes that don't need additional configuration.
|
||||
type CNINetworkingSpec struct {
|
||||
UsesSecondaryIP bool `json:"usesSecondaryIP,omitempty"`
|
||||
}
|
||||
|
||||
// KopeioNetworkingSpec declares that we want Kopeio networking
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ type ExternalNetworkingSpec struct {
|
|||
// Networking is not managed by kops - we can create options here that directly configure e.g. weave
|
||||
// but this is useful for arbitrary network modes or for modes that don't need additional configuration.
|
||||
type CNINetworkingSpec struct {
|
||||
UsesSecondaryIP bool `json:"usesSecondaryIP,omitempty"`
|
||||
}
|
||||
|
||||
// KopeioNetworkingSpec declares that we want Kopeio networking
|
||||
|
|
|
|||
|
|
@ -426,6 +426,7 @@ func Convert_kops_AwsAuthenticationSpec_To_v1alpha1_AwsAuthenticationSpec(in *ko
|
|||
}
|
||||
|
||||
func autoConvert_v1alpha1_CNINetworkingSpec_To_kops_CNINetworkingSpec(in *CNINetworkingSpec, out *kops.CNINetworkingSpec, s conversion.Scope) error {
|
||||
out.UsesSecondaryIP = in.UsesSecondaryIP
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -435,6 +436,7 @@ func Convert_v1alpha1_CNINetworkingSpec_To_kops_CNINetworkingSpec(in *CNINetwork
|
|||
}
|
||||
|
||||
func autoConvert_kops_CNINetworkingSpec_To_v1alpha1_CNINetworkingSpec(in *kops.CNINetworkingSpec, out *CNINetworkingSpec, s conversion.Scope) error {
|
||||
out.UsesSecondaryIP = in.UsesSecondaryIP
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ type ExternalNetworkingSpec struct {
|
|||
// Networking is not managed by kops - we can create options here that directly configure e.g. weave
|
||||
// but this is useful for arbitrary network modes or for modes that don't need additional configuration.
|
||||
type CNINetworkingSpec struct {
|
||||
UsesSecondaryIP bool `json:"usesSecondaryIP,omitempty"`
|
||||
}
|
||||
|
||||
// KopeioNetworkingSpec declares that we want Kopeio networking
|
||||
|
|
|
|||
|
|
@ -462,6 +462,7 @@ func Convert_kops_BastionSpec_To_v1alpha2_BastionSpec(in *kops.BastionSpec, out
|
|||
}
|
||||
|
||||
func autoConvert_v1alpha2_CNINetworkingSpec_To_kops_CNINetworkingSpec(in *CNINetworkingSpec, out *kops.CNINetworkingSpec, s conversion.Scope) error {
|
||||
out.UsesSecondaryIP = in.UsesSecondaryIP
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -471,6 +472,7 @@ func Convert_v1alpha2_CNINetworkingSpec_To_kops_CNINetworkingSpec(in *CNINetwork
|
|||
}
|
||||
|
||||
func autoConvert_kops_CNINetworkingSpec_To_v1alpha2_CNINetworkingSpec(in *kops.CNINetworkingSpec, out *CNINetworkingSpec, s conversion.Scope) error {
|
||||
out.UsesSecondaryIP = in.UsesSecondaryIP
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue