Skip to content

feat: add cluster-autoscaler CRS addon #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions api/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type Addons struct {
// +optional
NFD *NFD `json:"nfd,omitempty"`

// +optional
ClusterAutoscaler *ClusterAutoscaler `json:"clusterAutoscaler,omitempty"`

// +optional
CPI *CPI `json:"cpi,omitempty"`

Expand All @@ -29,10 +32,11 @@ func (Addons) VariableSchema() clusterv1.VariableSchema {
Description: "Cluster configuration",
Type: "object",
Properties: map[string]clusterv1.JSONSchemaProps{
"cni": CNI{}.VariableSchema().OpenAPIV3Schema,
"nfd": NFD{}.VariableSchema().OpenAPIV3Schema,
"csi": CSIProviders{}.VariableSchema().OpenAPIV3Schema,
"cpi": CPI{}.VariableSchema().OpenAPIV3Schema,
"cni": CNI{}.VariableSchema().OpenAPIV3Schema,
"nfd": NFD{}.VariableSchema().OpenAPIV3Schema,
"clusterAutoscaler": ClusterAutoscaler{}.VariableSchema().OpenAPIV3Schema,
"csi": CSIProviders{}.VariableSchema().OpenAPIV3Schema,
"cpi": CPI{}.VariableSchema().OpenAPIV3Schema,
},
},
}
Expand Down Expand Up @@ -104,6 +108,31 @@ func (NFD) VariableSchema() clusterv1.VariableSchema {
}
}

// ClusterAutoscaler tells us to enable or disable the cluster-autoscaler addon.
type ClusterAutoscaler struct {
// +optional
Strategy AddonStrategy `json:"strategy,omitempty"`
}

func (ClusterAutoscaler) VariableSchema() clusterv1.VariableSchema {
return clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "object",
Properties: map[string]clusterv1.JSONSchemaProps{
"strategy": {
Description: "Addon strategy used to deploy cluster-autoscaler to the management cluster," +
"targeting the workload cluster.",
Type: "string",
Enum: variables.MustMarshalValuesToEnumJSON(
AddonStrategyClusterResourceSet,
),
},
},
Required: []string{"strategy"},
},
}
}

type CSIProviders struct {
// +optional
Providers []CSIProvider `json:"providers,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const (
CNIVariableName = "cni"
// NFDVariableName is the NFD external patch variable name.
NFDVariableName = "nfd"
// ClusterAutoscalerVariableName is the cluster-autoscaler external patch variable name.
ClusterAutoscalerVariableName = "clusterAutoscaler"
// AWSVariableName is the AWS config patch variable name.
AWSVariableName = "aws"
)
20 changes: 20 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions charts/capi-runtime-extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ A Helm chart for capi-runtime-extensions
| deployDefaultClusterClasses | bool | `true` | |
| deployment.replicas | int | `1` | |
| env | object | `{}` | |
| hooks.clusterAutoscaler.crsStrategy.defaultInstallationConfigMap.name | string | `"cluster-autoscaler"` | |
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.configMap.content | string | `""` | |
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.configMap.name | string | `"calico-cni-crs-installation-awscluster"` | |
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.create | bool | `true` | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
# Copyright 2023 D2iQ, Inc. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

#=================================================================
# DO NOT EDIT THIS FILE
# IT HAS BEEN GENERATED BY /hack/addons/cluster-autoscaler.sh
#=================================================================
apiVersion: v1
data:
cluster-autoscaler.yaml: |
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
labels:
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: clusterapi-cluster-autoscaler
app.kubernetes.io/version: 1.29.0
helm.sh/chart: cluster-autoscaler-9.35.0
name: cluster-autoscaler-tmpl-clustername-tmpl
namespace: tmpl-clusternamespace-tmpl
spec:
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
app.kubernetes.io/name: clusterapi-cluster-autoscaler
---
apiVersion: v1
automountServiceAccountToken: true
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: clusterapi-cluster-autoscaler
app.kubernetes.io/version: 1.29.0
helm.sh/chart: cluster-autoscaler-9.35.0
name: cluster-autoscaler-tmpl-clustername-tmpl
namespace: tmpl-clusternamespace-tmpl
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
labels:
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: clusterapi-cluster-autoscaler
app.kubernetes.io/version: 1.29.0
helm.sh/chart: cluster-autoscaler-9.35.0
name: cluster-autoscaler-tmpl-clustername-tmpl
namespace: tmpl-clusternamespace-tmpl
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- apiGroups:
- ""
resourceNames:
- cluster-autoscaler-status
resources:
- configmaps
verbs:
- delete
- get
- update
- apiGroups:
- cluster.x-k8s.io
resources:
- machinedeployments
- machinepools
- machines
- machinesets
verbs:
- get
- list
- update
- watch
- apiGroups:
- cluster.x-k8s.io
resources:
- machinedeployments/scale
- machinepools/scale
verbs:
- get
- patch
- update
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- apiGroups:
- coordination.k8s.io
resourceNames:
- cluster-autoscaler
resources:
- leases
verbs:
- get
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: clusterapi-cluster-autoscaler
app.kubernetes.io/version: 1.29.0
helm.sh/chart: cluster-autoscaler-9.35.0
name: cluster-autoscaler-tmpl-clustername-tmpl
namespace: tmpl-clusternamespace-tmpl
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: cluster-autoscaler-tmpl-clustername-tmpl
subjects:
- kind: ServiceAccount
name: cluster-autoscaler-tmpl-clustername-tmpl
namespace: tmpl-clusternamespace-tmpl
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: clusterapi-cluster-autoscaler
app.kubernetes.io/version: 1.29.0
helm.sh/chart: cluster-autoscaler-9.35.0
name: cluster-autoscaler-tmpl-clustername-tmpl
namespace: tmpl-clusternamespace-tmpl
spec:
ports:
- name: http
port: 8085
protocol: TCP
targetPort: 8085
selector:
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
app.kubernetes.io/name: clusterapi-cluster-autoscaler
type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: clusterapi-cluster-autoscaler
app.kubernetes.io/version: 1.29.0
helm.sh/chart: cluster-autoscaler-9.35.0
name: cluster-autoscaler-tmpl-clustername-tmpl
namespace: tmpl-clusternamespace-tmpl
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
app.kubernetes.io/name: clusterapi-cluster-autoscaler
template:
metadata:
labels:
app.kubernetes.io/instance: cluster-autoscaler-tmpl-clustername-tmpl
app.kubernetes.io/name: clusterapi-cluster-autoscaler
spec:
containers:
- command:
- ./cluster-autoscaler
- --cloud-provider=clusterapi
- --namespace=tmpl-clusternamespace-tmpl
- --node-group-auto-discovery=clusterapi:clusterName=tmpl-clustername-tmpl,namespace=tmpl-clusternamespace-tmpl
- --kubeconfig=/cluster/kubeconfig
- --clusterapi-cloud-config-authoritative
- --enforce-node-group-min-size=true
- --logtostderr=true
- --stderrthreshold=info
- --v=4
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: SERVICE_ACCOUNT
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
image: registry.k8s.io/autoscaling/cluster-autoscaler:v1.29.0
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /health-check
port: 8085
name: clusterapi-cluster-autoscaler
ports:
- containerPort: 8085
resources: {}
volumeMounts:
- mountPath: /cluster
name: kubeconfig
readOnly: true
dnsPolicy: ClusterFirst
priorityClassName: system-cluster-critical
serviceAccountName: cluster-autoscaler-tmpl-clustername-tmpl
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
volumes:
- name: kubeconfig
secret:
items:
- key: value
path: kubeconfig
secretName: tmpl-clustername-tmpl-kubeconfig
kind: ConfigMap
metadata:
creationTimestamp: null
name: cluster-autoscaler
8 changes: 8 additions & 0 deletions charts/capi-runtime-extensions/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
Expand Down
4 changes: 4 additions & 0 deletions charts/capi-runtime-extensions/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ hooks:
defaultValueTemplateConfigMap:
create: true
name: default-nfd-helm-values-template
clusterAutoscaler:
crsStrategy:
defaultInstallationConfigMap:
name: cluster-autoscaler

deployDefaultClusterClasses: true

Expand Down
Loading