Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 30bc784

Browse files
dkoshkinjimmidyson
andauthored
feat: add cluster-autoscaler CRS addon (nutanix-cloud-native#423)
Co-authored-by: Jimmi Dyson <[email protected]>
1 parent a856a1f commit 30bc784

File tree

31 files changed

+965
-25
lines changed

31 files changed

+965
-25
lines changed

api/v1alpha1/addon_types.go

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ type Addons struct {
1616
// +optional
1717
NFD *NFD `json:"nfd,omitempty"`
1818

19+
// +optional
20+
ClusterAutoscaler *ClusterAutoscaler `json:"clusterAutoscaler,omitempty"`
21+
1922
// +optional
2023
CPI *CPI `json:"cpi,omitempty"`
2124

@@ -29,10 +32,11 @@ func (Addons) VariableSchema() clusterv1.VariableSchema {
2932
Description: "Cluster configuration",
3033
Type: "object",
3134
Properties: map[string]clusterv1.JSONSchemaProps{
32-
"cni": CNI{}.VariableSchema().OpenAPIV3Schema,
33-
"nfd": NFD{}.VariableSchema().OpenAPIV3Schema,
34-
"csi": CSIProviders{}.VariableSchema().OpenAPIV3Schema,
35-
"cpi": CPI{}.VariableSchema().OpenAPIV3Schema,
35+
"cni": CNI{}.VariableSchema().OpenAPIV3Schema,
36+
"nfd": NFD{}.VariableSchema().OpenAPIV3Schema,
37+
"clusterAutoscaler": ClusterAutoscaler{}.VariableSchema().OpenAPIV3Schema,
38+
"csi": CSIProviders{}.VariableSchema().OpenAPIV3Schema,
39+
"cpi": CPI{}.VariableSchema().OpenAPIV3Schema,
3640
},
3741
},
3842
}
@@ -104,6 +108,31 @@ func (NFD) VariableSchema() clusterv1.VariableSchema {
104108
}
105109
}
106110

111+
// ClusterAutoscaler tells us to enable or disable the cluster-autoscaler addon.
112+
type ClusterAutoscaler struct {
113+
// +optional
114+
Strategy AddonStrategy `json:"strategy,omitempty"`
115+
}
116+
117+
func (ClusterAutoscaler) VariableSchema() clusterv1.VariableSchema {
118+
return clusterv1.VariableSchema{
119+
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
120+
Type: "object",
121+
Properties: map[string]clusterv1.JSONSchemaProps{
122+
"strategy": {
123+
Description: "Addon strategy used to deploy cluster-autoscaler to the management cluster," +
124+
"targeting the workload cluster.",
125+
Type: "string",
126+
Enum: variables.MustMarshalValuesToEnumJSON(
127+
AddonStrategyClusterResourceSet,
128+
),
129+
},
130+
},
131+
Required: []string{"strategy"},
132+
},
133+
}
134+
}
135+
107136
type CSIProviders struct {
108137
// +optional
109138
Providers []CSIProvider `json:"providers,omitempty"`

api/v1alpha1/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const (
88
CNIVariableName = "cni"
99
// NFDVariableName is the NFD external patch variable name.
1010
NFDVariableName = "nfd"
11+
// ClusterAutoscalerVariableName is the cluster-autoscaler external patch variable name.
12+
ClusterAutoscalerVariableName = "clusterAutoscaler"
1113
// AWSVariableName is the AWS config patch variable name.
1214
AWSVariableName = "aws"
1315
)

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.

charts/capi-runtime-extensions/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ A Helm chart for capi-runtime-extensions
3131
| deployDefaultClusterClasses | bool | `true` | |
3232
| deployment.replicas | int | `1` | |
3333
| env | object | `{}` | |
34+
| hooks.clusterAutoscaler.crsStrategy.defaultInstallationConfigMap.name | string | `"cluster-autoscaler"` | |
3435
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.configMap.content | string | `""` | |
3536
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.configMap.name | string | `"calico-cni-crs-installation-awscluster"` | |
3637
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.create | bool | `true` | |
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
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/cluster-autoscaler.sh
7+
#=================================================================
8+
apiVersion: v1
9+
data:
10+
cluster-autoscaler.yaml: |
11+
apiVersion: policy/v1
12+
kind: PodDisruptionBudget
13+
metadata:
14+
labels:
15+
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
16+
app.kubernetes.io/managed-by: Helm
17+
app.kubernetes.io/name: clusterapi-cluster-autoscaler
18+
app.kubernetes.io/version: 1.29.0
19+
helm.sh/chart: cluster-autoscaler-9.35.0
20+
name: cluster-autoscaler-tmpl-clustername-tmpl
21+
namespace: tmpl-clusternamespace-tmpl
22+
spec:
23+
maxUnavailable: 1
24+
selector:
25+
matchLabels:
26+
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
27+
app.kubernetes.io/name: clusterapi-cluster-autoscaler
28+
---
29+
apiVersion: v1
30+
automountServiceAccountToken: true
31+
kind: ServiceAccount
32+
metadata:
33+
labels:
34+
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
35+
app.kubernetes.io/managed-by: Helm
36+
app.kubernetes.io/name: clusterapi-cluster-autoscaler
37+
app.kubernetes.io/version: 1.29.0
38+
helm.sh/chart: cluster-autoscaler-9.35.0
39+
name: cluster-autoscaler-tmpl-clustername-tmpl
40+
namespace: tmpl-clusternamespace-tmpl
41+
---
42+
apiVersion: rbac.authorization.k8s.io/v1
43+
kind: Role
44+
metadata:
45+
labels:
46+
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
47+
app.kubernetes.io/managed-by: Helm
48+
app.kubernetes.io/name: clusterapi-cluster-autoscaler
49+
app.kubernetes.io/version: 1.29.0
50+
helm.sh/chart: cluster-autoscaler-9.35.0
51+
name: cluster-autoscaler-tmpl-clustername-tmpl
52+
namespace: tmpl-clusternamespace-tmpl
53+
rules:
54+
- apiGroups:
55+
- ""
56+
resources:
57+
- configmaps
58+
verbs:
59+
- create
60+
- apiGroups:
61+
- ""
62+
resourceNames:
63+
- cluster-autoscaler-status
64+
resources:
65+
- configmaps
66+
verbs:
67+
- delete
68+
- get
69+
- update
70+
- apiGroups:
71+
- cluster.x-k8s.io
72+
resources:
73+
- machinedeployments
74+
- machinepools
75+
- machines
76+
- machinesets
77+
verbs:
78+
- get
79+
- list
80+
- update
81+
- watch
82+
- apiGroups:
83+
- cluster.x-k8s.io
84+
resources:
85+
- machinedeployments/scale
86+
- machinepools/scale
87+
verbs:
88+
- get
89+
- patch
90+
- update
91+
- apiGroups:
92+
- coordination.k8s.io
93+
resources:
94+
- leases
95+
verbs:
96+
- create
97+
- apiGroups:
98+
- coordination.k8s.io
99+
resourceNames:
100+
- cluster-autoscaler
101+
resources:
102+
- leases
103+
verbs:
104+
- get
105+
- update
106+
---
107+
apiVersion: rbac.authorization.k8s.io/v1
108+
kind: RoleBinding
109+
metadata:
110+
labels:
111+
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
112+
app.kubernetes.io/managed-by: Helm
113+
app.kubernetes.io/name: clusterapi-cluster-autoscaler
114+
app.kubernetes.io/version: 1.29.0
115+
helm.sh/chart: cluster-autoscaler-9.35.0
116+
name: cluster-autoscaler-tmpl-clustername-tmpl
117+
namespace: tmpl-clusternamespace-tmpl
118+
roleRef:
119+
apiGroup: rbac.authorization.k8s.io
120+
kind: Role
121+
name: cluster-autoscaler-tmpl-clustername-tmpl
122+
subjects:
123+
- kind: ServiceAccount
124+
name: cluster-autoscaler-tmpl-clustername-tmpl
125+
namespace: tmpl-clusternamespace-tmpl
126+
---
127+
apiVersion: v1
128+
kind: Service
129+
metadata:
130+
labels:
131+
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
132+
app.kubernetes.io/managed-by: Helm
133+
app.kubernetes.io/name: clusterapi-cluster-autoscaler
134+
app.kubernetes.io/version: 1.29.0
135+
helm.sh/chart: cluster-autoscaler-9.35.0
136+
name: cluster-autoscaler-tmpl-clustername-tmpl
137+
namespace: tmpl-clusternamespace-tmpl
138+
spec:
139+
ports:
140+
- name: http
141+
port: 8085
142+
protocol: TCP
143+
targetPort: 8085
144+
selector:
145+
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
146+
app.kubernetes.io/name: clusterapi-cluster-autoscaler
147+
type: ClusterIP
148+
---
149+
apiVersion: apps/v1
150+
kind: Deployment
151+
metadata:
152+
labels:
153+
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
154+
app.kubernetes.io/managed-by: Helm
155+
app.kubernetes.io/name: clusterapi-cluster-autoscaler
156+
app.kubernetes.io/version: 1.29.0
157+
helm.sh/chart: cluster-autoscaler-9.35.0
158+
name: cluster-autoscaler-tmpl-clustername-tmpl
159+
namespace: tmpl-clusternamespace-tmpl
160+
spec:
161+
replicas: 1
162+
revisionHistoryLimit: 10
163+
selector:
164+
matchLabels:
165+
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
166+
app.kubernetes.io/name: clusterapi-cluster-autoscaler
167+
template:
168+
metadata:
169+
labels:
170+
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
171+
app.kubernetes.io/name: clusterapi-cluster-autoscaler
172+
spec:
173+
containers:
174+
- command:
175+
- ./cluster-autoscaler
176+
- --cloud-provider=clusterapi
177+
- --namespace=tmpl-clusternamespace-tmpl
178+
- --node-group-auto-discovery=clusterapi:clusterName=tmpl-clustername-tmpl,namespace=tmpl-clusternamespace-tmpl
179+
- --kubeconfig=/cluster/kubeconfig
180+
- --clusterapi-cloud-config-authoritative
181+
- --enforce-node-group-min-size=true
182+
- --logtostderr=true
183+
- --stderrthreshold=info
184+
- --v=4
185+
env:
186+
- name: POD_NAMESPACE
187+
valueFrom:
188+
fieldRef:
189+
fieldPath: metadata.namespace
190+
- name: SERVICE_ACCOUNT
191+
valueFrom:
192+
fieldRef:
193+
fieldPath: spec.serviceAccountName
194+
image: registry.k8s.io/autoscaling/cluster-autoscaler:v1.29.0
195+
imagePullPolicy: IfNotPresent
196+
livenessProbe:
197+
httpGet:
198+
path: /health-check
199+
port: 8085
200+
name: clusterapi-cluster-autoscaler
201+
ports:
202+
- containerPort: 8085
203+
resources: {}
204+
volumeMounts:
205+
- mountPath: /cluster
206+
name: kubeconfig
207+
readOnly: true
208+
dnsPolicy: ClusterFirst
209+
priorityClassName: system-cluster-critical
210+
serviceAccountName: cluster-autoscaler-tmpl-clustername-tmpl
211+
tolerations:
212+
- effect: NoSchedule
213+
key: node-role.kubernetes.io/control-plane
214+
volumes:
215+
- name: kubeconfig
216+
secret:
217+
items:
218+
- key: value
219+
path: kubeconfig
220+
secretName: tmpl-clustername-tmpl-kubeconfig
221+
kind: ConfigMap
222+
metadata:
223+
creationTimestamp: null
224+
name: cluster-autoscaler

charts/capi-runtime-extensions/templates/role.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ rules:
1818
- patch
1919
- update
2020
- watch
21+
- apiGroups:
22+
- ""
23+
resources:
24+
- nodes
25+
verbs:
26+
- get
27+
- list
28+
- watch
2129
- apiGroups:
2230
- ""
2331
resources:

charts/capi-runtime-extensions/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ hooks:
4343
defaultValueTemplateConfigMap:
4444
create: true
4545
name: default-nfd-helm-values-template
46+
clusterAutoscaler:
47+
crsStrategy:
48+
defaultInstallationConfigMap:
49+
name: cluster-autoscaler
4650

4751
deployDefaultClusterClasses: true
4852

0 commit comments

Comments
 (0)