Merge pull request #8930 from justinsb/enabled_to_pointer

Change NodeLocalDNS Enabled to *bool
This commit is contained in:
Kubernetes Prow Robot 2020-04-16 21:55:06 -07:00 committed by GitHub
commit 982496c539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 17 deletions

View File

@ -1616,8 +1616,7 @@ spec:
node-local-dns addon node-local-dns addon
properties: properties:
enabled: enabled:
description: Disable indicates we do not wish to run the node-local-dns description: Enabled activates the node-local-dns addon
addon
type: boolean type: boolean
localIP: localIP:
description: Local listen IP address. It can be any IP in description: Local listen IP address. It can be any IP in

View File

@ -406,8 +406,8 @@ type KubeDNSConfig struct {
// NodeLocalDNSConfig are options of the node-local-dns // NodeLocalDNSConfig are options of the node-local-dns
type NodeLocalDNSConfig struct { type NodeLocalDNSConfig struct {
// Disable indicates we do not wish to run the node-local-dns addon // Enabled activates the node-local-dns addon
Enabled bool `json:"enabled,omitempty"` 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. // 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"` LocalIP string `json:"localIP,omitempty"`
} }

View File

@ -404,8 +404,8 @@ type KubeDNSConfig struct {
// NodeLocalDNSConfig are options of the node-local-dns // NodeLocalDNSConfig are options of the node-local-dns
type NodeLocalDNSConfig struct { type NodeLocalDNSConfig struct {
// Disable indicates we do not wish to run the node-local-dns addon // Enabled activates the node-local-dns addon
Enabled bool `json:"enabled,omitempty"` 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. // 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"` LocalIP string `json:"localIP,omitempty"`
} }

View File

@ -2480,7 +2480,7 @@ func (in *KubeDNSConfig) DeepCopyInto(out *KubeDNSConfig) {
if in.NodeLocalDNS != nil { if in.NodeLocalDNS != nil {
in, out := &in.NodeLocalDNS, &out.NodeLocalDNS in, out := &in.NodeLocalDNS, &out.NodeLocalDNS
*out = new(NodeLocalDNSConfig) *out = new(NodeLocalDNSConfig)
**out = **in (*in).DeepCopyInto(*out)
} }
return 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. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeLocalDNSConfig) DeepCopyInto(out *NodeLocalDNSConfig) { func (in *NodeLocalDNSConfig) DeepCopyInto(out *NodeLocalDNSConfig) {
*out = *in *out = *in
if in.Enabled != nil {
in, out := &in.Enabled, &out.Enabled
*out = new(bool)
**out = **in
}
return return
} }

View File

@ -287,7 +287,7 @@ func ValidateCluster(c *kops.Cluster, strict bool) field.ErrorList {
} }
// @ check that NodeLocalDNS addon is configured correctly // @ 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" { 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")) allErrs = append(allErrs, field.Forbidden(fieldSpec.Child("kubeDNS", "provider"), "KubeDNS provider must be set to CoreDNS if NodeLocalDNS addon is enabled"))
} }

View File

@ -24,6 +24,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
) )
func Test_Validate_DNS(t *testing.T) { func Test_Validate_DNS(t *testing.T) {
@ -548,7 +549,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) {
KubeDNS: &kops.KubeDNSConfig{ KubeDNS: &kops.KubeDNSConfig{
Provider: "CoreDNS", Provider: "CoreDNS",
NodeLocalDNS: &kops.NodeLocalDNSConfig{ NodeLocalDNS: &kops.NodeLocalDNSConfig{
Enabled: true, Enabled: fi.Bool(true),
}, },
}, },
}, },
@ -565,7 +566,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) {
KubeDNS: &kops.KubeDNSConfig{ KubeDNS: &kops.KubeDNSConfig{
Provider: "CoreDNS", Provider: "CoreDNS",
NodeLocalDNS: &kops.NodeLocalDNSConfig{ NodeLocalDNS: &kops.NodeLocalDNSConfig{
Enabled: true, Enabled: fi.Bool(true),
}, },
}, },
}, },
@ -582,7 +583,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) {
KubeDNS: &kops.KubeDNSConfig{ KubeDNS: &kops.KubeDNSConfig{
Provider: "CoreDNS", Provider: "CoreDNS",
NodeLocalDNS: &kops.NodeLocalDNSConfig{ NodeLocalDNS: &kops.NodeLocalDNSConfig{
Enabled: true, Enabled: fi.Bool(true),
}, },
}, },
Networking: &kops.NetworkingSpec{ Networking: &kops.NetworkingSpec{
@ -602,7 +603,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) {
KubeDNS: &kops.KubeDNSConfig{ KubeDNS: &kops.KubeDNSConfig{
Provider: "CoreDNS", Provider: "CoreDNS",
NodeLocalDNS: &kops.NodeLocalDNSConfig{ NodeLocalDNS: &kops.NodeLocalDNSConfig{
Enabled: true, Enabled: fi.Bool(true),
LocalIP: "169.254.20.10", LocalIP: "169.254.20.10",
}, },
}, },

View File

@ -2662,7 +2662,7 @@ func (in *KubeDNSConfig) DeepCopyInto(out *KubeDNSConfig) {
if in.NodeLocalDNS != nil { if in.NodeLocalDNS != nil {
in, out := &in.NodeLocalDNS, &out.NodeLocalDNS in, out := &in.NodeLocalDNS, &out.NodeLocalDNS
*out = new(NodeLocalDNSConfig) *out = new(NodeLocalDNSConfig)
**out = **in (*in).DeepCopyInto(*out)
} }
return 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. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeLocalDNSConfig) DeepCopyInto(out *NodeLocalDNSConfig) { func (in *NodeLocalDNSConfig) DeepCopyInto(out *NodeLocalDNSConfig) {
*out = *in *out = *in
if in.Enabled != nil {
in, out := &in.Enabled, &out.Enabled
*out = new(bool)
**out = **in
}
return return
} }

View File

@ -19,6 +19,7 @@ package components
import ( import (
"k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/loader" "k8s.io/kops/upup/pkg/fi/loader"
) )
@ -77,8 +78,8 @@ func (b *KubeDnsOptionsBuilder) BuildOptions(o interface{}) error {
NodeLocalDNS := clusterSpec.KubeDNS.NodeLocalDNS NodeLocalDNS := clusterSpec.KubeDNS.NodeLocalDNS
if NodeLocalDNS == nil { if NodeLocalDNS == nil {
NodeLocalDNS = &kops.NodeLocalDNSConfig{} NodeLocalDNS = &kops.NodeLocalDNSConfig{}
NodeLocalDNS.Enabled = false NodeLocalDNS.Enabled = fi.Bool(false)
} else if NodeLocalDNS.Enabled && NodeLocalDNS.LocalIP == "" { } else if fi.BoolValue(NodeLocalDNS.Enabled) && NodeLocalDNS.LocalIP == "" {
NodeLocalDNS.LocalIP = "169.254.20.10" NodeLocalDNS.LocalIP = "169.254.20.10"
} }

View File

@ -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 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" key := "nodelocaldns.addons.k8s.io"
version := "1.18.0" version := "1.18.0"