Skip to content

Commit f83d0dd

Browse files
committed
cloudprovider/clusterapi: copy cluster-api v1alpha types
These are copied to facilitate testing. They are not meant to reflect upstream clusterapi/v1alpha1 - in fact, fields have been removed. They are here to support the switch to unstructured types in the tests without having to rewrite all of the unit tests.
1 parent 46bb9b4 commit f83d0dd

File tree

4 files changed

+561
-0
lines changed

4 files changed

+561
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// MachineDeploymentSpec is the internal autoscaler Schema for MachineDeploymentSpec
24+
type MachineDeploymentSpec struct {
25+
// Number of desired machines. Defaults to 1.
26+
// This is a pointer to distinguish between explicit zero and not specified.
27+
Replicas *int32 `json:"replicas,omitempty"`
28+
29+
// Label selector for machines. Existing MachineSets whose machines are
30+
// selected by this will be the ones affected by this deployment.
31+
// It must match the machine template's labels.
32+
Selector metav1.LabelSelector `json:"selector"`
33+
34+
// Template describes the machines that will be created.
35+
Template MachineTemplateSpec `json:"template"`
36+
}
37+
38+
// MachineDeploymentStatus is the internal autoscaler Schema for MachineDeploymentStatus
39+
type MachineDeploymentStatus struct{}
40+
41+
// MachineDeployment is the internal autoscaler Schema for MachineDeployment
42+
type MachineDeployment struct {
43+
metav1.TypeMeta `json:",inline"`
44+
metav1.ObjectMeta `json:"metadata,omitempty"`
45+
46+
Spec MachineDeploymentSpec `json:"spec,omitempty"`
47+
Status MachineDeploymentStatus `json:"status,omitempty"`
48+
}
49+
50+
// MachineDeploymentList is the internal autoscaler Schema for MachineDeploymentList
51+
type MachineDeploymentList struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ListMeta `json:"metadata,omitempty"`
54+
Items []MachineDeployment `json:"items"`
55+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// MachineSet is the internal autoscaler Schema for machineSets
24+
type MachineSet struct {
25+
metav1.TypeMeta `json:",inline"`
26+
metav1.ObjectMeta `json:"metadata,omitempty"`
27+
28+
Spec MachineSetSpec `json:"spec,omitempty"`
29+
Status MachineSetStatus `json:"status,omitempty"`
30+
}
31+
32+
// MachineSetSpec is the internal autoscaler Schema for MachineSetSpec
33+
type MachineSetSpec struct {
34+
// Replicas is the number of desired replicas.
35+
// This is a pointer to distinguish between explicit zero and unspecified.
36+
// Defaults to 1.
37+
// +optional
38+
Replicas *int32 `json:"replicas,omitempty"`
39+
40+
// MinReadySeconds is the minimum number of seconds for which a newly created machine should be ready.
41+
// Defaults to 0 (machine will be considered available as soon as it is ready)
42+
// +optional
43+
MinReadySeconds int32 `json:"minReadySeconds,omitempty"`
44+
45+
// Selector is a label query over machines that should match the replica count.
46+
// Label keys and values that must match in order to be controlled by this MachineSet.
47+
// It must match the machine template's labels.
48+
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
49+
Selector metav1.LabelSelector `json:"selector"`
50+
51+
// Template is the object that describes the machine that will be created if
52+
// insufficient replicas are detected.
53+
// +optional
54+
Template MachineTemplateSpec `json:"template,omitempty"`
55+
}
56+
57+
// MachineTemplateSpec is the internal autoscaler Schema for MachineTemplateSpec
58+
type MachineTemplateSpec struct {
59+
// Standard object's metadata.
60+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
61+
// +optional
62+
metav1.ObjectMeta `json:"metadata,omitempty"`
63+
64+
// Specification of the desired behavior of the machine.
65+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
66+
// +optional
67+
Spec MachineSpec `json:"spec,omitempty"`
68+
}
69+
70+
// MachineSetStatus is the internal autoscaler Schema for MachineSetStatus
71+
type MachineSetStatus struct{}
72+
73+
// MachineSetList is the internal autoscaler Schema for MachineSetList
74+
type MachineSetList struct {
75+
metav1.TypeMeta `json:",inline"`
76+
metav1.ListMeta `json:"metadata,omitempty"`
77+
Items []MachineSet `json:"items"`
78+
}

0 commit comments

Comments
 (0)