首页 > 解决方案 > Kubernetes Elasticsearch centos - 无法在 pod 中启动 nginx

问题描述

我在 kubernetes 中使用弹性搜索。我希望使用 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

我的尝试

码头工人文件 -

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 容器,所以我宁愿不使用它。

我怎样才能使这项工作?

标签: dockerelasticsearchnginxkubernetes

解决方案


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


推荐阅读