Skip to content

Commit 5476467

Browse files
authored
Add controller to create nodepool bootstrap data on S3 (#239)
1 parent df368a4 commit 5476467

40 files changed

+1934
-345
lines changed

.circleci/config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ workflows:
9090
requires:
9191
- go-build
9292
- unit-tests
93-
- integration-tests
94-
- acceptance-tests
9593
filters:
9694
# Trigger the job also on git tag.
9795
tags:

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# Ignore build and test binaries.
33
bin/
44
testbin/
5+
aws-resolver-rules-operator-test-secrets.sh

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ Dockerfile.cross
2424
*.swp
2525
*.swo
2626
*~
27+
28+
aws-resolver-rules-operator-test-secrets.sh

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add controller to create node pool bootstrap data on S3.
13+
1014
### Changed
1115

1216
- Dynamically calculate CAPI and CAPA versions from go cache, so that we use the right path when installing the CRDs during tests.

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RUN go mod download
1313

1414
# Copy the go source
1515
COPY main.go main.go
16+
COPY api/ api/
1617
COPY controllers/ controllers/
1718
COPY pkg/ pkg/
1819

Makefile.custom.mk

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ MANAGEMENT_CLUSTER_NAMESPACE ?= $(eval MANAGEMENT_CLUSTER_NAMESPACE := $$(shell
1717

1818
DOCKER_COMPOSE = bin/docker-compose
1919

20+
.PHONY: crds
21+
crds: controller-gen ## Generate CustomResourceDefinition.
22+
$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=config/crd/bases
23+
cp config/crd/bases/* helm/aws-resolver-rules-operator/templates/
24+
2025
.PHONY: generate
21-
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
26+
generate: controller-gen crds ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
2227
go generate ./...
2328
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
2429

api/v1alpha1/groupversion_info.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2025.
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 v1alpha1 contains API Schema definitions for the infrastructure v1alpha1 API group.
18+
// +kubebuilder:object:generate=true
19+
// +groupName=infrastructure.cluster.x-k8s.io
20+
package v1alpha1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects.
29+
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
Copyright 2025.
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 v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// KarpenterMachinePoolSpec defines the desired state of KarpenterMachinePool.
24+
type KarpenterMachinePoolSpec struct {
25+
// The name or the Amazon Resource Name (ARN) of the instance profile associated
26+
// with the IAM role for the instance. The instance profile contains the IAM
27+
// role.
28+
IamInstanceProfile string `json:"iamInstanceProfile,omitempty"`
29+
// ProviderIDList are the identification IDs of machine instances provided by the provider.
30+
// This field must match the provider IDs as seen on the node objects corresponding to a machine pool's machine instances.
31+
// +optional
32+
ProviderIDList []string `json:"providerIDList,omitempty"`
33+
}
34+
35+
// KarpenterMachinePoolStatus defines the observed state of KarpenterMachinePool.
36+
type KarpenterMachinePoolStatus struct {
37+
// Ready is true when the provider resource is ready.
38+
// +optional
39+
Ready bool `json:"ready"`
40+
41+
// Replicas is the most recently observed number of replicas
42+
// +optional
43+
Replicas int32 `json:"replicas"`
44+
}
45+
46+
// +kubebuilder:object:root=true
47+
// +kubebuilder:subresource:status
48+
// +kubebuilder:metadata:annotations="helm.sh/resource-policy=keep"
49+
// https://release-1-2.cluster-api.sigs.k8s.io/developer/providers/contracts#api-version-labels
50+
// +kubebuilder:metadata:labels="cluster.x-k8s.io/v1beta1=v1alpha1"
51+
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
52+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
53+
54+
// KarpenterMachinePool is the Schema for the karpentermachinepools API.
55+
type KarpenterMachinePool struct {
56+
metav1.TypeMeta `json:",inline"`
57+
metav1.ObjectMeta `json:"metadata,omitempty"`
58+
59+
Spec KarpenterMachinePoolSpec `json:"spec,omitempty"`
60+
Status KarpenterMachinePoolStatus `json:"status,omitempty"`
61+
}
62+
63+
// +kubebuilder:object:root=true
64+
65+
// KarpenterMachinePoolList contains a list of KarpenterMachinePool.
66+
type KarpenterMachinePoolList struct {
67+
metav1.TypeMeta `json:",inline"`
68+
metav1.ListMeta `json:"metadata,omitempty"`
69+
Items []KarpenterMachinePool `json:"items"`
70+
}
71+
72+
func init() {
73+
SchemeBuilder.Register(&KarpenterMachinePool{}, &KarpenterMachinePoolList{})
74+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 119 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.5
7+
helm.sh/resource-policy: keep
8+
labels:
9+
cluster.x-k8s.io/v1beta1: v1alpha1
10+
name: karpentermachinepools.infrastructure.cluster.x-k8s.io
11+
spec:
12+
group: infrastructure.cluster.x-k8s.io
13+
names:
14+
kind: KarpenterMachinePool
15+
listKind: KarpenterMachinePoolList
16+
plural: karpentermachinepools
17+
singular: karpentermachinepool
18+
scope: Namespaced
19+
versions:
20+
- additionalPrinterColumns:
21+
- jsonPath: .status.ready
22+
name: Ready
23+
type: boolean
24+
- jsonPath: .metadata.creationTimestamp
25+
name: Age
26+
type: date
27+
name: v1alpha1
28+
schema:
29+
openAPIV3Schema:
30+
description: KarpenterMachinePool is the Schema for the karpentermachinepools
31+
API.
32+
properties:
33+
apiVersion:
34+
description: |-
35+
APIVersion defines the versioned schema of this representation of an object.
36+
Servers should convert recognized schemas to the latest internal value, and
37+
may reject unrecognized values.
38+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
39+
type: string
40+
kind:
41+
description: |-
42+
Kind is a string value representing the REST resource this object represents.
43+
Servers may infer this from the endpoint the client submits requests to.
44+
Cannot be updated.
45+
In CamelCase.
46+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
47+
type: string
48+
metadata:
49+
type: object
50+
spec:
51+
description: KarpenterMachinePoolSpec defines the desired state of KarpenterMachinePool.
52+
properties:
53+
iamInstanceProfile:
54+
description: |-
55+
The name or the Amazon Resource Name (ARN) of the instance profile associated
56+
with the IAM role for the instance. The instance profile contains the IAM
57+
role.
58+
type: string
59+
providerIDList:
60+
description: |-
61+
ProviderIDList are the identification IDs of machine instances provided by the provider.
62+
This field must match the provider IDs as seen on the node objects corresponding to a machine pool's machine instances.
63+
items:
64+
type: string
65+
type: array
66+
type: object
67+
status:
68+
description: KarpenterMachinePoolStatus defines the observed state of
69+
KarpenterMachinePool.
70+
properties:
71+
ready:
72+
description: Ready is true when the provider resource is ready.
73+
type: boolean
74+
replicas:
75+
description: Replicas is the most recently observed number of replicas
76+
format: int32
77+
type: integer
78+
type: object
79+
type: object
80+
served: true
81+
storage: true
82+
subresources:
83+
status: {}

0 commit comments

Comments
 (0)