Skip to content

Commit fb652ed

Browse files
authored
feat: deploy AWS CPI (#229)
resolves #215 fo kubernetes 1.27 i would recommend creating a cluster using the aws cluster in the `examples` directory and checking the existence of the aws-cloud-controller-manager daemonset in the kube-system namespace
1 parent 349bf97 commit fb652ed

File tree

15 files changed

+740
-42
lines changed

15 files changed

+740
-42
lines changed

api/v1alpha1/clusterconfig_types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
const (
1818
CNIProviderCalico = "calico"
1919
CSIProviderAWSEBS = "aws-ebs"
20+
CPIProivderAWS = "aws"
2021
)
2122

2223
//+kubebuilder:object:root=true
@@ -322,6 +323,9 @@ type Addons struct {
322323
// +optional
323324
NFD *NFD `json:"nfd,omitempty"`
324325

326+
// +optional
327+
CPI *CPI `json:"cpi,omitempty"`
328+
325329
// +optional
326330
CSIProviders *CSIProviders `json:"csi,omitempty"`
327331
}
@@ -335,6 +339,7 @@ func (Addons) VariableSchema() clusterv1.VariableSchema {
335339
"cni": CNI{}.VariableSchema().OpenAPIV3Schema,
336340
"nfd": NFD{}.VariableSchema().OpenAPIV3Schema,
337341
"csi": CSIProviders{}.VariableSchema().OpenAPIV3Schema,
342+
"cpi": CPI{}.VariableSchema().OpenAPIV3Schema,
338343
},
339344
},
340345
}
@@ -413,6 +418,17 @@ func (CSIProviders) VariableSchema() clusterv1.VariableSchema {
413418
}
414419
}
415420

421+
// CPI tells us to enable or disable the cloud provider interface.
422+
type CPI struct{}
423+
424+
func (CPI) VariableSchema() clusterv1.VariableSchema {
425+
return clusterv1.VariableSchema{
426+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
427+
Type: "object",
428+
},
429+
}
430+
}
431+
416432
func init() {
417433
SchemeBuilder.Register(&ClusterConfig{})
418434
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# Copyright 2023 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
#=================================================================
5+
# DO NOT EDIT THIS FILE
6+
# IT HAS BEEN GENERATED BY /hack/addons/update-aws-cpi.sh
7+
#=================================================================
8+
apiVersion: v1
9+
data:
10+
aws-cpi-v1.27.1.yaml: |
11+
apiVersion: v1
12+
kind: ServiceAccount
13+
metadata:
14+
labels:
15+
helm.sh/chart: aws-cloud-controller-manager-0.0.8
16+
name: cloud-controller-manager
17+
namespace: kube-system
18+
---
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
kind: ClusterRole
21+
metadata:
22+
labels:
23+
helm.sh/chart: aws-cloud-controller-manager-0.0.8
24+
name: system:cloud-controller-manager
25+
rules:
26+
- apiGroups:
27+
- ""
28+
resources:
29+
- events
30+
verbs:
31+
- create
32+
- patch
33+
- update
34+
- apiGroups:
35+
- ""
36+
resources:
37+
- nodes
38+
verbs:
39+
- '*'
40+
- apiGroups:
41+
- ""
42+
resources:
43+
- nodes/status
44+
verbs:
45+
- patch
46+
- apiGroups:
47+
- ""
48+
resources:
49+
- services
50+
verbs:
51+
- list
52+
- patch
53+
- update
54+
- watch
55+
- apiGroups:
56+
- ""
57+
resources:
58+
- services/status
59+
verbs:
60+
- list
61+
- patch
62+
- update
63+
- watch
64+
- apiGroups:
65+
- ""
66+
resources:
67+
- serviceaccounts
68+
verbs:
69+
- create
70+
- apiGroups:
71+
- ""
72+
resources:
73+
- persistentvolumes
74+
verbs:
75+
- get
76+
- list
77+
- update
78+
- watch
79+
- apiGroups:
80+
- ""
81+
resources:
82+
- endpoints
83+
verbs:
84+
- create
85+
- get
86+
- list
87+
- watch
88+
- update
89+
- apiGroups:
90+
- coordination.k8s.io
91+
resources:
92+
- leases
93+
verbs:
94+
- create
95+
- get
96+
- list
97+
- watch
98+
- update
99+
- apiGroups:
100+
- ""
101+
resources:
102+
- serviceaccounts/token
103+
verbs:
104+
- create
105+
---
106+
apiVersion: rbac.authorization.k8s.io/v1
107+
kind: RoleBinding
108+
metadata:
109+
labels:
110+
helm.sh/chart: aws-cloud-controller-manager-0.0.8
111+
name: cloud-controller-manager:apiserver-authentication-reader
112+
namespace: kube-system
113+
roleRef:
114+
apiGroup: rbac.authorization.k8s.io
115+
kind: Role
116+
name: extension-apiserver-authentication-reader
117+
subjects:
118+
- apiGroup: ""
119+
kind: ServiceAccount
120+
name: cloud-controller-manager
121+
namespace: kube-system
122+
---
123+
apiVersion: rbac.authorization.k8s.io/v1
124+
kind: ClusterRoleBinding
125+
metadata:
126+
labels:
127+
helm.sh/chart: aws-cloud-controller-manager-0.0.8
128+
name: system:cloud-controller-manager
129+
roleRef:
130+
apiGroup: rbac.authorization.k8s.io
131+
kind: ClusterRole
132+
name: system:cloud-controller-manager
133+
subjects:
134+
- apiGroup: ""
135+
kind: ServiceAccount
136+
name: cloud-controller-manager
137+
namespace: kube-system
138+
---
139+
apiVersion: apps/v1
140+
kind: DaemonSet
141+
metadata:
142+
labels:
143+
helm.sh/chart: aws-cloud-controller-manager-0.0.8
144+
k8s-app: aws-cloud-controller-manager
145+
name: aws-cloud-controller-manager
146+
namespace: kube-system
147+
spec:
148+
selector:
149+
matchLabels:
150+
k8s-app: aws-cloud-controller-manager
151+
template:
152+
metadata:
153+
labels:
154+
k8s-app: aws-cloud-controller-manager
155+
name: aws-cloud-controller-manager
156+
spec:
157+
containers:
158+
- args:
159+
- --v=2
160+
- --cloud-provider=aws
161+
- --configure-cloud-routes=false
162+
env: []
163+
image: registry.k8s.io/provider-aws/cloud-controller-manager:v1.27.1
164+
name: aws-cloud-controller-manager
165+
resources:
166+
requests:
167+
cpu: 200m
168+
securityContext: {}
169+
dnsPolicy: Default
170+
nodeSelector:
171+
node-role.kubernetes.io/control-plane: ""
172+
priorityClassName: system-node-critical
173+
securityContext: {}
174+
serviceAccountName: cloud-controller-manager
175+
tolerations:
176+
- effect: NoSchedule
177+
key: node.cloudprovider.kubernetes.io/uninitialized
178+
value: "true"
179+
- effect: NoSchedule
180+
key: node-role.kubernetes.io/master
181+
- effect: NoSchedule
182+
key: node-role.kubernetes.io/control-plane
183+
updateStrategy:
184+
type: RollingUpdate
185+
kind: ConfigMap
186+
metadata:
187+
creationTimestamp: null
188+
name: aws-cpi-v1.27.1

examples/capi-quick-start/aws-cluster.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ spec:
2323
addons:
2424
cni:
2525
provider: calico
26+
cpi: {}
2627
csi:
2728
providers:
2829
- name: aws-ebs

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ go 1.21
88
replace github.com/d2iq-labs/capi-runtime-extensions/common => ./common
99

1010
require (
11+
github.com/blang/semver/v4 v4.0.0
1112
github.com/d2iq-labs/capi-runtime-extensions/common v0.0.0-00010101000000-000000000000
1213
github.com/go-logr/logr v1.2.4
1314
github.com/onsi/gomega v1.28.0
@@ -32,7 +33,6 @@ require (
3233
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
3334
github.com/beorn7/perks v1.0.1 // indirect
3435
github.com/blang/semver v3.5.1+incompatible // indirect
35-
github.com/blang/semver/v4 v4.0.0 // indirect
3636
github.com/cespare/xxhash/v2 v2.2.0 // indirect
3737
github.com/coredns/caddy v1.1.0 // indirect
3838
github.com/coredns/corefile-migration v1.0.21 // indirect
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2023 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: kustomize.config.k8s.io/v1beta1
5+
kind: Kustomization
6+
7+
metadata:
8+
name: aws-cpi-kustomize
9+
10+
helmCharts:
11+
- name: aws-cloud-controller-manager
12+
includeCRDs: true
13+
releaseName: aws-cloud-controller-manager
14+
version: ${CHART_VERSION}
15+
repo: https://kubernetes.github.io/cloud-provider-aws
16+
17+
patches:
18+
- patch: |-
19+
- op: add
20+
path: /spec/template/spec/containers/0/args/-
21+
value: --configure-cloud-routes=false
22+
target:
23+
kind: DaemonSet

hack/addons/update-aws-cpi.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
readonly SCRIPT_DIR
7+
8+
# shellcheck source=hack/common.sh
9+
source "${SCRIPT_DIR}/../common.sh"
10+
11+
AWS_CPI_VERSION=$1
12+
13+
if [ -z "${AWS_CPI_VERSION:-}" ]; then
14+
echo "Missing argument: AWS_CPI_VERSION"
15+
exit 1
16+
fi
17+
18+
ASSETS_DIR="$(mktemp -d -p "${TMPDIR:-/tmp}")"
19+
readonly ASSETS_DIR
20+
trap_add "rm -rf ${ASSETS_DIR}" EXIT
21+
22+
export CHART_VERSION=""
23+
if [ "${AWS_CPI_VERSION}" = "1.27.1" ]; then
24+
CHART_VERSION="0.0.8"
25+
fi
26+
27+
readonly KUSTOMIZE_BASE_DIR="${SCRIPT_DIR}/kustomize/aws-cpi/"
28+
envsubst -no-unset <"${KUSTOMIZE_BASE_DIR}/kustomization.yaml.tmpl" >"${ASSETS_DIR}/kustomization.yaml"
29+
30+
readonly FILE_NAME="aws-cpi-${AWS_CPI_VERSION}.yaml"
31+
kustomize build --enable-helm "${ASSETS_DIR}" >"${ASSETS_DIR}/${FILE_NAME}"
32+
33+
kubectl create configmap aws-cpi-"${AWS_CPI_VERSION}" --dry-run=client --output yaml \
34+
--from-file "${ASSETS_DIR}/${FILE_NAME}" \
35+
>"${ASSETS_DIR}/aws-ebs-cpi-${AWS_CPI_VERSION}-configmap.yaml"
36+
37+
# add warning not to edit file directly
38+
cat <<EOF >"${GIT_REPO_ROOT}/charts/capi-runtime-extensions/templates/cpi/aws/manifests/aws-ebs-cpi-${AWS_CPI_VERSION}-configmap.yaml"
39+
$(cat "${GIT_REPO_ROOT}/hack/license-header.yaml.txt")
40+
41+
#=================================================================
42+
# DO NOT EDIT THIS FILE
43+
# IT HAS BEEN GENERATED BY /hack/addons/update-aws-cpi.sh
44+
#=================================================================
45+
$(cat "${ASSETS_DIR}/aws-ebs-cpi-${AWS_CPI_VERSION}-configmap.yaml")
46+
EOF

hack/examples/bases/aws/kustomization.yaml.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ patches:
3939
cni:
4040
provider: calico
4141
nfd: {}
42+
cpi: {}
4243
csi:
4344
providers:
4445
- name: aws-ebs

make/addons.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export CALICO_VERSION := v3.26.3
55
export NODE_FEATURE_DISCOVERY_VERSION := 0.14.1
66
export AWS_CSI_SNAPSHOT_CONTROLLER_VERSION := v6.3.0
77
export AWS_EBS_CSI_VERSION := release-1.23
8+
export AWS_CPI_VERSION_127 := v1.27.1
89

910
.PHONY: addons.sync
1011
addons.sync: $(addprefix update-addon.,calico nfd aws-ebs-csi)
@@ -20,3 +21,7 @@ update-addon.nfd: ; $(info $(M) updating node feature discovery manifests)
2021
.PHONY: update-addon.aws-ebs-csi
2122
update-addon.aws-ebs-csi: ; $(info $(M) updating aws ebs csi manifests)
2223
./hack/addons/update-aws-ebs-csi.sh
24+
25+
.PHONY: update-addon.aws-cpi.127
26+
update-addon.aws-cpi.127: ; $(info $(M) updating aws cpi manifests)
27+
./hack/addons/update-aws-cpi.sh $(AWS_CPI_VERSION_127)

0 commit comments

Comments
 (0)