Skip to content

Commit b0f6359

Browse files
committed
feat: set default instance profile for AWS CP and worker nodes
1 parent bce383c commit b0f6359

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

api/v1alpha1/aws_node_types.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import (
1414
const (
1515
AWSControlPlaneInstanceType InstanceType = "m5.xlarge"
1616
AWSWorkerInstanceType InstanceType = "m5.2xlarge"
17+
18+
AWSControlPlaneInstanceProfile IAMInstanceProfile = "control-plane.cluster-api-provider-aws.sigs.k8s.io"
19+
AWSWorkerInstanceProfile IAMInstanceProfile = "nodes.cluster-api-provider-aws.sigs.k8s.io"
1720
)
1821

1922
type AWSNodeSpec struct {
@@ -34,13 +37,15 @@ type AWSNodeSpec struct {
3437

3538
func NewAWSControlPlaneNodeSpec() *AWSNodeSpec {
3639
return &AWSNodeSpec{
37-
InstanceType: ptr.To(AWSControlPlaneInstanceType),
40+
InstanceType: ptr.To(AWSControlPlaneInstanceType),
41+
IAMInstanceProfile: ptr.To(AWSControlPlaneInstanceProfile),
3842
}
3943
}
4044

4145
func NewAWSWorkerNodeSpec() *AWSNodeSpec {
4246
return &AWSNodeSpec{
43-
InstanceType: ptr.To(AWSWorkerInstanceType),
47+
InstanceType: ptr.To(AWSWorkerInstanceType),
48+
IAMInstanceProfile: ptr.To(AWSWorkerInstanceProfile),
4449
}
4550
}
4651

@@ -75,7 +80,7 @@ func (a AWSNodeSpec) VariableSchema() clusterv1.VariableSchema {
7580
Description: "AWS Node configuration",
7681
Type: "object",
7782
Properties: map[string]clusterv1.JSONSchemaProps{
78-
"iamInstanceProfile": IAMInstanceProfile("").VariableSchema().OpenAPIV3Schema,
83+
"iamInstanceProfile": a.IAMInstanceProfile.VariableSchema().OpenAPIV3Schema,
7984
"instanceType": a.InstanceType.VariableSchema().OpenAPIV3Schema,
8085
"ami": AMISpec{}.VariableSchema().OpenAPIV3Schema,
8186
"additionalSecurityGroups": AdditionalSecurityGroup{}.VariableSchema().OpenAPIV3Schema,
@@ -87,11 +92,12 @@ func (a AWSNodeSpec) VariableSchema() clusterv1.VariableSchema {
8792

8893
type IAMInstanceProfile string
8994

90-
func (IAMInstanceProfile) VariableSchema() clusterv1.VariableSchema {
95+
func (i IAMInstanceProfile) VariableSchema() clusterv1.VariableSchema {
9196
return clusterv1.VariableSchema{
9297
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
9398
Type: "string",
9499
Description: "The IAM instance profile to use for the cluster Machines",
100+
Default: variables.MustMarshal(i),
95101
},
96102
}
97103
}

charts/cluster-api-runtime-extensions-nutanix/defaultclusterclasses/aws-cluster-class.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ metadata:
105105
spec:
106106
template:
107107
spec:
108-
iamInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io
109108
instanceType: PLACEHOLDER
110109
sshKeyName: ""
111110
---
@@ -118,7 +117,6 @@ metadata:
118117
spec:
119118
template:
120119
spec:
121-
iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io
122120
instanceType: PLACEHOLDER
123121
sshKeyName: ""
124122
---

hack/examples/overlays/clusterclasses/aws/kustomization.yaml.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,8 @@ patches:
5959
- op: "add"
6060
path: "/spec/template/spec/instanceType"
6161
value: "PLACEHOLDER"
62+
- target:
63+
kind: AWSMachineTemplate
64+
patch: |-
65+
- op: "remove"
66+
path: "/spec/template/spec/iamInstanceProfile"

0 commit comments

Comments
 (0)