Skip to content

Commit 34ff97d

Browse files
committed
Add test scenario for Karpenter
1 parent 27ca469 commit 34ff97d

File tree

2 files changed

+123
-4
lines changed

2 files changed

+123
-4
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
REPO_ROOT=$(git rev-parse --show-toplevel);
18+
source "${REPO_ROOT}"/tests/e2e/scenarios/lib/common.sh
19+
20+
kops-acquire-latest
21+
22+
NETWORKING=cilium
23+
OVERRIDES="${OVERRIDES-} --instance-manager=karpenter"
24+
OVERRIDES="${OVERRIDES} --control-plane-size=c6g.large"
25+
26+
kops-up
27+
28+
USER_DATA=$(aws s3 cp "${KOPS_STATE_STORE-}/${CLUSTER_NAME}/igconfig/node/nodes/nodeupscript.sh" -)
29+
export USER_DATA
30+
31+
kubectl apply -f - <<YAML
32+
apiVersion: karpenter.k8s.aws/v1
33+
kind: EC2NodeClass
34+
metadata:
35+
name: default
36+
spec:
37+
amiFamily: Custom
38+
amiSelectorTerms:
39+
- ssmParameter: /aws/service/canonical/ubuntu/server/24.04/stable/current/arm64/hvm/ebs-gp3/ami-id
40+
associatePublicIPAddress: true
41+
tags:
42+
KubernetesCluster: ${CLUSTER_NAME}
43+
kops.k8s.io/instancegroup: nodes
44+
k8s.io/role/node: "1"
45+
subnetSelectorTerms:
46+
- tags:
47+
KubernetesCluster: ${CLUSTER_NAME}
48+
securityGroupSelectorTerms:
49+
- tags:
50+
KubernetesCluster: ${CLUSTER_NAME}
51+
Name: nodes.${CLUSTER_NAME}
52+
instanceProfile: nodes.${CLUSTER_NAME}
53+
userData: |
54+
$(echo "$USER_DATA" | sed 's/^/ /')
55+
YAML
56+
57+
kubectl apply -f - <<YAML
58+
apiVersion: karpenter.sh/v1
59+
kind: NodePool
60+
metadata:
61+
name: default
62+
spec:
63+
template:
64+
spec:
65+
requirements:
66+
- key: node.kubernetes.io/instance-type
67+
operator: In
68+
values: ["m6g.large"]
69+
- key: karpenter.sh/capacity-type
70+
operator: In
71+
values: ["on-demand"]
72+
nodeClassRef:
73+
group: karpenter.k8s.aws
74+
kind: EC2NodeClass
75+
name: default
76+
limits:
77+
cpu: 10
78+
disruption:
79+
consolidationPolicy: WhenEmpty
80+
consolidateAfter: 30m
81+
YAML
82+
83+
kubectl apply -f - <<YAML
84+
apiVersion: apps/v1
85+
kind: Deployment
86+
metadata:
87+
name: node-hold
88+
spec:
89+
replicas: 2
90+
selector:
91+
matchLabels:
92+
app: node-hold
93+
template:
94+
metadata:
95+
labels:
96+
app: node-hold
97+
spec:
98+
topologySpreadConstraints:
99+
- maxSkew: 1
100+
topologyKey: kubernetes.io/hostname
101+
whenUnsatisfiable: DoNotSchedule
102+
labelSelector:
103+
matchLabels:
104+
app: node-hold
105+
containers:
106+
- name: pause
107+
image: registry.k8s.io/pause:3.10.1
108+
YAML
109+
110+
sleep 30
111+
"${KOPS}" validate cluster --wait=10m
112+
113+
cp "${KOPS}" "${WORKSPACE}/kops"
114+
${KUBETEST2} \
115+
--test=kops \
116+
--kops-binary-path="${KOPS}" \
117+
-- \
118+
--test-package-version="${K8S_VERSION}" \
119+
--focus-regex="\[Conformance\]" \
120+
--parallel 20

tests/e2e/scenarios/lib/common.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ if [[ -z "${DISCOVERY_STORE-}" ]]; then
4545
DISCOVERY_STORE="${KOPS_STATE_STORE-}"
4646
fi
4747

48-
export GO111MODULE=on
49-
5048
if [[ -z "${AWS_SSH_PRIVATE_KEY_FILE-}" ]]; then
5149
export AWS_SSH_PRIVATE_KEY_FILE="${HOME}/.ssh/id_rsa"
5250
fi
@@ -55,8 +53,9 @@ if [[ -z "${AWS_SSH_PUBLIC_KEY_FILE-}" ]]; then
5553
fi
5654

5755
KUBETEST2="kubetest2 kops -v=2 --cloud-provider=${CLOUD_PROVIDER} --cluster-name=${CLUSTER_NAME:-} --kops-root=${REPO_ROOT}"
58-
KUBETEST2="${KUBETEST2} --admin-access=${ADMIN_ACCESS:-}"
59-
56+
if [[ -n "${ADMIN_ACCESS-}" ]]; then
57+
KUBETEST2="${KUBETEST2} --admin-access=${ADMIN_ACCESS}"
58+
fi
6059
if [[ -n "${GCP_PROJECT-}" ]]; then
6160
KUBETEST2="${KUBETEST2} --gcp-project=${GCP_PROJECT}"
6261
fi

0 commit comments

Comments
 (0)