如何在EKS启动模板Bootstrap脚本中安装其他软件包?

发布于 2025-02-13 02:06:20 字数 1362 浏览 1 评论 0原文

我为我的EKS节点组启动模板提供了此Bootstrap脚本,并在一些命令中添加了尝试安装Apache。我尝试了一些变体,没有一个可以安装服务。如果我进入我的节点,我可以手动执行此操作,但是无法用脚本

bootstrap.sh

变化#1

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
set -ex
/etc/eks/bootstrap.sh ${cluster_name} \
  --container-runtime containerd

sudo su
yum update -y
yum install httpd -y
service httpd start

--==MYBOUNDARY==--

来完成它。变体#2

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
sudo su
yum update -y
yum install httpd -y
service httpd start
set -ex
/etc/eks/bootstrap.sh ${cluster_name} \
  --container-runtime containerd

--==MYBOUNDARY==--

变量#3

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
set -ex
/etc/eks/bootstrap.sh ${cluster_name} \
  --container-runtime containerd

--==MYBOUNDARY==--

#!/bin/bash
sudo su
yum update -y
yum install httpd -y
service httpd start

我也尝试过有没有sudo su,而这些都没有使用。似乎这些命令根本没有运行

I have this bootstrap script for my EKS node-group launch template and I added in some commands to try to install Apache. I tried a few variations and none would install the service. I'm able to do it manually if I ssh into my nodes, but haven't been able to accomplish it with my script

bootstrap.sh

Variation #1

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
set -ex
/etc/eks/bootstrap.sh ${cluster_name} \
  --container-runtime containerd

sudo su
yum update -y
yum install httpd -y
service httpd start

--==MYBOUNDARY==--

Variation #2

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
sudo su
yum update -y
yum install httpd -y
service httpd start
set -ex
/etc/eks/bootstrap.sh ${cluster_name} \
  --container-runtime containerd

--==MYBOUNDARY==--

Variation #3

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
set -ex
/etc/eks/bootstrap.sh ${cluster_name} \
  --container-runtime containerd

--==MYBOUNDARY==--

#!/bin/bash
sudo su
yum update -y
yum install httpd -y
service httpd start

I also tried with and without the sudo su and none of those worked either. Just seems like the commands aren't running at all

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九八野马 2025-02-20 02:06:20

我只是在启动模板的userData中使用以下代码。这从来都不是问题。

#!/bin/bash
/etc/eks/bootstrap.sh your_cluster_name_here
sudo adduser ssm-user
sudo usermod -a -G docker ssm-user
sudo adduser uua
sudo usermod -g wheel uua
sudo sed -i  's/^# %wheel/%wheel/' /etc/sudoers
sudo adduser uub

它在 ec2&gt下;启动模板> (您的启动模板)>详细信息>高级详细信息

屏幕快照参考
aws ec2 ec2启动模板用户数据

I simply used the below code in the userdata of the launch template & it was never a problem.

#!/bin/bash
/etc/eks/bootstrap.sh your_cluster_name_here
sudo adduser ssm-user
sudo usermod -a -G docker ssm-user
sudo adduser uua
sudo usermod -g wheel uua
sudo sed -i  's/^# %wheel/%wheel/' /etc/sudoers
sudo adduser uub

It's Under EC2 > Launch Templates > (your launch template) > Details > Advanced Details

Screenshot Reference
AWS EC2 Launch Template User Data

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文