Skip to content

Commit e11bcee

Browse files
alfredkrohmermirozoe
authored andcommitted
chore: modernize toolchain
1 parent e9bd1f3 commit e11bcee

File tree

12 files changed

+99
-529
lines changed

12 files changed

+99
-529
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.18 as builder
2+
FROM golang:1.24 as builder
33

44
WORKDIR /workspace
55
# Copy the go source

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
8383

8484
## Tool Versions
8585
KUSTOMIZE_VERSION ?= v3.8.7
86-
CONTROLLER_TOOLS_VERSION ?= v0.9.0
86+
CONTROLLER_TOOLS_VERSION ?= v0.19.0
8787

8888
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
8989
.PHONY: kustomize

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,5 @@ Tags can be defined from CLI as default tags, what will be applied to EIP and EN
256256
### ENIs
257257

258258
To be documented
259+
260+
ENI specification requires at least one tag. It could be default tag or specified in YAML.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/k8s-aws-operator/crds/aws.k8s.logmein.com_eipassociations.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.9.0
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.19.0
87
name: eipassociations.aws.k8s.logmein.com
98
spec:
109
group: aws.k8s.logmein.com
@@ -27,14 +26,19 @@ spec:
2726
openAPIV3Schema:
2827
properties:
2928
apiVersion:
30-
description: 'APIVersion defines the versioned schema of this representation
31-
of an object. Servers should convert recognized schemas to the latest
32-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
29+
description: |-
30+
APIVersion defines the versioned schema of this representation of an object.
31+
Servers should convert recognized schemas to the latest internal value, and
32+
may reject unrecognized values.
33+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
3334
type: string
3435
kind:
35-
description: 'Kind is a string value representing the REST resource this
36-
object represents. Servers may infer this from the endpoint the client
37-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
36+
description: |-
37+
Kind is a string value representing the REST resource this object represents.
38+
Servers may infer this from the endpoint the client submits requests to.
39+
Cannot be updated.
40+
In CamelCase.
41+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
3842
type: string
3943
metadata:
4044
type: object

charts/k8s-aws-operator/crds/aws.k8s.logmein.com_eips.yaml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.9.0
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.19.0
87
name: eips.aws.k8s.logmein.com
98
spec:
109
group: aws.k8s.logmein.com
@@ -37,23 +36,30 @@ spec:
3736
description: EIP is the Schema for the eips API
3837
properties:
3938
apiVersion:
40-
description: 'APIVersion defines the versioned schema of this representation
41-
of an object. Servers should convert recognized schemas to the latest
42-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
39+
description: |-
40+
APIVersion defines the versioned schema of this representation of an object.
41+
Servers should convert recognized schemas to the latest internal value, and
42+
may reject unrecognized values.
43+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
4344
type: string
4445
kind:
45-
description: 'Kind is a string value representing the REST resource this
46-
object represents. Servers may infer this from the endpoint the client
47-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
46+
description: |-
47+
Kind is a string value representing the REST resource this object represents.
48+
Servers may infer this from the endpoint the client submits requests to.
49+
Cannot be updated.
50+
In CamelCase.
51+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
4852
type: string
4953
metadata:
5054
type: object
5155
spec:
5256
description: EIPSpec defines the desired state of EIP
5357
properties:
5458
assignment:
55-
description: "Which resource this EIP should be assigned to. \n If
56-
not given, it will not be assigned to anything."
59+
description: |-
60+
Which resource this EIP should be assigned to.
61+
62+
If not given, it will not be assigned to anything.
5763
properties:
5864
eni:
5965
type: string
@@ -101,11 +107,18 @@ spec:
101107
publicIPAddress:
102108
type: string
103109
state:
104-
description: "Current state of the EIP object. \n State transfer diagram:
105-
\n /------- unassigning <----\\--------------\\ | |
106-
\ | *start*: V | |
110+
description: |-
111+
Current state of the EIP object.
112+
113+
State transfer diagram:
114+
115+
/------- unassigning <----\--------------\
116+
| | |
117+
*start*: V | |
107118
allocating -> allocated <-> assigning -> assigned <-> reassigning
108-
| | *end*: | | releasing <------/-------------/"
119+
| |
120+
*end*: | |
121+
releasing <------/-------------/
109122
type: string
110123
required:
111124
- state

charts/k8s-aws-operator/crds/aws.k8s.logmein.com_enis.yaml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.9.0
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.19.0
87
name: enis.aws.k8s.logmein.com
98
spec:
109
group: aws.k8s.logmein.com
@@ -28,14 +27,19 @@ spec:
2827
description: ENI is the Schema for the enis API
2928
properties:
3029
apiVersion:
31-
description: 'APIVersion defines the versioned schema of this representation
32-
of an object. Servers should convert recognized schemas to the latest
33-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
30+
description: |-
31+
APIVersion defines the versioned schema of this representation of an object.
32+
Servers should convert recognized schemas to the latest internal value, and
33+
may reject unrecognized values.
34+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
3435
type: string
3536
kind:
36-
description: 'Kind is a string value representing the REST resource this
37-
object represents. Servers may infer this from the endpoint the client
38-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
37+
description: |-
38+
Kind is a string value representing the REST resource this object represents.
39+
Servers may infer this from the endpoint the client submits requests to.
40+
Cannot be updated.
41+
In CamelCase.
42+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
3943
type: string
4044
metadata:
4145
type: object
@@ -59,6 +63,11 @@ spec:
5963
type: array
6064
subnetID:
6165
type: string
66+
tags:
67+
additionalProperties:
68+
type: string
69+
description: Tags that will be applied to the created EIP.
70+
type: object
6271
required:
6372
- securityGroups
6473
- subnetID

config/rbac/role.yaml

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,13 @@
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:
5-
creationTimestamp: null
65
name: manager-role
76
rules:
87
- apiGroups:
98
- aws.k8s.logmein.com
109
resources:
1110
- eipassociations
12-
verbs:
13-
- create
14-
- delete
15-
- get
16-
- list
17-
- patch
18-
- update
19-
- watch
20-
- apiGroups:
21-
- aws.k8s.logmein.com
22-
resources:
2311
- eips
24-
verbs:
25-
- create
26-
- delete
27-
- get
28-
- list
29-
- patch
30-
- update
31-
- watch
32-
- apiGroups:
33-
- aws.k8s.logmein.com
34-
resources:
35-
- eips/status
36-
verbs:
37-
- get
38-
- patch
39-
- update
40-
- apiGroups:
41-
- aws.k8s.logmein.com
42-
resources:
4312
- enis
4413
verbs:
4514
- create
@@ -52,6 +21,7 @@ rules:
5221
- apiGroups:
5322
- aws.k8s.logmein.com
5423
resources:
24+
- eips/status
5525
- enis/status
5626
verbs:
5727
- get

controllers/eip_controller.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ func (r *EIPReconciler) allocateEIP(ctx context.Context, eip *awsv1alpha1.EIP, l
218218
func (r EIPReconciler) combineDefaultAndDefinedTags(eip *awsv1alpha1.EIP) []*ec2.Tag {
219219
var tags []*ec2.Tag
220220
tags = convertMapToTags(r.Tags)
221-
tags = append(tags, convertMapToTags(*eip.Spec.Tags)...)
221+
if eip.Spec.Tags != nil {
222+
tags = append(tags, convertMapToTags(*eip.Spec.Tags)...)
223+
}
222224
return tags
223225
}
224226

@@ -230,7 +232,9 @@ func (r *EIPReconciler) reconcileTags(ctx context.Context, eip *awsv1alpha1.EIP,
230232
resources := []*string{aws.String(eip.Status.AllocationId)}
231233

232234
var tagsToCreate []*ec2.Tag
233-
for k, v := range *eip.Spec.Tags {
235+
for _, tag := range r.combineDefaultAndDefinedTags(eip) {
236+
k := aws.StringValue(tag.Key)
237+
v := aws.StringValue(tag.Value)
234238
create := true
235239
for _, tag := range existingTags {
236240
if aws.StringValue(tag.Key) == k && aws.StringValue(tag.Value) == v {

controllers/eni_controller.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ func (r *ENIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
175175
return ctrl.Result{}, r.Update(ctx, &eni)
176176
}
177177

178+
// reconcile tags
179+
if err := r.reconcileTags(ctx, &eni, eniInfo.TagSet); err != nil {
180+
return ctrl.Result{}, err
181+
}
182+
178183
// reconcile pod attachment
179184
if eni.Spec.Attachment == nil {
180185
if eniInfo.Attachment == nil || aws.StringValue(eniInfo.Attachment.Status) != "attached" {
@@ -209,11 +214,6 @@ func (r *ENIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
209214
}
210215
}
211216

212-
// reconcile tags
213-
if err := r.reconcileTags(ctx, &eni, eniInfo.TagSet); err != nil {
214-
return ctrl.Result{}, err
215-
}
216-
217217
eni.Status.Attachment = eni.Spec.Attachment
218218
return ctrl.Result{}, r.Update(ctx, &eni)
219219
} else if containsString(eni.ObjectMeta.Finalizers, finalizerName) {
@@ -377,7 +377,9 @@ func (r *ENIReconciler) SetupWithManager(mgr ctrl.Manager) error {
377377
func (r ENIReconciler) combineDefaultAndDefinedTags(eni *awsv1alpha1.ENI) []*ec2.Tag {
378378
var tags []*ec2.Tag
379379
tags = convertMapToTags(r.Tags)
380-
tags = append(tags, convertMapToTags(*eni.Spec.Tags)...)
380+
if eni.Spec.Tags != nil {
381+
tags = append(tags, convertMapToTags(*eni.Spec.Tags)...)
382+
}
381383
return tags
382384
}
383385

@@ -386,7 +388,9 @@ func (r *ENIReconciler) reconcileTags(ctx context.Context, eni *awsv1alpha1.ENI,
386388

387389
// create tags that are defined in the spec but not present yet
388390
var tagsToCreate []*ec2.Tag
389-
for k, v := range *eni.Spec.Tags {
391+
for _, tag := range r.combineDefaultAndDefinedTags(eni) {
392+
k := aws.StringValue(tag.Key)
393+
v := aws.StringValue(tag.Value)
390394
create := true
391395
for _, tag := range existingTags {
392396
if aws.StringValue(tag.Key) == k && aws.StringValue(tag.Value) == v {

0 commit comments

Comments
 (0)