Skip to content

Commit 2323aa7

Browse files
committed
e2e: updated EKS environment
1 parent 6e3bdb3 commit 2323aa7

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

  • stackgres-k8s/e2e/envs

stackgres-k8s/e2e/envs/eks

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ K8S_EKS_NODES="${K8S_EKS_NODES:-1}"
77
K8S_EKS_DISK_SIZE="${K8S_EKS_DISK_SIZE:-20}"
88
K8S_EKS_USE_SPOT="${K8S_EKS_USE_SPOT:-true}"
99
K8S_EKS_OPTS="$K8S_EKS_OPTS"
10+
EKSCTL=eksctl
11+
EKSCTL_0_210_0=eksctl-0.210.0
1012
EKS_EXPANDABLE_STORAGE_CLASSNAME="${EXPANDABLE_STORAGE_CLASSNAME:-expandable-sc}"
1113

1214
export K8S_EKS_NAME K8S_VERSION K8S_EKS_REGION K8S_EKS_NODE_LOCATIONS K8S_EKS_NODE_TYPE K8S_EKS_OPTS
@@ -16,7 +18,30 @@ get_k8s_env_version() {
1618
echo
1719
}
1820

21+
check_eks_version() {
22+
if [ "$(echo "$K8S_VERSION" | tr . '\n' | head -n 2 | xargs -I @ printf '%05d' @)" \
23+
-ge "$(echo "1.31" | tr . '\n' | xargs -I @ printf '%05d' @)" ]
24+
then
25+
if ! "$EKSCTL" version | grep -q -F '0.210.0'
26+
then
27+
EKSCTL="$EKSCTL_0_210_0"
28+
fi
29+
if ! "$EKSCTL" version | grep -q -F '0.210.0'
30+
then
31+
echo "$PATH"
32+
echo "To run Kubernetes 1.31+ eksctl 0.210.0 is required"
33+
return 1
34+
fi
35+
else
36+
if ! command -v "$EKSCTL" > /dev/null
37+
then
38+
return 1
39+
fi
40+
fi
41+
}
42+
1943
reuse_k8s() {
44+
check_eks_version
2045
if ! eksctl get cluster --name "$K8S_EKS_NAME" --region "$K8S_EKS_REGION" 2>&1 \
2146
| grep "^$K8S_EKS_NAME" | grep -q "ACTIVE"
2247
then
@@ -35,7 +60,12 @@ reuse_k8s() {
3560
create_and_use_cluster_admin_fast() {
3661
kubectl create sa cluster-admin-fast 2>/dev/null || true
3762
kubectl create clusterrolebinding cluster-admin-fast --clusterrole=cluster-admin --serviceaccount=default:cluster-admin-fast 2>/dev/null || true
38-
SECRET="$(kubectl get sa cluster-admin-fast -o json | jq -r '.secrets[].name')"
63+
if ! SECRET="$(kubectl get sa cluster-admin-fast -o json | jq -r '.secrets[].name' 2>/dev/null)"
64+
then
65+
SECRET=cluster-admin-fast
66+
kubectl create secret generic --type=kubernetes.io/service-account-token cluster-admin-fast 2>/dev/null || true
67+
kubectl annotate secret cluster-admin-fast kubernetes.io/service-account.name=cluster-admin-fast 2>/dev/null || true
68+
fi
3969
kubectl get secret "$SECRET" -o json | jq -r '.data["ca.crt"]' | base64 -d > "$TARGET_PATH/eks-ca.crt"
4070
USER_TOKEN=$(kubectl get secret "$SECRET" -o json | jq -r '.data["token"]' | base64 -d)
4171
CURRENT_CONTEXT="$(kubectl config current-context)"
@@ -57,6 +87,8 @@ create_and_use_cluster_admin_fast() {
5787
}
5888

5989
reset_k8s() {
90+
check_eks_version
91+
6092
echo "Setting up eks environment $K8S_EKS_NAME..."
6193

6294
delete_k8s
@@ -67,12 +99,15 @@ reset_k8s() {
6799
--node-type "$K8S_EKS_NODE_TYPE" \
68100
--node-volume-size "$K8S_EKS_DISK_SIZE" \
69101
--nodes "$K8S_EKS_NODES" \
70-
--version "$(printf %s "$K8S_VERSION" | cut -d . -f 1-2)"
102+
--version "$(printf %s "$K8S_VERSION" | cut -d . -f 1-2)" \
103+
$K8S_EKS_OPTS
71104

72105
echo "...done"
73106
}
74107

75108
delete_k8s() {
109+
check_eks_version
110+
76111
echo "Checking if eks environment $K8S_EKS_NAME exists"
77112

78113
if eksctl get cluster --name "$K8S_EKS_NAME" --region "$K8S_EKS_REGION" 2>&1 \
@@ -136,6 +171,7 @@ excluded_clusterrolebindings() {
136171
echo "aws-node"
137172
echo "eks:.*"
138173
echo "vpc-resource-controller-rolebinding"
174+
echo "metrics-server:system:auth-delegator"
139175
}
140176

141177

0 commit comments

Comments
 (0)