Move UpdatePolicy into NodeConfig

This commit is contained in:
John Gardiner Myers 2021-05-16 13:34:31 -07:00
parent 221f02b1af
commit 14ab4a3453
2 changed files with 14 additions and 20 deletions

View File

@ -49,16 +49,8 @@ func (b *UpdateServiceBuilder) Build(c *fi.ModelBuilderContext) error {
}
func (b *UpdateServiceBuilder) buildFlatcarSystemdService(c *fi.ModelBuilderContext) {
if b.InstanceGroup.Spec.UpdatePolicy != nil {
switch *b.InstanceGroup.Spec.UpdatePolicy {
case kops.UpdatePolicyAutomatic:
klog.Infof("UpdatePolicy set in InstanceGroup %q spec requests automatic updates; skipping creation of systemd unit %q", b.InstanceGroup.GetName(), flatcarServiceName)
return
case kops.UpdatePolicyExternal:
// Carry on with creating this systemd unit.
}
} else if fi.StringValue(b.Cluster.Spec.UpdatePolicy) != kops.UpdatePolicyExternal {
klog.Infof("UpdatePolicy in Cluster spec requests automatic updates; skipping creation of systemd unit %q", flatcarServiceName)
if b.NodeupConfig.UpdatePolicy != kops.UpdatePolicyExternal {
klog.Infof("UpdatePolicy requests automatic updates; skipping creation of systemd unit %q", flatcarServiceName)
return
}
@ -93,16 +85,8 @@ func (b *UpdateServiceBuilder) buildFlatcarSystemdService(c *fi.ModelBuilderCont
}
func (b *UpdateServiceBuilder) buildDebianPackage(c *fi.ModelBuilderContext) {
if b.InstanceGroup.Spec.UpdatePolicy != nil {
switch *b.InstanceGroup.Spec.UpdatePolicy {
case kops.UpdatePolicyAutomatic:
klog.Infof("UpdatePolicy set in InstanceGroup %q spec requests automatic updates; skipping installation of packagk %q", b.InstanceGroup.GetName(), debianPackageName)
return
case kops.UpdatePolicyExternal:
// Carry on with creating this systemd unit.
}
} else if fi.StringValue(b.Cluster.Spec.UpdatePolicy) != kops.UpdatePolicyExternal {
klog.Infof("UpdatePolicy in Cluster spec requests automatic updates; skipping installation of package %q", debianPackageName)
if b.NodeupConfig.UpdatePolicy != kops.UpdatePolicyExternal {
klog.Infof("UpdatePolicy requests automatic updates; skipping installation of package %q", debianPackageName)
return
}

View File

@ -62,6 +62,8 @@ type Config struct {
// specified, each parameter must follow the form variable=value, the way
// it would appear in sysctl.conf.
SysctlParameters []string `json:",omitempty"`
// UpdatePolicy determines the policy for applying upgrades automatically.
UpdatePolicy string
// VolumeMounts are a collection of volume mounts.
VolumeMounts []kops.VolumeMountSpec `json:",omitempty"`
@ -152,6 +154,14 @@ func NewConfig(cluster *kops.Cluster, instanceGroup *kops.InstanceGroup) (*Confi
config.KubeletConfig.Taints = append(config.KubeletConfig.Taints, instanceGroup.Spec.Taints...)
if instanceGroup.Spec.UpdatePolicy != nil {
config.UpdatePolicy = *instanceGroup.Spec.UpdatePolicy
} else if cluster.Spec.UpdatePolicy != nil {
config.UpdatePolicy = *cluster.Spec.UpdatePolicy
} else {
config.UpdatePolicy = kops.UpdatePolicyAutomatic
}
if cluster.Spec.Networking != nil && cluster.Spec.Networking.AmazonVPC != nil {
config.DefaultMachineType = fi.String(strings.Split(instanceGroup.Spec.MachineType, ",")[0])
}