|
| 1 | +/* |
| 2 | +Copyright 2020 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package clusterapi |
| 18 | + |
| 19 | +import ( |
| 20 | + corev1 "k8s.io/api/core/v1" |
| 21 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 | +) |
| 23 | + |
| 24 | +// Machine is the Schema for the machines API |
| 25 | +type Machine struct { |
| 26 | + metav1.TypeMeta `json:",inline"` |
| 27 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 28 | + |
| 29 | + Spec MachineSpec `json:"spec,omitempty"` |
| 30 | + Status MachineStatus `json:"status,omitempty"` |
| 31 | +} |
| 32 | + |
| 33 | +// MachineSpec defines the desired state of Machine |
| 34 | +type MachineSpec struct { |
| 35 | + // ObjectMeta will autopopulate the Node created. Use this to |
| 36 | + // indicate what labels, annotations, name prefix, etc., should be used |
| 37 | + // when creating the Node. |
| 38 | + // +optional |
| 39 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 40 | + |
| 41 | + // Taints is the full, authoritative list of taints to apply to the corresponding |
| 42 | + // Node. This list will overwrite any modifications made to the Node on |
| 43 | + // an ongoing basis. |
| 44 | + // +optional |
| 45 | + Taints []corev1.Taint `json:"taints,omitempty"` |
| 46 | + |
| 47 | + // ProviderID is the identification ID of the machine provided by the provider. |
| 48 | + // This field must match the provider ID as seen on the node object corresponding to this machine. |
| 49 | + // This field is required by higher level consumers of cluster-api. Example use case is cluster autoscaler |
| 50 | + // with cluster-api as provider. Clean-up login in the autoscaler compares machines v/s nodes to find out |
| 51 | + // machines at provider which could not get registered as Kubernetes nodes. With cluster-api as a |
| 52 | + // generic out-of-tree provider for autoscaler, this field is required by autoscaler to be |
| 53 | + // able to have a provider view of the list of machines. Another list of nodes is queries from the k8s apiserver |
| 54 | + // and then comparison is done to find out unregistered machines and are marked for delete. |
| 55 | + // This field will be set by the actuators and consumed by higher level entities like autoscaler who will |
| 56 | + // be interfacing with cluster-api as generic provider. |
| 57 | + // +optional |
| 58 | + ProviderID *string `json:"providerID,omitempty"` |
| 59 | +} |
| 60 | + |
| 61 | +// MachineStatus defines the observed state of Machine |
| 62 | +type MachineStatus struct { |
| 63 | + // NodeRef will point to the corresponding Node if it exists. |
| 64 | + // +optional |
| 65 | + NodeRef *corev1.ObjectReference `json:"nodeRef,omitempty"` |
| 66 | +} |
| 67 | + |
| 68 | +// MachineList contains a list of Machine |
| 69 | +type MachineList struct { |
| 70 | + metav1.TypeMeta `json:",inline"` |
| 71 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 72 | + Items []Machine `json:"items"` |
| 73 | +} |
0 commit comments