mirror of https://github.com/kubernetes/kops.git
Merge pull request #8930 from justinsb/enabled_to_pointer
Change NodeLocalDNS Enabled to *bool
This commit is contained in:
commit
982496c539
|
|
@ -1616,8 +1616,7 @@ spec:
|
|||
node-local-dns addon
|
||||
properties:
|
||||
enabled:
|
||||
description: Disable indicates we do not wish to run the node-local-dns
|
||||
addon
|
||||
description: Enabled activates the node-local-dns addon
|
||||
type: boolean
|
||||
localIP:
|
||||
description: Local listen IP address. It can be any IP in
|
||||
|
|
|
|||
|
|
@ -406,8 +406,8 @@ type KubeDNSConfig struct {
|
|||
|
||||
// NodeLocalDNSConfig are options of the node-local-dns
|
||||
type NodeLocalDNSConfig struct {
|
||||
// Disable indicates we do not wish to run the node-local-dns addon
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
// Enabled activates the node-local-dns addon
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
// Local listen IP address. It can be any IP in the 169.254.20.0/16 space or any other IP address that can be guaranteed to not collide with any existing IP.
|
||||
LocalIP string `json:"localIP,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -404,8 +404,8 @@ type KubeDNSConfig struct {
|
|||
|
||||
// NodeLocalDNSConfig are options of the node-local-dns
|
||||
type NodeLocalDNSConfig struct {
|
||||
// Disable indicates we do not wish to run the node-local-dns addon
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
// Enabled activates the node-local-dns addon
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
// Local listen IP address. It can be any IP in the 169.254.20.0/16 space or any other IP address that can be guaranteed to not collide with any existing IP.
|
||||
LocalIP string `json:"localIP,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2480,7 +2480,7 @@ func (in *KubeDNSConfig) DeepCopyInto(out *KubeDNSConfig) {
|
|||
if in.NodeLocalDNS != nil {
|
||||
in, out := &in.NodeLocalDNS, &out.NodeLocalDNS
|
||||
*out = new(NodeLocalDNSConfig)
|
||||
**out = **in
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -3209,6 +3209,11 @@ func (in *NodeAuthorizerSpec) DeepCopy() *NodeAuthorizerSpec {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NodeLocalDNSConfig) DeepCopyInto(out *NodeLocalDNSConfig) {
|
||||
*out = *in
|
||||
if in.Enabled != nil {
|
||||
in, out := &in.Enabled, &out.Enabled
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ func ValidateCluster(c *kops.Cluster, strict bool) field.ErrorList {
|
|||
}
|
||||
|
||||
// @ check that NodeLocalDNS addon is configured correctly
|
||||
if c.Spec.KubeDNS.NodeLocalDNS != nil && c.Spec.KubeDNS.NodeLocalDNS.Enabled {
|
||||
if c.Spec.KubeDNS.NodeLocalDNS != nil && fi.BoolValue(c.Spec.KubeDNS.NodeLocalDNS.Enabled) {
|
||||
if c.Spec.KubeDNS.Provider != "CoreDNS" {
|
||||
allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("kubeDNS", "provider"), "KubeDNS provider must be set to CoreDNS if NodeLocalDNS addon is enabled"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/kops/pkg/apis/kops"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
)
|
||||
|
||||
func Test_Validate_DNS(t *testing.T) {
|
||||
|
|
@ -548,7 +549,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) {
|
|||
KubeDNS: &kops.KubeDNSConfig{
|
||||
Provider: "CoreDNS",
|
||||
NodeLocalDNS: &kops.NodeLocalDNSConfig{
|
||||
Enabled: true,
|
||||
Enabled: fi.Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -565,7 +566,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) {
|
|||
KubeDNS: &kops.KubeDNSConfig{
|
||||
Provider: "CoreDNS",
|
||||
NodeLocalDNS: &kops.NodeLocalDNSConfig{
|
||||
Enabled: true,
|
||||
Enabled: fi.Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -582,7 +583,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) {
|
|||
KubeDNS: &kops.KubeDNSConfig{
|
||||
Provider: "CoreDNS",
|
||||
NodeLocalDNS: &kops.NodeLocalDNSConfig{
|
||||
Enabled: true,
|
||||
Enabled: fi.Bool(true),
|
||||
},
|
||||
},
|
||||
Networking: &kops.NetworkingSpec{
|
||||
|
|
@ -602,7 +603,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) {
|
|||
KubeDNS: &kops.KubeDNSConfig{
|
||||
Provider: "CoreDNS",
|
||||
NodeLocalDNS: &kops.NodeLocalDNSConfig{
|
||||
Enabled: true,
|
||||
Enabled: fi.Bool(true),
|
||||
LocalIP: "169.254.20.10",
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2662,7 +2662,7 @@ func (in *KubeDNSConfig) DeepCopyInto(out *KubeDNSConfig) {
|
|||
if in.NodeLocalDNS != nil {
|
||||
in, out := &in.NodeLocalDNS, &out.NodeLocalDNS
|
||||
*out = new(NodeLocalDNSConfig)
|
||||
**out = **in
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -3407,6 +3407,11 @@ func (in *NodeAuthorizerSpec) DeepCopy() *NodeAuthorizerSpec {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NodeLocalDNSConfig) DeepCopyInto(out *NodeLocalDNSConfig) {
|
||||
*out = *in
|
||||
if in.Enabled != nil {
|
||||
in, out := &in.Enabled, &out.Enabled
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package components
|
|||
import (
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
"k8s.io/kops/pkg/apis/kops"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kops/upup/pkg/fi/loader"
|
||||
)
|
||||
|
||||
|
|
@ -77,8 +78,8 @@ func (b *KubeDnsOptionsBuilder) BuildOptions(o interface{}) error {
|
|||
NodeLocalDNS := clusterSpec.KubeDNS.NodeLocalDNS
|
||||
if NodeLocalDNS == nil {
|
||||
NodeLocalDNS = &kops.NodeLocalDNSConfig{}
|
||||
NodeLocalDNS.Enabled = false
|
||||
} else if NodeLocalDNS.Enabled && NodeLocalDNS.LocalIP == "" {
|
||||
NodeLocalDNS.Enabled = fi.Bool(false)
|
||||
} else if fi.BoolValue(NodeLocalDNS.Enabled) && NodeLocalDNS.LocalIP == "" {
|
||||
NodeLocalDNS.LocalIP = "169.254.20.10"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -451,9 +451,9 @@ func (b *BootstrapChannelBuilder) buildAddons() *channelsapi.Addons {
|
|||
}
|
||||
}
|
||||
|
||||
// @check the node-local-dns has not been disabled
|
||||
// @check if the node-local-dns is enabled
|
||||
NodeLocalDNS := b.cluster.Spec.KubeDNS.NodeLocalDNS
|
||||
if kubeDNS.Provider == "CoreDNS" && NodeLocalDNS != nil && NodeLocalDNS.Enabled {
|
||||
if kubeDNS.Provider == "CoreDNS" && NodeLocalDNS != nil && fi.BoolValue(NodeLocalDNS.Enabled) {
|
||||
{
|
||||
key := "nodelocaldns.addons.k8s.io"
|
||||
version := "1.18.0"
|
||||
|
|
|
|||
Loading…
Reference in New Issue