Skip to content

Set interruptible label to nodes #3504

@alexander-demicev

Description

@alexander-demicev

User Story

As a user, I would like to have a "cluster.x-k8s.io/interruptible" label on Nodes that run on interruptible instances(see https://github.com/kubernetes-sigs/cluster-api/blob/master/docs/proposals/20200330-spot-instances.md).

Detailed Description

Having "cluster.x-k8s.io/interruptible" label on Nodes that run on interruptible instances should help us with implementing a termination handler(see #3528). We'll be able to create a DaemonSet that runs a termination handler on each node.

Based on the discussion here #3668. @ncdc's suggestion(1, 2) is:

  1. User creates InfraMachine with whatever spec field(s) are required for that provider to indicate it's interruptible
  2. Infra provider sets InfraMachine.status.interruptible=true
  3. Machine looks at the infra machine's status (for interruptible) and adds a label to the node.
  4. Machine controller ensures the interruptible label is always present on the Node if Machine.status.interruptible is true

The following snippet should work:

// Get and set the failure domain from the infrastructure provider.
var interruptible bool
err = util.UnstructuredUnmarshalField(infraConfig, &interruptible, "status", "interruptible")
switch {
case err == util.ErrUnstructuredFieldNotFound: // no-op
case err != nil:
	return errors.Wrapf(err, "failed to get interruptible status from infrastructure provider for Machine %q in namespace %q", m.Name, m.Namespace)
}

if !interruptible {
	return nil
}

// Here goes logic for assigning a label to node

/kind feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/designCategorizes issue or PR as related to design.kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions