mirror of https://github.com/kubernetes/kops.git
Use enums for needsRollingUpdate in the channels API
This commit is contained in:
parent
d9e2490439
commit
43be10020c
|
|
@ -35,6 +35,14 @@ type AddonsSpec struct {
|
||||||
Addons []*AddonSpec `json:"addons,omitempty"`
|
Addons []*AddonSpec `json:"addons,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NeedsRollingUpdate string
|
||||||
|
|
||||||
|
const (
|
||||||
|
NeedsRollingUpdateControlPlane NeedsRollingUpdate = "control-plane"
|
||||||
|
NeedsRollingUpdateWorkers NeedsRollingUpdate = "workers"
|
||||||
|
NeedsRollingUpdateAll NeedsRollingUpdate = "all"
|
||||||
|
)
|
||||||
|
|
||||||
type AddonSpec struct {
|
type AddonSpec struct {
|
||||||
Name *string `json:"name,omitempty"`
|
Name *string `json:"name,omitempty"`
|
||||||
|
|
||||||
|
|
@ -63,7 +71,7 @@ type AddonSpec struct {
|
||||||
// NeedsRollingUpdate determines if we should mark nodes as needing an update.
|
// NeedsRollingUpdate determines if we should mark nodes as needing an update.
|
||||||
// Legal values are control-plane, workers, and all
|
// Legal values are control-plane, workers, and all
|
||||||
// Empty value means no update needed
|
// Empty value means no update needed
|
||||||
NeedsRollingUpdate string `json:"needsRollingUpdate,omitempty"`
|
NeedsRollingUpdate NeedsRollingUpdate `json:"needsRollingUpdate,omitempty"`
|
||||||
|
|
||||||
// NeedsPKI determines if channels should provision a CA and a cert-manager issuer for the addon.
|
// NeedsPKI determines if channels should provision a CA and a cert-manager issuer for the addon.
|
||||||
NeedsPKI bool `json:"needsPKI,omitempty"`
|
NeedsPKI bool `json:"needsPKI,omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -233,9 +233,9 @@ func (a *Addon) patchNeedsUpdateLabel(ctx context.Context, k8sClient kubernetes.
|
||||||
klog.Infof("addon %v wants to update %v nodes", a.Name, a.Spec.NeedsRollingUpdate)
|
klog.Infof("addon %v wants to update %v nodes", a.Name, a.Spec.NeedsRollingUpdate)
|
||||||
selector := ""
|
selector := ""
|
||||||
switch a.Spec.NeedsRollingUpdate {
|
switch a.Spec.NeedsRollingUpdate {
|
||||||
case "control-plane":
|
case api.NeedsRollingUpdateControlPlane:
|
||||||
selector = "node-role.kubernetes.io/master="
|
selector = "node-role.kubernetes.io/master="
|
||||||
case "worker":
|
case api.NeedsRollingUpdateWorkers:
|
||||||
selector = "node-role.kubernetes.io/node="
|
selector = "node-role.kubernetes.io/node="
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ func Test_NeedsRollingUpdate(t *testing.T) {
|
||||||
Spec: &api.AddonSpec{
|
Spec: &api.AddonSpec{
|
||||||
Name: fi.PtrTo("test"),
|
Name: fi.PtrTo("test"),
|
||||||
ManifestHash: "originalHash",
|
ManifestHash: "originalHash",
|
||||||
NeedsRollingUpdate: "all",
|
NeedsRollingUpdate: api.NeedsRollingUpdateAll,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -185,7 +185,7 @@ func Test_NeedsRollingUpdate(t *testing.T) {
|
||||||
Spec: &api.AddonSpec{
|
Spec: &api.AddonSpec{
|
||||||
Name: fi.PtrTo("test"),
|
Name: fi.PtrTo("test"),
|
||||||
ManifestHash: "newHash",
|
ManifestHash: "newHash",
|
||||||
NeedsRollingUpdate: "all",
|
NeedsRollingUpdate: api.NeedsRollingUpdateAll,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
updateRequired: true,
|
updateRequired: true,
|
||||||
|
|
@ -197,7 +197,7 @@ func Test_NeedsRollingUpdate(t *testing.T) {
|
||||||
Spec: &api.AddonSpec{
|
Spec: &api.AddonSpec{
|
||||||
Name: fi.PtrTo("test"),
|
Name: fi.PtrTo("test"),
|
||||||
ManifestHash: "newHash",
|
ManifestHash: "newHash",
|
||||||
NeedsRollingUpdate: "worker",
|
NeedsRollingUpdate: api.NeedsRollingUpdateWorkers,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
updateRequired: true,
|
updateRequired: true,
|
||||||
|
|
@ -209,7 +209,7 @@ func Test_NeedsRollingUpdate(t *testing.T) {
|
||||||
Spec: &api.AddonSpec{
|
Spec: &api.AddonSpec{
|
||||||
Name: fi.PtrTo("test"),
|
Name: fi.PtrTo("test"),
|
||||||
ManifestHash: "newHash",
|
ManifestHash: "newHash",
|
||||||
NeedsRollingUpdate: "control-plane",
|
NeedsRollingUpdate: api.NeedsRollingUpdateControlPlane,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
updateRequired: true,
|
updateRequired: true,
|
||||||
|
|
@ -221,7 +221,7 @@ func Test_NeedsRollingUpdate(t *testing.T) {
|
||||||
Spec: &api.AddonSpec{
|
Spec: &api.AddonSpec{
|
||||||
Name: fi.PtrTo("test"),
|
Name: fi.PtrTo("test"),
|
||||||
ManifestHash: "newHash",
|
ManifestHash: "newHash",
|
||||||
NeedsRollingUpdate: "all",
|
NeedsRollingUpdate: api.NeedsRollingUpdateAll,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
originalAnnotations: map[string]string{
|
originalAnnotations: map[string]string{
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext)
|
||||||
Name: fi.PtrTo(key),
|
Name: fi.PtrTo(key),
|
||||||
Selector: map[string]string{"k8s-addon": key},
|
Selector: map[string]string{"k8s-addon": key},
|
||||||
Manifest: fi.PtrTo(location),
|
Manifest: fi.PtrTo(location),
|
||||||
NeedsRollingUpdate: "control-plane",
|
NeedsRollingUpdate: channelsapi.NeedsRollingUpdateControlPlane,
|
||||||
Id: id,
|
Id: id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -1057,7 +1057,7 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext)
|
||||||
Selector: networkingSelector(),
|
Selector: networkingSelector(),
|
||||||
Manifest: fi.PtrTo(location),
|
Manifest: fi.PtrTo(location),
|
||||||
Id: id,
|
Id: id,
|
||||||
NeedsRollingUpdate: "all",
|
NeedsRollingUpdate: channelsapi.NeedsRollingUpdateAll,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ func addCiliumAddon(b *BootstrapChannelBuilder, addons *AddonList) error {
|
||||||
Selector: networkingSelector(),
|
Selector: networkingSelector(),
|
||||||
Manifest: fi.PtrTo(location),
|
Manifest: fi.PtrTo(location),
|
||||||
Id: id,
|
Id: id,
|
||||||
NeedsRollingUpdate: "all",
|
NeedsRollingUpdate: api.NeedsRollingUpdateAll,
|
||||||
}
|
}
|
||||||
if cilium.Hubble != nil && fi.ValueOf(cilium.Hubble.Enabled) {
|
if cilium.Hubble != nil && fi.ValueOf(cilium.Hubble.Enabled) {
|
||||||
addon.NeedsPKI = true
|
addon.NeedsPKI = true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue