Skip to content

Commit

Permalink
test: add templates for autoscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Aug 26, 2024
1 parent cf6bf1c commit 1caecef
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ generate-e2e-templates-main: $(KUSTOMIZE) ## Generate test templates for the mai
"$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/clusterclass-runtimesdk" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/clusterclass-quick-start-supervisor-runtimesdk.yaml"
cp "$(RELEASE_DIR)/main/cluster-template-topology-supervisor.yaml" "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/topology/cluster-template-topology-supervisor.yaml"
"$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/topology" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/cluster-template-topology-supervisor.yaml"
"$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/topology-autoscaler" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/cluster-template-topology-autoscaler-supervisor.yaml"
"$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/topology-runtimesdk" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/cluster-template-topology-runtimesdk-supervisor.yaml"
"$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/conformance" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/cluster-template-conformance-supervisor.yaml"
"$(KUSTOMIZE)" --load-restrictor LoadRestrictionsNone build "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/fast-rollout" > "$(E2E_SUPERVISOR_TEMPLATE_DIR)/main/cluster-template-fast-rollout-supervisor.yaml"
Expand Down
1 change: 1 addition & 0 deletions test/e2e/config/vsphere.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ providers:
- sourcePath: "../../../test/e2e/data/infrastructure-vsphere-govmomi/main/clusterclass-quick-start.yaml"
- sourcePath: "../../../test/e2e/data/infrastructure-vsphere-govmomi/main/clusterclass-quick-start-runtimesdk.yaml"
- sourcePath: "../../../test/e2e/data/infrastructure-vsphere-supervisor/main/cluster-template-topology-supervisor.yaml"
- sourcePath: "../../../test/e2e/data/infrastructure-vsphere-supervisor/main/cluster-template-topology-autoscaler-supervisor.yaml"
- sourcePath: "../../../test/e2e/data/infrastructure-vsphere-supervisor/main/cluster-template-topology-runtimesdk-supervisor.yaml"
- sourcePath: "../../../test/e2e/data/infrastructure-vsphere-supervisor/main/cluster-template-supervisor.yaml"
- sourcePath: "../../../test/e2e/data/infrastructure-vsphere-supervisor/main/clusterclass-quick-start-supervisor.yaml"
Expand Down
89 changes: 89 additions & 0 deletions test/e2e/data/autoscaler/autoscaler-to-management-workload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# This yaml deploys the autoscaler on a workload cluster and configures it to match
# against the corresponding Cluster API cluster which is defined into the management cluster.
---
# Specify kubeconfig for management cluster
apiVersion: v1
kind: Secret
metadata:
name: kubeconfig-management-cluster
namespace: ${CLUSTER_NAMESPACE}
stringData:
kubeconfig: |
apiVersion: v1
kind: Config
clusters:
- name: management-cluster
cluster:
certificate-authority-data: ${MANAGEMENT_CLUSTER_CA}
server: ${MANAGEMENT_CLUSTER_ADDRESS}
contexts:
- name: management-context
context:
cluster: management-cluster
namespace: ${CLUSTER_NAMESPACE}
user: cluster-autoscaler-sa
current-context: management-context
users:
- name: cluster-autoscaler-sa
user:
token: "${MANAGEMENT_CLUSTER_TOKEN}"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: cluster-autoscaler
namespace: ${CLUSTER_NAMESPACE}
labels:
app: cluster-autoscaler
spec:
selector:
matchLabels:
app: cluster-autoscaler
replicas: 1
template:
metadata:
labels:
app: cluster-autoscaler
spec:
containers:
- image: registry.k8s.io/autoscaling/cluster-autoscaler:${AUTOSCALER_VERSION}
name: cluster-autoscaler
command:
- /cluster-autoscaler
args:
- --cloud-provider=clusterapi
# Specify kubeconfig for management cluster
- --cloud-config=/management-cluster/kubeconfig
# Specify kubeconfig for workload cluster
- --kubeconfig=/workload-cluster/value
# Limit cluster autoscaler to only match against resources belonging to a single Cluster API cluster
- --node-group-auto-discovery=clusterapi:namespace=${CLUSTER_NAMESPACE},clusterName=${CLUSTER_NAME}
# Set a short scale down unneeded time, so we don't have to wait too long during e2e testing
- --scale-down-unneeded-time=1m
# Set a short scale down delay after add time, so we don't have to wait too long during e2e testing
- --scale-down-delay-after-add=1m
# Set a short scale down delay after delete time, so we don't have to wait too long during e2e testing
- --scale-down-delay-after-delete=1m
# Set a short scale down delay after failure time, so we don't have to wait too long during e2e testing
- --scale-down-delay-after-failure=1m
# Set a max nodes limit as safeguard so that the test does not scale up unbounded.
# Note: The E2E test should only go up to 4 (assuming it starts with a min node group size of 2).
# Using 6 for additional some buffer and to allow different starting min node group sizes.
- --max-nodes-total=6
volumeMounts:
- name: kubeconfig-management-cluster
mountPath: /management-cluster
readOnly: true
- name: kubeconfig-workload-cluster
mountPath: /workload-cluster
readOnly: true
terminationGracePeriodSeconds: 10
volumes:
- name: kubeconfig-management-cluster
secret:
secretName: kubeconfig-management-cluster
optional: false
- name: kubeconfig-workload-cluster
secret:
secretName: ${CLUSTER_NAME}-kubeconfig
optional: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- op: replace
path: /spec/topology/workers/machineDeployments/0/metadata
value:
annotations:
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "5"
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "2"
- op: remove
path: /spec/topology/workers/machineDeployments/0/replicas
value:
annotations:
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: "5"
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../topology
patches:
- target:
kind: Cluster
path: ./cluster-autoscaler.yaml

0 comments on commit 1caecef

Please sign in to comment.