3
3
4
4
package v1alpha1
5
5
6
- import (
7
- v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
8
- "k8s.io/utils/ptr"
9
- clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
6
+ const (
7
+ AWSControlPlaneInstanceType = "m5.xlarge"
8
+ AWSWorkerInstanceType = "m5.2xlarge"
10
9
11
- "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables"
10
+ AWSControlPlaneInstanceProfile = "control-plane.cluster-api-provider-aws.sigs.k8s.io"
11
+ AWSWorkerInstanceProfile = "nodes.cluster-api-provider-aws.sigs.k8s.io"
12
12
)
13
13
14
- const (
15
- AWSControlPlaneInstanceType InstanceType = "m5.xlarge"
16
- AWSWorkerInstanceType InstanceType = "m5.2xlarge"
14
+ type AWSControlPlaneNodeSpec struct {
15
+ // The IAM instance profile to use for the cluster Machines.
16
+ // +kubebuilder:default=control-plane.cluster-api-provider-aws.sigs.k8s.io
17
+ // +optional
18
+ IAMInstanceProfile string `json:"iamInstanceProfile,omitempty"`
17
19
18
- AWSControlPlaneInstanceProfile IAMInstanceProfile = "control-plane.cluster-api-provider-aws.sigs.k8s.io"
19
- AWSWorkerInstanceProfile IAMInstanceProfile = "nodes.cluster-api-provider-aws.sigs.k8s.io"
20
- )
20
+ // +kubebuilder:default=m5.xlarge
21
+ // +optional
22
+ InstanceType string `json:"instanceType,omitempty"`
23
+
24
+ AWSGenericNodeSpec `json:",inline"`
25
+ }
21
26
22
- type AWSNodeSpec struct {
27
+ type AWSWorkerNodeSpec struct {
28
+ // The IAM instance profile to use for the cluster Machines.
29
+ // +kubebuilder:default=nodes.cluster-api-provider-aws.sigs.k8s.io
23
30
// +optional
24
- IAMInstanceProfile * IAMInstanceProfile `json:"iamInstanceProfile,omitempty"`
31
+ IAMInstanceProfile string `json:"iamInstanceProfile,omitempty"`
25
32
33
+ // The AWS instance type to use for the cluster Machines.
34
+ // +kubebuilder:default=m5.2xlarge
26
35
// +optional
27
- InstanceType * InstanceType `json:"instanceType,omitempty"`
36
+ InstanceType string `json:"instanceType,omitempty"`
28
37
38
+ AWSGenericNodeSpec `json:",inline"`
39
+ }
40
+
41
+ type AWSGenericNodeSpec struct {
29
42
// AMI or AMI Lookup arguments for machine image of a AWS machine.
30
43
// If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence
31
44
//+optional
@@ -35,87 +48,16 @@ type AWSNodeSpec struct {
35
48
AdditionalSecurityGroups AdditionalSecurityGroup `json:"additionalSecurityGroups,omitempty"`
36
49
}
37
50
38
- func NewAWSControlPlaneNodeSpec () * AWSNodeSpec {
39
- return & AWSNodeSpec {
40
- InstanceType : ptr .To (AWSControlPlaneInstanceType ),
41
- IAMInstanceProfile : ptr .To (AWSControlPlaneInstanceProfile ),
42
- }
43
- }
44
-
45
- func NewAWSWorkerNodeSpec () * AWSNodeSpec {
46
- return & AWSNodeSpec {
47
- InstanceType : ptr .To (AWSWorkerInstanceType ),
48
- IAMInstanceProfile : ptr .To (AWSWorkerInstanceProfile ),
49
- }
50
- }
51
-
52
51
type AdditionalSecurityGroup []SecurityGroup
53
52
54
53
type SecurityGroup struct {
55
54
// ID is the id of the security group
56
55
// +optional
57
- ID * string `json:"id,omitempty"`
58
- }
59
-
60
- func (AdditionalSecurityGroup ) VariableSchema () clusterv1.VariableSchema {
61
- return clusterv1.VariableSchema {
62
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
63
- Type : "array" ,
64
- Items : & clusterv1.JSONSchemaProps {
65
- Type : "object" ,
66
- Properties : map [string ]clusterv1.JSONSchemaProps {
67
- "id" : {
68
- Type : "string" ,
69
- Description : "Security group ID to add for the cluster Machines" ,
70
- },
71
- },
72
- },
73
- },
74
- }
75
- }
76
-
77
- func (a AWSNodeSpec ) VariableSchema () clusterv1.VariableSchema {
78
- return clusterv1.VariableSchema {
79
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
80
- Description : "AWS Node configuration" ,
81
- Type : "object" ,
82
- Properties : map [string ]clusterv1.JSONSchemaProps {
83
- "iamInstanceProfile" : a .IAMInstanceProfile .VariableSchema ().OpenAPIV3Schema ,
84
- "instanceType" : a .InstanceType .VariableSchema ().OpenAPIV3Schema ,
85
- "ami" : AMISpec {}.VariableSchema ().OpenAPIV3Schema ,
86
- "additionalSecurityGroups" : AdditionalSecurityGroup {}.VariableSchema ().OpenAPIV3Schema ,
87
- },
88
- Required : []string {"instanceType" },
89
- },
90
- }
91
- }
92
-
93
- type IAMInstanceProfile string
94
-
95
- func (i IAMInstanceProfile ) VariableSchema () clusterv1.VariableSchema {
96
- return clusterv1.VariableSchema {
97
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
98
- Type : "string" ,
99
- Description : "The IAM instance profile to use for the cluster Machines" ,
100
- Default : variables .MustMarshal (i ),
101
- },
102
- }
103
- }
104
-
105
- type InstanceType string
106
-
107
- func (i InstanceType ) VariableSchema () clusterv1.VariableSchema {
108
- return clusterv1.VariableSchema {
109
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
110
- Type : "string" ,
111
- Description : "The AWS instance type to use for the cluster Machines" ,
112
- Default : variables .MustMarshal (i ),
113
- },
114
- }
56
+ ID string `json:"id,omitempty"`
115
57
}
116
58
117
59
type AMISpec struct {
118
- // ID is an explicit AMI to use .
60
+ // AMI ID is the reference to the AMI from which to create the machine instance .
119
61
// +optional
120
62
ID string `json:"id,omitempty"`
121
63
@@ -124,58 +66,18 @@ type AMISpec struct {
124
66
Lookup * AMILookup `json:"lookup,omitempty"`
125
67
}
126
68
127
- func (AMISpec ) VariableSchema () clusterv1.VariableSchema {
128
- return clusterv1.VariableSchema {
129
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
130
- Type : "object" ,
131
- Default : & v1.JSON {},
132
- Description : "AMI or AMI Lookup arguments for machine image of a AWS machine." +
133
- "If both AMI ID and AMI lookup arguments are provided then AMI ID takes precedence" ,
134
- Properties : map [string ]clusterv1.JSONSchemaProps {
135
- "id" : {
136
- Type : "string" ,
137
- Description : "AMI ID is the reference to the AMI from which to create the machine instance." ,
138
- },
139
- "lookup" : AMILookup {}.VariableSchema ().OpenAPIV3Schema ,
140
- },
141
- },
142
- }
143
- }
144
-
145
69
type AMILookup struct {
146
- // Format is the AMI naming format
70
+ // AMI naming format. Supports substitutions for {{.BaseOS}} and {{.K8sVersion}} with the
71
+ // base OS and kubernetes version.
72
+ // +kubebuilder:example=`capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*`
147
73
// +optional
148
74
Format string `json:"format,omitempty"`
149
75
150
- // Org is the AWS Organization ID to use for image lookup
76
+ // The AWS Organization ID to use for image lookup.
151
77
// +optional
152
78
Org string `json:"org,omitempty"`
153
79
154
- // BaseOS is the name of the base os for image lookup
80
+ // The name of the base os for image lookup
155
81
// +optional
156
82
BaseOS string `json:"baseOS,omitempty"`
157
83
}
158
-
159
- func (AMILookup ) VariableSchema () clusterv1.VariableSchema {
160
- return clusterv1.VariableSchema {
161
- OpenAPIV3Schema : clusterv1.JSONSchemaProps {
162
- Type : "object" ,
163
- Default : & v1.JSON {},
164
- Properties : map [string ]clusterv1.JSONSchemaProps {
165
- "format" : {
166
- Type : "string" ,
167
- Description : "AMI naming format. Supports substitutions for {{.BaseOS}} and {{.K8sVersion}} with the" +
168
- "base OS and kubernetes version. example: capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-*" ,
169
- },
170
- "org" : {
171
- Type : "string" ,
172
- Description : "The AWS Organization ID to use for image lookup" ,
173
- },
174
- "baseOS" : {
175
- Type : "string" ,
176
- Description : "The name of the base os for image lookup" ,
177
- },
178
- },
179
- },
180
- }
181
- }
0 commit comments