我遵循ec2 run scripts every boot并针对每个实例尝试了相同的方法,但是我的脚本仍未执行。
我也遵循了Execute User Data After the Initial Launch of Your EC2 Instance,但是脚本没有执行。脚本内容:
pipeline {
agent any
environment {
............
stage('Deploy to K8s') {
steps{
echo 'Deployment started ...'
step([$class: 'KubernetesEngineBuilder', projectId: env.PROJECT_ID, clusterName: env.CLUSTER_NAME, location: env.LOCATION, manifestPattern: 'deployment.yaml', credentialsId: env.CREDENTIALS_ID, verifyDeployments: true])
echo "Deployment Finished ..."
}
}
}
}
为什么事实证明每次实例重新启动时都很难运行脚本?有人可以帮忙吗?
答案 0 :(得分:0)
如果您使用Amazon EC2 Linux实例在启动时运行批处理作业,只需在以下目录中安装脚本即可:
/var/lib/cloud/scripts/per-boot/
这将在安装了cloud-init的任何系统上运行,该系统也运行用户数据脚本。
有关更多详细信息,请参见:Auto-Stop EC2 instances when they finish a task - DEV Community