繁体   English   中英

Kubernetes Elasticsearch centos - 无法在 pod 中启动 nginx

[英]Kubernetes Elasticsearch centos - unable to start nginx in the pod

我在 kubernetes 中使用 elasticsearch。 我希望使用 nginx 添加另一层保护。

当我尝试使用systemctl start nginx运行 nginx systemctl start nginx我得到:

Failed to get D-Bus connection: Operation not permitted

这似乎是centos一个已知问题,因为它的 docker 发行版没有完整的systemd

遵循centos指南对我不起作用:

https://hub.docker.com/_/centos请参阅Dockerfile for systemd base image部分

我的尝试

Docker 文件 -

FROM docker.elastic.co/elasticsearch/elasticsearch:7.6.1


ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]

# Install gcs plugin
RUN bin/elasticsearch-plugin install --batch repository-gcs

# install nginx
RUN yum install -y epel-release
RUN yum install -y nginx

# Copy configuration
COPY my-config.conf /etc/nginx/sites-enabled/my-config.conf


CMD ["/usr/sbin/init"]

还尝试在 kubernetes yaml 中添加 docker 参数 -

args:
  ["--tmpfs", "/run", "-v", "/sys/fs/cgroup:/sys/fs/cgroup:ro"]

或者

["-ti", "-v", "/sys/fs/cgroup:/sys/fs/cgroup:ro", "-v", "/tmp/$(mktemp -d):/run"]

这些都没有帮助。

看到这个问题,但没有很多答案似乎工作,例如: https://serverfault.com/questions/824975/failed-to-get-d-bus-connection-operation-not-permitted https://开头github上。 com/CentOS/sig-cloud-instance-images/issues/45#issuecomment-363709254

出于安全原因,不推荐使用特权 docker 容器,所以我宁愿不使用它。

我怎样才能使这项工作?

容器是为运行单个应用程序而构建的。 您应该为 nginx 代理使用一个单独的代理,而为 Elasticsearch 使用另一个。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM