Skip to content

Commit fd0f95e

Browse files
committed
docs: enable cluster-autoscaler in example clusters
1 parent a76a6db commit fd0f95e

File tree

12 files changed

+124
-48
lines changed

12 files changed

+124
-48
lines changed

charts/capi-runtime-extensions/README.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,45 @@ A Helm chart for capi-runtime-extensions
2323

2424
## Values
2525

26-
| Key | Type | Default | Description |
27-
|--------------------------------------------------------------------------------------------|------|---------------------------------------------------|-------------|
28-
| certificates.issuer.kind | string | `"Issuer"` | |
29-
| certificates.issuer.name | string | `""` | |
30-
| certificates.issuer.selfSigned | bool | `true` | |
31-
| deployDefaultClusterClasses | bool | `true` | |
32-
| deployment.replicas | int | `1` | |
33-
| env | object | `{}` | |
34-
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.configMap.content | string | `""` | |
35-
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.configMap.name | string | `"calico-cni-crs-installation-awscluster"` | |
36-
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.create | bool | `true` | |
37-
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.DockerCluster.configMap.content | string | `""` | |
38-
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.DockerCluster.configMap.name | string | `"calico-cni-crs-installation-dockercluster"` | |
39-
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.DockerCluster.create | bool | `true` | |
40-
| hooks.cni.calico.crsStrategy.defaultTigeraOperatorConfigMap.name | string | `"tigera-operator"` | |
41-
| hooks.cni.calico.defaultPodSubnet | string | `"192.168.0.0/16"` | |
42-
| hooks.cni.calico.helmAddonStrategy.defaultValueTemplatesConfigMaps.AWSCluster.create | bool | `true` | |
43-
| hooks.cni.calico.helmAddonStrategy.defaultValueTemplatesConfigMaps.AWSCluster.name | string | `"calico-cni-helm-values-template-awscluster"` | |
44-
| hooks.cni.calico.helmAddonStrategy.defaultValueTemplatesConfigMaps.DockerCluster.create | bool | `true` | |
45-
| hooks.cni.calico.helmAddonStrategy.defaultValueTemplatesConfigMaps.DockerCluster.name | string | `"calico-cni-helm-values-template-dockercluster"` | |
46-
| hooks.cni.cilium.crsStrategy.defaultCiliumConfigMap.name | string | `"cilium"` | |
47-
| hooks.cni.cilium.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
48-
| hooks.cni.cilium.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-cilium-cni-helm-values-template"` | |
49-
| hooks.nfd.crsStrategy.defaultInstallationConfigMap.name | string | `"node-feature-discovery"` | |
50-
| hooks.nfd.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
51-
| hooks.nfd.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-nfd-helm-values-template"` | |
52-
| hooks.clusterAutoscaler.crsStrategy.defaultInstallationConfigMap.name | string | `"cluster-autoscaler"` | |
53-
| image.pullPolicy | string | `"IfNotPresent"` | |
54-
| image.repository | string | `"ghcr.io/d2iq-labs/capi-runtime-extensions"` | |
55-
| image.tag | string | `""` | |
56-
| imagePullSecrets | list | `[]` | Optional secrets used for pulling the container image |
57-
| nodeSelector | object | `{}` | |
58-
| priorityClassName | string | `""` | Optional priority class to be used for the pod. |
59-
| resources.limits.cpu | string | `"100m"` | |
60-
| resources.limits.memory | string | `"256Mi"` | |
61-
| resources.requests.cpu | string | `"100m"` | |
62-
| resources.requests.memory | string | `"128Mi"` | |
63-
| securityContext.runAsUser | int | `65532` | |
64-
| service.annotations | object | `{}` | |
65-
| service.port | int | `443` | |
66-
| service.type | string | `"ClusterIP"` | |
67-
| tolerations | list | `[]` | |
26+
| Key | Type | Default | Description |
27+
|-----|------|---------|-------------|
28+
| certificates.issuer.kind | string | `"Issuer"` | |
29+
| certificates.issuer.name | string | `""` | |
30+
| certificates.issuer.selfSigned | bool | `true` | |
31+
| deployDefaultClusterClasses | bool | `true` | |
32+
| deployment.replicas | int | `1` | |
33+
| env | object | `{}` | |
34+
| hooks.clusterAutoscaler.crsStrategy.defaultInstallationConfigMap.name | string | `"cluster-autoscaler"` | |
35+
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.configMap.content | string | `""` | |
36+
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.configMap.name | string | `"calico-cni-crs-installation-awscluster"` | |
37+
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.AWSCluster.create | bool | `true` | |
38+
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.DockerCluster.configMap.content | string | `""` | |
39+
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.DockerCluster.configMap.name | string | `"calico-cni-crs-installation-dockercluster"` | |
40+
| hooks.cni.calico.crsStrategy.defaultInstallationConfigMaps.DockerCluster.create | bool | `true` | |
41+
| hooks.cni.calico.crsStrategy.defaultTigeraOperatorConfigMap.name | string | `"tigera-operator"` | |
42+
| hooks.cni.calico.defaultPodSubnet | string | `"192.168.0.0/16"` | |
43+
| hooks.cni.calico.helmAddonStrategy.defaultValueTemplatesConfigMaps.AWSCluster.create | bool | `true` | |
44+
| hooks.cni.calico.helmAddonStrategy.defaultValueTemplatesConfigMaps.AWSCluster.name | string | `"calico-cni-helm-values-template-awscluster"` | |
45+
| hooks.cni.calico.helmAddonStrategy.defaultValueTemplatesConfigMaps.DockerCluster.create | bool | `true` | |
46+
| hooks.cni.calico.helmAddonStrategy.defaultValueTemplatesConfigMaps.DockerCluster.name | string | `"calico-cni-helm-values-template-dockercluster"` | |
47+
| hooks.cni.cilium.crsStrategy.defaultCiliumConfigMap.name | string | `"cilium"` | |
48+
| hooks.cni.cilium.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
49+
| hooks.cni.cilium.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-cilium-cni-helm-values-template"` | |
50+
| hooks.nfd.crsStrategy.defaultInstallationConfigMap.name | string | `"node-feature-discovery"` | |
51+
| hooks.nfd.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
52+
| hooks.nfd.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-nfd-helm-values-template"` | |
53+
| image.pullPolicy | string | `"IfNotPresent"` | |
54+
| image.repository | string | `"ghcr.io/d2iq-labs/capi-runtime-extensions"` | |
55+
| image.tag | string | `""` | |
56+
| imagePullSecrets | list | `[]` | Optional secrets used for pulling the container image |
57+
| nodeSelector | object | `{}` | |
58+
| priorityClassName | string | `""` | Optional priority class to be used for the pod. |
59+
| resources.limits.cpu | string | `"100m"` | |
60+
| resources.limits.memory | string | `"256Mi"` | |
61+
| resources.requests.cpu | string | `"100m"` | |
62+
| resources.requests.memory | string | `"128Mi"` | |
63+
| securityContext.runAsUser | int | `65532` | |
64+
| service.annotations | object | `{}` | |
65+
| service.port | int | `443` | |
66+
| service.type | string | `"ClusterIP"` | |
67+
| tolerations | list | `[]` | |

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ spec:
2121
- name: clusterConfig
2222
value:
2323
addons:
24+
clusterAutoscaler:
25+
strategy: ClusterResourceSet
2426
cni:
2527
provider: Calico
2628
strategy: ClusterResourceSet
@@ -51,5 +53,8 @@ spec:
5153
workers:
5254
machineDeployments:
5355
- class: default-worker
56+
metadata:
57+
annotations:
58+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "${WORKER_MACHINE_COUNT}"
59+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "${WORKER_MACHINE_COUNT}"
5460
name: md-0
55-
replicas: ${WORKER_MACHINE_COUNT}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ spec:
2121
- name: clusterConfig
2222
value:
2323
addons:
24+
clusterAutoscaler:
25+
strategy: ClusterResourceSet
2426
cni:
2527
provider: Cilium
2628
strategy: ClusterResourceSet
@@ -51,5 +53,8 @@ spec:
5153
workers:
5254
machineDeployments:
5355
- class: default-worker
56+
metadata:
57+
annotations:
58+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "${WORKER_MACHINE_COUNT}"
59+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "${WORKER_MACHINE_COUNT}"
5460
name: md-0
55-
replicas: ${WORKER_MACHINE_COUNT}

examples/capi-quick-start/docker-cluster-calico-crs.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ spec:
2222
- name: clusterConfig
2323
value:
2424
addons:
25+
clusterAutoscaler:
26+
strategy: ClusterResourceSet
2527
cni:
2628
provider: Calico
2729
strategy: ClusterResourceSet
@@ -32,5 +34,8 @@ spec:
3234
workers:
3335
machineDeployments:
3436
- class: default-worker
37+
metadata:
38+
annotations:
39+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "${WORKER_MACHINE_COUNT}"
40+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "${WORKER_MACHINE_COUNT}"
3541
name: md-0
36-
replicas: ${WORKER_MACHINE_COUNT}

examples/capi-quick-start/docker-cluster-cilium-crs.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ spec:
2222
- name: clusterConfig
2323
value:
2424
addons:
25+
clusterAutoscaler:
26+
strategy: ClusterResourceSet
2527
cni:
2628
provider: Cilium
2729
strategy: ClusterResourceSet
@@ -32,5 +34,8 @@ spec:
3234
workers:
3335
machineDeployments:
3436
- class: default-worker
37+
metadata:
38+
annotations:
39+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "${WORKER_MACHINE_COUNT}"
40+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "${WORKER_MACHINE_COUNT}"
3541
name: md-0
36-
replicas: ${WORKER_MACHINE_COUNT}

hack/addons/update-cluster-autoscaler.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ fi
1515

1616
ASSETS_DIR="$(mktemp -d -p "${TMPDIR:-/tmp}")"
1717
readonly ASSETS_DIR
18-
#trap_add "rm -rf ${ASSETS_DIR}" EXIT
19-
echo ${ASSETS_DIR}
18+
trap_add "rm -rf ${ASSETS_DIR}" EXIT
2019

2120
readonly FILE_NAME="cluster-autoscaler.yaml"
2221

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ patches:
2828
path: "/spec/topology/variables/0/value/addons/nfd"
2929
value:
3030
strategy: ClusterResourceSet
31+
- op: "add"
32+
path: "/spec/topology/variables/0/value/addons/clusterAutoscaler"
33+
value:
34+
strategy: ClusterResourceSet
35+
- op: "remove"
36+
path: "/spec/topology/workers/machineDeployments/0/replicas"
37+
- op: "add"
38+
path: "/spec/topology/workers/machineDeployments/0/metadata"
39+
value:
40+
annotations:
41+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "$${WORKER_MACHINE_COUNT}"
42+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "$${WORKER_MACHINE_COUNT}"
43+
3144

3245
# Delete all ClusterClass related resources to prevent duplicate resources because we use the same resources definition
3346
# above- we only actually want the Cluster resource to mutate here.

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ patches:
2828
path: "/spec/topology/variables/0/value/addons/nfd"
2929
value:
3030
strategy: ClusterResourceSet
31+
- op: "add"
32+
path: "/spec/topology/variables/0/value/addons/clusterAutoscaler"
33+
value:
34+
strategy: ClusterResourceSet
35+
- op: "remove"
36+
path: "/spec/topology/workers/machineDeployments/0/replicas"
37+
- op: "add"
38+
path: "/spec/topology/workers/machineDeployments/0/metadata"
39+
value:
40+
annotations:
41+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "$${WORKER_MACHINE_COUNT}"
42+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "$${WORKER_MACHINE_COUNT}"
43+
3144

3245
# Delete all ClusterClass related resources to prevent duplicate resources because we use the same resources definition
3346
# above- we only actually want the Cluster resource to mutate here.

hack/examples/bases/docker/calico/crs/kustomization.yaml.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,15 @@ patches:
2828
path: "/spec/topology/variables/0/value/addons/nfd"
2929
value:
3030
strategy: ClusterResourceSet
31+
- op: "add"
32+
path: "/spec/topology/variables/0/value/addons/clusterAutoscaler"
33+
value:
34+
strategy: ClusterResourceSet
35+
- op: "remove"
36+
path: "/spec/topology/workers/machineDeployments/0/replicas"
37+
- op: "add"
38+
path: "/spec/topology/workers/machineDeployments/0/metadata"
39+
value:
40+
annotations:
41+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "$${WORKER_MACHINE_COUNT}"
42+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "$${WORKER_MACHINE_COUNT}"

hack/examples/bases/docker/cilium/crs/kustomization.yaml.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,15 @@ patches:
2828
path: "/spec/topology/variables/0/value/addons/nfd"
2929
value:
3030
strategy: ClusterResourceSet
31+
- op: "add"
32+
path: "/spec/topology/variables/0/value/addons/clusterAutoscaler"
33+
value:
34+
strategy: ClusterResourceSet
35+
- op: "remove"
36+
path: "/spec/topology/workers/machineDeployments/0/replicas"
37+
- op: "add"
38+
path: "/spec/topology/workers/machineDeployments/0/metadata"
39+
value:
40+
annotations:
41+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "$${WORKER_MACHINE_COUNT}"
42+
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "$${WORKER_MACHINE_COUNT}"

hack/examples/sync.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,7 @@ sed -i'' 's/${AMI_LOOKUP_ORG}/"${AMI_LOOKUP_ORG}"/' "${EXAMPLE_CLUSTERS_DIR}"/*.
111111

112112
# TODO Remove once CAPA templates default to using external cloud provider.
113113
sed -i'' 's/cloud-provider:\ aws/cloud-provider:\ external/g' "${EXAMPLE_CLUSTERCLASSES_DIR}/aws-cluster-class.yaml"
114+
115+
# TODO Remove once kustomize supports retaining quotes in what will be numeric values.
116+
#shellcheck disable=SC2016
117+
sed -i'' 's/size\: ${WORKER_MACHINE_COUNT}/size\: "${WORKER_MACHINE_COUNT}"/' "${EXAMPLE_CLUSTERS_DIR}"/*.yaml

pkg/handlers/generic/lifecycle/clusterautoscaler/template.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright 2023 D2iQ, Inc. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
package clusterautoscaler
25

36
import "strings"

0 commit comments

Comments
 (0)