我想运行shell脚本,它使用kubernetes中的cron作业在文件中包含ssh命令。
test.sh
#!/bin/bash
echo copying files from edge node to batch pods;
ssh -q userid@<hostname>"kubectl config use-context testnamespace";
ssh -q userid@<hostname>"kubectl scale statefulsets testpod --replicas=1";当我手动执行它时,它会抛出错误"ssh command not found",并触发作业抛给我permission denied消息。
有人能帮我解决这个问题吗。
发布于 2020-02-27 09:13:13
此消息(ssh command not found)表示您的pod中缺少ssh客户端。在注释中,您提到的是停靠者,所以我假设您使用的是您的对接图像。
要在您的docker容器中安装SSH,您必须根据我们的Linux发行版运行apt或yum或任何其他包管理器,这需要在您的Dockerfile中表示。
以下是如何实现这一目标的示例:
# A basic apache server. To use either add or bind mount content under /var/www
FROM ubuntu:12.04
MAINTAINER Kimbro Staken version: 0.1
RUN apt-get update && apt-get install -y apache2 && apt-get clean && rm -rf /var/lib/apt/lists/*
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]在本例中,我们在ubuntu映像上安装apache。在您的场景中,您需要运行类似于以下内容的内容:
RUN apt-get update && apt-get install -y openssh-client && apt-get clean && rm -rf /var/lib/apt/lists/*https://stackoverflow.com/questions/60319820
复制相似问题