From d71a6b9700aff2d777ed6d03f00123cdd39ae2b9 Mon Sep 17 00:00:00 2001 From: mye956 Date: Fri, 28 Feb 2025 20:00:35 +0000 Subject: [PATCH 1/2] Modify amazon linux codebuil and spec file to include baking in the CSI driver tar file --- Makefile | 14 +++++++++++--- .../amazon-linux-ami-integrated/ecs-agent.spec | 12 ++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ad82e7e58dc..3dffe6e5d24 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,8 @@ endif export GO111MODULE=auto +VERSION = $(shell cat ecs-init/ECSVERSION) + all: docker # Dynamic go build; useful in that it does not have -a so it won't recompile @@ -315,6 +317,12 @@ EBS_CSI_DRIVER_DIR=./ecs-agent/daemonimages/csidriver ebs-csi-driver: $(MAKE) -C $(EBS_CSI_DRIVER_DIR) $(MFLAGS) bin/ebs-csi-driver +# This is used to build the EBS CSI driver tar files during ECS Init RPM builds via CodeBuild +ebs-csi-driver-codebuild: + $(MAKE) -C $(EBS_CSI_DRIVER_DIR) $(MFLAGS) tarfiles/ebs-csi-driver.tar + cp $(EBS_CSI_DRIVER_DIR)/tarfiles/ebs-csi-driver.tar ebs-csi-driver-v${VERSION}.tar + cp $(EBS_CSI_DRIVER_DIR)/tarfiles/ebs-csi-driver.tar ebs-csi-driver-arm64-v${VERSION}.tar + # Starts EBS CSI Driver as a background process. # The driver uses /tmp/ebs-csi-driver.sock as the socket file. start-ebs-csi-driver: ebs-csi-driver @@ -417,7 +425,7 @@ amazon-linux-sources.tgz: amazon-linux-rpm-integrated: .amazon-linux-rpm-integrated-done # Make target for Amazon Linux Codebuild jobs -.amazon-linux-rpm-codebuild-done: get-cni-sources +.amazon-linux-rpm-codebuild-done: get-cni-sources ebs-csi-driver-codebuild ./scripts/update-version.sh cp packaging/amazon-linux-ami-integrated/ecs-agent.spec ecs-agent.spec cp packaging/amazon-linux-ami-integrated/ecs.conf ecs.conf @@ -448,8 +456,6 @@ amazon-linux-rpm-codebuild: .amazon-linux-rpm-codebuild-done # Build init rpm generic-rpm-integrated: .generic-rpm-integrated-done -VERSION = $(shell cat ecs-init/ECSVERSION) - .generic-deb-integrated-done: get-cni-sources ./scripts/update-version.sh mkdir -p BUILDROOT @@ -513,6 +519,8 @@ clean: -rm -f .generic-rpm-integrated-done -rm -f amazon-ecs-volume-plugin -rm -rf $(EBS_CSI_DRIVER_DIR)/bin + -rm -rf $(EBS_CSI_DRIVER_DIR)/tarfiles + -rm -f ebs-csi-driver-*.tar -rm -rf /tmp/private-test-registry-htpasswd # private registry credentials cleanup clean-all: clean diff --git a/packaging/amazon-linux-ami-integrated/ecs-agent.spec b/packaging/amazon-linux-ami-integrated/ecs-agent.spec index 21f8f58a20f..3f1bf6c39fc 100644 --- a/packaging/amazon-linux-ami-integrated/ecs-agent.spec +++ b/packaging/amazon-linux-ami-integrated/ecs-agent.spec @@ -24,6 +24,7 @@ %global no_exec_perm 644 %global debug_package %{nil} %global agent_image ecs-agent-v%{version}.tar +%global ebs_csi_driver_dir /var/lib/ecs/deps/daemons/ebs-csi-driver Name: ecs-init Version: 1.91.0 @@ -38,6 +39,8 @@ Source2: ecs.service Source3: amazon-ecs-volume-plugin.service Source4: amazon-ecs-volume-plugin.socket Source5: amazon-ecs-volume-plugin.conf +Source6: ebs-csi-driver-arm64-v%{version}.tar +Source7: ebs-csi-driver-v%{version}.tar BuildRequires: golang >= 1.22.0 %if %{with systemd} @@ -171,6 +174,13 @@ mkdir -p %{buildroot}%{_sysconfdir}/ecs touch %{buildroot}%{_sysconfdir}/ecs/ecs.config touch %{buildroot}%{_sysconfdir}/ecs/ecs.config.json +mkdir -p %{buildroot}%{ebs_csi_driver_dir} +%ifarch aarch64 +install -m %{no_exec_perm} -D %{SOURCE6} %{buildroot}%{ebs_csi_driver_dir}/ebs-csi-driver.tar +%else +install -m %{no_exec_perm} -D %{SOURCE7} %{buildroot}%{ebs_csi_driver_dir}/ebs-csi-driver.tar +%endif + # Configure ecs-init to reload the bundled ECS container agent image. mkdir -p %{buildroot}%{_cachedir}/ecs echo 2 > %{buildroot}%{_cachedir}/ecs/state @@ -198,6 +208,8 @@ install -m %{no_exec_perm} -D %{SOURCE5} %{buildroot}%{_sysconfdir}/init/amazon- %{_cachedir}/ecs/%{basename:%{agent_image}} %{_cachedir}/ecs/state %dir %{_sharedstatedir}/ecs/data +%dir %{ebs_csi_driver_dir} +%{ebs_csi_driver_dir}/ebs-csi-driver.tar %if %{with systemd} %{_unitdir}/ecs.service From 916a38fce333a4511bc34e8f7f03c66290eb3ca8 Mon Sep 17 00:00:00 2001 From: Prateek Chaudhry Date: Mon, 10 Mar 2025 20:39:11 +0000 Subject: [PATCH 2/2] update csi driver base image to al2023 --- ecs-agent/daemonimages/csidriver/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecs-agent/daemonimages/csidriver/Dockerfile b/ecs-agent/daemonimages/csidriver/Dockerfile index 703fd053791..9acb89d6140 100644 --- a/ecs-agent/daemonimages/csidriver/Dockerfile +++ b/ecs-agent/daemonimages/csidriver/Dockerfile @@ -20,7 +20,7 @@ ADD . /go/src/ RUN make bin/ebs-csi-driver # use minimal eks base for csi driver image to add required mount utils -FROM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-csi-ebs:latest-al2 +FROM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-csi-ebs:latest-al23 MAINTAINER Amazon Web Services, Inc. COPY --from=build /go/src/bin/ebs-csi-driver /bin/ebs-csi-driver