...

Source file src/github.com/openshift/api/machine/v1beta1/types_machine.go

Documentation: github.com/openshift/api/machine/v1beta1

     1  package v1beta1
     2  
     3  import (
     4  	corev1 "k8s.io/api/core/v1"
     5  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     6  	"k8s.io/apimachinery/pkg/runtime"
     7  )
     8  
     9  // +genclient
    10  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    11  
    12  const (
    13  	// MachineFinalizer is set on PrepareForCreate callback.
    14  	MachineFinalizer = "machine.machine.openshift.io"
    15  
    16  	// MachineClusterLabelName is the label set on machines linked to a cluster.
    17  	MachineClusterLabelName = "cluster.k8s.io/cluster-name"
    18  
    19  	// MachineClusterIDLabel is the label that a machine must have to identify the
    20  	// cluster to which it belongs.
    21  	MachineClusterIDLabel = "machine.openshift.io/cluster-api-cluster"
    22  )
    23  
    24  type MachineStatusError string
    25  
    26  const (
    27  	// Represents that the combination of configuration in the MachineSpec
    28  	// is not supported by this cluster. This is not a transient error, but
    29  	// indicates a state that must be fixed before progress can be made.
    30  	//
    31  	// Example: the ProviderSpec specifies an instance type that doesn't exist,
    32  	InvalidConfigurationMachineError MachineStatusError = "InvalidConfiguration"
    33  
    34  	// This indicates that the MachineSpec has been updated in a way that
    35  	// is not supported for reconciliation on this cluster. The spec may be
    36  	// completely valid from a configuration standpoint, but the controller
    37  	// does not support changing the real world state to match the new
    38  	// spec.
    39  	//
    40  	// Example: the responsible controller is not capable of changing the
    41  	// container runtime from docker to rkt.
    42  	UnsupportedChangeMachineError MachineStatusError = "UnsupportedChange"
    43  
    44  	// This generally refers to exceeding one's quota in a cloud provider,
    45  	// or running out of physical machines in an on-premise environment.
    46  	InsufficientResourcesMachineError MachineStatusError = "InsufficientResources"
    47  
    48  	// There was an error while trying to create a Node to match this
    49  	// Machine. This may indicate a transient problem that will be fixed
    50  	// automatically with time, such as a service outage, or a terminal
    51  	// error during creation that doesn't match a more specific
    52  	// MachineStatusError value.
    53  	//
    54  	// Example: timeout trying to connect to GCE.
    55  	CreateMachineError MachineStatusError = "CreateError"
    56  
    57  	// There was an error while trying to update a Node that this
    58  	// Machine represents. This may indicate a transient problem that will be
    59  	// fixed automatically with time, such as a service outage,
    60  	//
    61  	// Example: error updating load balancers
    62  	UpdateMachineError MachineStatusError = "UpdateError"
    63  
    64  	// An error was encountered while trying to delete the Node that this
    65  	// Machine represents. This could be a transient or terminal error, but
    66  	// will only be observable if the provider's Machine controller has
    67  	// added a finalizer to the object to more gracefully handle deletions.
    68  	//
    69  	// Example: cannot resolve EC2 IP address.
    70  	DeleteMachineError MachineStatusError = "DeleteError"
    71  
    72  	// TemplateClonedFromGroupKindAnnotation is the infrastructure machine
    73  	// annotation that stores the group-kind of the infrastructure template resource
    74  	// that was cloned for the machine. This annotation is set only during cloning a
    75  	// template. Older/adopted machines will not have this annotation.
    76  	TemplateClonedFromGroupKindAnnotation = "machine.openshift.io/cloned-from-groupkind"
    77  
    78  	// TemplateClonedFromNameAnnotation is the infrastructure machine annotation that
    79  	// stores the name of the infrastructure template resource
    80  	// that was cloned for the machine. This annotation is set only during cloning a
    81  	//  template. Older/adopted machines will not have this annotation.
    82  	TemplateClonedFromNameAnnotation = "machine.openshift.io/cloned-from-name"
    83  
    84  	// This error indicates that the machine did not join the cluster
    85  	// as a new node within the expected timeframe after instance
    86  	// creation at the provider succeeded
    87  	//
    88  	// Example use case: A controller that deletes Machines which do
    89  	// not result in a Node joining the cluster within a given timeout
    90  	// and that are managed by a MachineSet
    91  	JoinClusterTimeoutMachineError = "JoinClusterTimeoutError"
    92  )
    93  
    94  type ClusterStatusError string
    95  
    96  const (
    97  	// InvalidConfigurationClusterError indicates that the cluster
    98  	// configuration is invalid.
    99  	InvalidConfigurationClusterError ClusterStatusError = "InvalidConfiguration"
   100  
   101  	// UnsupportedChangeClusterError indicates that the cluster
   102  	// spec has been updated in an unsupported way. That cannot be
   103  	// reconciled.
   104  	UnsupportedChangeClusterError ClusterStatusError = "UnsupportedChange"
   105  
   106  	// CreateClusterError indicates that an error was encountered
   107  	// when trying to create the cluster.
   108  	CreateClusterError ClusterStatusError = "CreateError"
   109  
   110  	// UpdateClusterError indicates that an error was encountered
   111  	// when trying to update the cluster.
   112  	UpdateClusterError ClusterStatusError = "UpdateError"
   113  
   114  	// DeleteClusterError indicates that an error was encountered
   115  	// when trying to delete the cluster.
   116  	DeleteClusterError ClusterStatusError = "DeleteError"
   117  )
   118  
   119  type MachineSetStatusError string
   120  
   121  const (
   122  	// Represents that the combination of configuration in the MachineTemplateSpec
   123  	// is not supported by this cluster. This is not a transient error, but
   124  	// indicates a state that must be fixed before progress can be made.
   125  	//
   126  	// Example: the ProviderSpec specifies an instance type that doesn't exist.
   127  	InvalidConfigurationMachineSetError MachineSetStatusError = "InvalidConfiguration"
   128  )
   129  
   130  type MachineDeploymentStrategyType string
   131  
   132  const (
   133  	// Replace the old MachineSet by new one using rolling update
   134  	// i.e. gradually scale down the old MachineSet and scale up the new one.
   135  	RollingUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "RollingUpdate"
   136  )
   137  
   138  const (
   139  	// PhaseFailed indicates a state that will need to be fixed before progress can be made.
   140  	// Failed machines have encountered a terminal error and must be deleted.
   141  	// https://github.com/openshift/enhancements/blob/master/enhancements/machine-instance-lifecycle.md
   142  	// e.g. Instance does NOT exist but Machine has providerID/addresses.
   143  	// e.g. Cloud service returns a 4xx response.
   144  	PhaseFailed string = "Failed"
   145  
   146  	// PhaseProvisioning indicates the instance does NOT exist.
   147  	// The machine has NOT been given a providerID or addresses.
   148  	// Provisioning implies that the Machine API is in the process of creating the instance.
   149  	PhaseProvisioning string = "Provisioning"
   150  
   151  	// PhaseProvisioned indicates the instance exists.
   152  	// The machine has been given a providerID and addresses.
   153  	// The machine API successfully provisioned an instance which has not yet joined the cluster,
   154  	// as such, the machine has NOT yet been given a nodeRef.
   155  	PhaseProvisioned string = "Provisioned"
   156  
   157  	// PhaseRunning indicates the instance exists and the node has joined the cluster.
   158  	// The machine has been given a providerID, addresses, and a nodeRef.
   159  	PhaseRunning string = "Running"
   160  
   161  	// PhaseDeleting indicates the machine has a deletion timestamp and that the
   162  	// Machine API is now in the process of removing the machine from the cluster.
   163  	PhaseDeleting string = "Deleting"
   164  )
   165  
   166  // +genclient
   167  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   168  
   169  // Machine is the Schema for the machines API
   170  // +k8s:openapi-gen=true
   171  // +kubebuilder:subresource:status
   172  // +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="Phase of machine"
   173  // +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".metadata.labels['machine\\.openshift\\.io/instance-type']",description="Type of instance"
   174  // +kubebuilder:printcolumn:name="Region",type="string",JSONPath=".metadata.labels['machine\\.openshift\\.io/region']",description="Region associated with machine"
   175  // +kubebuilder:printcolumn:name="Zone",type="string",JSONPath=".metadata.labels['machine\\.openshift\\.io/zone']",description="Zone associated with machine"
   176  // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Machine age"
   177  // +kubebuilder:printcolumn:name="Node",type="string",JSONPath=".status.nodeRef.name",description="Node associated with machine",priority=1
   178  // +kubebuilder:printcolumn:name="ProviderID",type="string",JSONPath=".spec.providerID",description="Provider ID of machine created in cloud provider",priority=1
   179  // +kubebuilder:printcolumn:name="State",type="string",JSONPath=".metadata.annotations['machine\\.openshift\\.io/instance-state']",description="State of instance",priority=1
   180  // Compatibility level 2: Stable within a major release for a minimum of 9 months or 3 minor releases (whichever is longer).
   181  // +openshift:compatibility-gen:level=2
   182  type Machine struct {
   183  	metav1.TypeMeta `json:",inline"`
   184  
   185  	// metadata is the standard object's metadata.
   186  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   187  	metav1.ObjectMeta `json:"metadata,omitempty"`
   188  
   189  	Spec   MachineSpec   `json:"spec,omitempty"`
   190  	Status MachineStatus `json:"status,omitempty"`
   191  }
   192  
   193  // MachineSpec defines the desired state of Machine
   194  type MachineSpec struct {
   195  	// ObjectMeta will autopopulate the Node created. Use this to
   196  	// indicate what labels, annotations, name prefix, etc., should be used
   197  	// when creating the Node.
   198  	// +optional
   199  	ObjectMeta `json:"metadata,omitempty"`
   200  
   201  	// LifecycleHooks allow users to pause operations on the machine at
   202  	// certain predefined points within the machine lifecycle.
   203  	// +optional
   204  	LifecycleHooks LifecycleHooks `json:"lifecycleHooks,omitempty"`
   205  
   206  	// The list of the taints to be applied to the corresponding Node in additive
   207  	// manner. This list will not overwrite any other taints added to the Node on
   208  	// an ongoing basis by other entities. These taints should be actively reconciled
   209  	// e.g. if you ask the machine controller to apply a taint and then manually remove
   210  	// the taint the machine controller will put it back) but not have the machine controller
   211  	// remove any taints
   212  	// +optional
   213  	Taints []corev1.Taint `json:"taints,omitempty"`
   214  
   215  	// ProviderSpec details Provider-specific configuration to use during node creation.
   216  	// +optional
   217  	ProviderSpec ProviderSpec `json:"providerSpec"`
   218  
   219  	// ProviderID is the identification ID of the machine provided by the provider.
   220  	// This field must match the provider ID as seen on the node object corresponding to this machine.
   221  	// This field is required by higher level consumers of cluster-api. Example use case is cluster autoscaler
   222  	// with cluster-api as provider. Clean-up logic in the autoscaler compares machines to nodes to find out
   223  	// machines at provider which could not get registered as Kubernetes nodes. With cluster-api as a
   224  	// generic out-of-tree provider for autoscaler, this field is required by autoscaler to be
   225  	// able to have a provider view of the list of machines. Another list of nodes is queried from the k8s apiserver
   226  	// and then a comparison is done to find out unregistered machines and are marked for delete.
   227  	// This field will be set by the actuators and consumed by higher level entities like autoscaler that will
   228  	// be interfacing with cluster-api as generic provider.
   229  	// +optional
   230  	ProviderID *string `json:"providerID,omitempty"`
   231  }
   232  
   233  // LifecycleHooks allow users to pause operations on the machine at
   234  // certain prefedined points within the machine lifecycle.
   235  type LifecycleHooks struct {
   236  	// PreDrain hooks prevent the machine from being drained.
   237  	// This also blocks further lifecycle events, such as termination.
   238  	// +listType=map
   239  	// +listMapKey=name
   240  	// +optional
   241  	PreDrain []LifecycleHook `json:"preDrain,omitempty"`
   242  
   243  	// PreTerminate hooks prevent the machine from being terminated.
   244  	// PreTerminate hooks be actioned after the Machine has been drained.
   245  	// +listType=map
   246  	// +listMapKey=name
   247  	// +optional
   248  	PreTerminate []LifecycleHook `json:"preTerminate,omitempty"`
   249  }
   250  
   251  // LifecycleHook represents a single instance of a lifecycle hook
   252  type LifecycleHook struct {
   253  	// Name defines a unique name for the lifcycle hook.
   254  	// The name should be unique and descriptive, ideally 1-3 words, in CamelCase or
   255  	// it may be namespaced, eg. foo.example.com/CamelCase.
   256  	// Names must be unique and should only be managed by a single entity.
   257  	// +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$`
   258  	// +kubebuilder:validation:MinLength:=3
   259  	// +kubebuilder:validation:MaxLength:=256
   260  	// +kubebuilder:validation:Required
   261  	Name string `json:"name"`
   262  
   263  	// Owner defines the owner of the lifecycle hook.
   264  	// This should be descriptive enough so that users can identify
   265  	// who/what is responsible for blocking the lifecycle.
   266  	// This could be the name of a controller (e.g. clusteroperator/etcd)
   267  	// or an administrator managing the hook.
   268  	// +kubebuilder:validation:MinLength:=3
   269  	// +kubebuilder:validation:MaxLength:=512
   270  	// +kubebuilder:validation:Required
   271  	Owner string `json:"owner"`
   272  }
   273  
   274  // MachineStatus defines the observed state of Machine
   275  type MachineStatus struct {
   276  	// NodeRef will point to the corresponding Node if it exists.
   277  	// +optional
   278  	NodeRef *corev1.ObjectReference `json:"nodeRef,omitempty"`
   279  
   280  	// LastUpdated identifies when this status was last observed.
   281  	// +optional
   282  	LastUpdated *metav1.Time `json:"lastUpdated,omitempty"`
   283  
   284  	// ErrorReason will be set in the event that there is a terminal problem
   285  	// reconciling the Machine and will contain a succinct value suitable
   286  	// for machine interpretation.
   287  	//
   288  	// This field should not be set for transitive errors that a controller
   289  	// faces that are expected to be fixed automatically over
   290  	// time (like service outages), but instead indicate that something is
   291  	// fundamentally wrong with the Machine's spec or the configuration of
   292  	// the controller, and that manual intervention is required. Examples
   293  	// of terminal errors would be invalid combinations of settings in the
   294  	// spec, values that are unsupported by the controller, or the
   295  	// responsible controller itself being critically misconfigured.
   296  	//
   297  	// Any transient errors that occur during the reconciliation of Machines
   298  	// can be added as events to the Machine object and/or logged in the
   299  	// controller's output.
   300  	// +optional
   301  	ErrorReason *MachineStatusError `json:"errorReason,omitempty"`
   302  
   303  	// ErrorMessage will be set in the event that there is a terminal problem
   304  	// reconciling the Machine and will contain a more verbose string suitable
   305  	// for logging and human consumption.
   306  	//
   307  	// This field should not be set for transitive errors that a controller
   308  	// faces that are expected to be fixed automatically over
   309  	// time (like service outages), but instead indicate that something is
   310  	// fundamentally wrong with the Machine's spec or the configuration of
   311  	// the controller, and that manual intervention is required. Examples
   312  	// of terminal errors would be invalid combinations of settings in the
   313  	// spec, values that are unsupported by the controller, or the
   314  	// responsible controller itself being critically misconfigured.
   315  	//
   316  	// Any transient errors that occur during the reconciliation of Machines
   317  	// can be added as events to the Machine object and/or logged in the
   318  	// controller's output.
   319  	// +optional
   320  	ErrorMessage *string `json:"errorMessage,omitempty"`
   321  
   322  	// ProviderStatus details a Provider-specific status.
   323  	// It is recommended that providers maintain their
   324  	// own versioned API types that should be
   325  	// serialized/deserialized from this field.
   326  	// +optional
   327  	// +kubebuilder:validation:XPreserveUnknownFields
   328  	ProviderStatus *runtime.RawExtension `json:"providerStatus,omitempty"`
   329  
   330  	// Addresses is a list of addresses assigned to the machine. Queried from cloud provider, if available.
   331  	// +optional
   332  	Addresses []corev1.NodeAddress `json:"addresses,omitempty"`
   333  
   334  	// LastOperation describes the last-operation performed by the machine-controller.
   335  	// This API should be useful as a history in terms of the latest operation performed on the
   336  	// specific machine. It should also convey the state of the latest-operation for example if
   337  	// it is still on-going, failed or completed successfully.
   338  	// +optional
   339  	LastOperation *LastOperation `json:"lastOperation,omitempty"`
   340  
   341  	// Phase represents the current phase of machine actuation.
   342  	// One of: Failed, Provisioning, Provisioned, Running, Deleting
   343  	// +optional
   344  	Phase *string `json:"phase,omitempty"`
   345  
   346  	// Conditions defines the current state of the Machine
   347  	Conditions Conditions `json:"conditions,omitempty"`
   348  }
   349  
   350  // LastOperation represents the detail of the last performed operation on the MachineObject.
   351  type LastOperation struct {
   352  	// Description is the human-readable description of the last operation.
   353  	Description *string `json:"description,omitempty"`
   354  
   355  	// LastUpdated is the timestamp at which LastOperation API was last-updated.
   356  	LastUpdated *metav1.Time `json:"lastUpdated,omitempty"`
   357  
   358  	// State is the current status of the last performed operation.
   359  	// E.g. Processing, Failed, Successful etc
   360  	State *string `json:"state,omitempty"`
   361  
   362  	// Type is the type of operation which was last performed.
   363  	// E.g. Create, Delete, Update etc
   364  	Type *string `json:"type,omitempty"`
   365  }
   366  
   367  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   368  
   369  // MachineList contains a list of Machine
   370  // Compatibility level 2: Stable within a major release for a minimum of 9 months or 3 minor releases (whichever is longer).
   371  // +openshift:compatibility-gen:level=2
   372  type MachineList struct {
   373  	metav1.TypeMeta `json:",inline"`
   374  
   375  	// metadata is the standard list's metadata.
   376  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   377  	metav1.ListMeta `json:"metadata,omitempty"`
   378  
   379  	Items []Machine `json:"items"`
   380  }
   381  

View as plain text