Skip to content

Commit b64d83d

Browse files
author
AidanAbd
committed
fix: port over
1 parent 6449d5b commit b64d83d

File tree

4 files changed

+100
-5
lines changed

4 files changed

+100
-5
lines changed

bootstrap.sh.patch

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
--- bootstrap.sh 2024-04-08 15:32:39
2-
+++ patched_bootstrap.sh 2024-04-08 15:36:38
1+
--- bootstrap.sh 2025-02-11 13:09:53
2+
+++ patched_bootstrap.sh 2025-02-11 13:23:06
33
@@ -150,7 +150,7 @@
44
API_RETRY_ATTEMPTS="${API_RETRY_ATTEMPTS:-3}"
55
DOCKER_CONFIG_JSON="${DOCKER_CONFIG_JSON:-}"
@@ -9,7 +9,45 @@
99
CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-$DEFAULT_CONTAINER_RUNTIME}"
1010
# from >= 1.27, the cloud-provider will be external
1111
CLOUD_PROVIDER="external"
12-
@@ -426,17 +426,28 @@
12+
@@ -295,11 +295,15 @@
13+
--region=${AWS_DEFAULT_REGION} \
14+
--name=${CLUSTER_NAME}
15+
16+
+ # Switch to JSON output to avoid "NoneType" flush bug in text mode.
17+
+ # Then parse the required fields with jq, output them on a single line.
18+
aws eks describe-cluster \
19+
--region=${AWS_DEFAULT_REGION} \
20+
--name=${CLUSTER_NAME} \
21+
- --output=text \
22+
- --query 'cluster.{certificateAuthorityData: certificateAuthority.data, endpoint: endpoint, serviceIpv4Cidr: kubernetesNetworkConfig.serviceIpv4Cidr, serviceIpv6Cidr: kubernetesNetworkConfig.serviceIpv6Cidr, clusterIpFamily: kubernetesNetworkConfig.ipFamily}' > $DESCRIBE_CLUSTER_RESULT || rc=$?
23+
+ --output=json \
24+
+ | jq -r '.cluster | "\( .certificateAuthority.data ) \( .endpoint ) \( .kubernetesNetworkConfig.serviceIpv4Cidr ) \( .kubernetesNetworkConfig.serviceIpv6Cidr ) \( .kubernetesNetworkConfig.ipFamily )"' \
25+
+ > $DESCRIBE_CLUSTER_RESULT || rc=$?
26+
+
27+
if [[ $rc -eq 0 ]]; then
28+
break
29+
fi
30+
@@ -310,13 +314,14 @@
31+
sleep_sec="$(( $(( 5 << $((1+$attempt)) )) + $jitter))"
32+
sleep $sleep_sec
33+
done
34+
- B64_CLUSTER_CA=$(cat $DESCRIBE_CLUSTER_RESULT | awk '{print $1}')
35+
- APISERVER_ENDPOINT=$(cat $DESCRIBE_CLUSTER_RESULT | awk '{print $3}')
36+
- SERVICE_IPV4_CIDR=$(cat $DESCRIBE_CLUSTER_RESULT | awk '{print $4}')
37+
- SERVICE_IPV6_CIDR=$(cat $DESCRIBE_CLUSTER_RESULT | awk '{print $5}')
38+
39+
+ # Our jq line puts five fields on one line. Re-map them accordingly.
40+
+ B64_CLUSTER_CA="$(awk '{print $1}' $DESCRIBE_CLUSTER_RESULT)"
41+
+ APISERVER_ENDPOINT="$(awk '{print $2}' $DESCRIBE_CLUSTER_RESULT)"
42+
+ SERVICE_IPV4_CIDR="$(awk '{print $3}' $DESCRIBE_CLUSTER_RESULT)"
43+
+ SERVICE_IPV6_CIDR="$(awk '{print $4}' $DESCRIBE_CLUSTER_RESULT)"
44+
if [[ -z "${IP_FAMILY}" ]]; then
45+
- IP_FAMILY=$(cat $DESCRIBE_CLUSTER_RESULT | awk '{print $2}')
46+
+ IP_FAMILY="$(awk '{print $5}' $DESCRIBE_CLUSTER_RESULT)"
47+
fi
48+
fi
49+
50+
@@ -434,17 +439,28 @@
1351
systemctl restart docker
1452
snap set kubelet-eks \
1553
container-runtime=docker
@@ -25,7 +63,7 @@
2563
+ --file /etc/crio/crio.conf \
2664
+ --selector 'crio.image.pause_image' \
2765
+ "${PAUSE_CONTAINER}"
28-
66+
2967
elif [[ "$CONTAINER_RUNTIME" = "nvidia-container-runtime" ]]; then
3068
- echo "Container runtime is ${CONTAINER_RUNTIME}"
3169
- # update config.toml file
@@ -37,7 +75,7 @@
3775
+ # see https://github.com/NVIDIA/k8s-device-plugin
3876
+ cp /usr/local/share/eks/nvidia-runtime-config.toml /etc/containerd/config.toml
3977
+ systemctl restart containerd
40-
78+
4179
else
4280
- echo "Container runtime ${CONTAINER_RUNTIME} is not supported."
4381
- exit 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Unit]
2+
Requires=dev-ec2imds.device
3+
After=dev-ec2imds.device

sysbox-eks.pkr.hcl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,4 +507,51 @@ build {
507507
"echo 'label ::/0 100' | sudo tee -a /etc/gai.conf"
508508
]
509509
}
510+
511+
provisioner "file" {
512+
source = "cloud-init-local.service.d/10-wait-for-net-device.conf"
513+
destination = "/home/ubuntu/10-wait-for-net-device.conf"
514+
}
515+
516+
provisioner "file" {
517+
source = "udev/10-ec2imds.rules"
518+
destination = "/home/ubuntu/10-ec2imds.rules"
519+
}
520+
521+
provisioner "shell" {
522+
inline_shebang = "/usr/bin/env bash"
523+
inline = [
524+
"set -o pipefail -o errexit",
525+
"",
526+
"echo '>>> Installing cloud-init network device wait configuration'",
527+
"sudo mkdir -p /etc/systemd/system/cloud-init-local.service.d",
528+
"sudo mv /home/ubuntu/10-wait-for-net-device.conf /etc/systemd/system/cloud-init-local.service.d/",
529+
"",
530+
"sudo mkdir -p /etc/udev/rules.d",
531+
"sudo mv /home/ubuntu/10-ec2imds.rules /etc/udev/rules.d/",
532+
"",
533+
"sudo systemctl daemon-reload"
534+
]
535+
}
536+
537+
provisioner "shell" {
538+
inline_shebang = "/usr/bin/env bash"
539+
inline = [
540+
"set -o pipefail -o errexit",
541+
542+
"echo '>>> Configuring KVM support'",
543+
"sudo modprobe kvm",
544+
545+
"echo 'kvm' | sudo tee -a /etc/modules",
546+
547+
"sudo dasel put string --parser toml --file /etc/crio/crio.conf --selector 'crio.runtime.allowed_devices.[]' --multiple /dev/kvm",
548+
549+
"sudo systemctl restart crio",
550+
551+
# configure /dev/kvm perms to allow containers to r/w to it
552+
"echo 'KERNEL==\"kvm\", MODE=\"0666\"' | sudo tee /etc/udev/rules.d/99-kvm-permissions.rules > /dev/null",
553+
"sudo udevadm control --reload-rules",
554+
"sudo udevadm trigger"
555+
]
556+
}
510557
}

udev/10-ec2imds.rules

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# cloud-init-local must wait for at least one network interface device to exist
2+
# before attempting to download EC2 instance metadata.
3+
#
4+
# These udev rules implement this policy along with
5+
# /etc/systemd/system/cloud-init.local.service.d/10-wait-for-net-device.conf
6+
7+
ACTION!="remove", SUBSYSTEM=="net", KERNEL!="lo", DRIVERS=="ena|vif", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/dev/ec2imds"

0 commit comments

Comments
 (0)