docker - 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 容器,所以我宁愿不使用它。
我怎样才能使这项工作?
解决方案
容器是为运行单个应用程序而构建的。您应该为 nginx 代理使用一个单独的代理,为 Elasticsearch 使用另一个。
推荐阅读
- windows - SourceTree 不刷新文件更改和暂存状态 - windows
- ruby-on-rails - 将 CSV/Excel 文件导入 Ruby on Rails 时出错
- java - 数字(或)数字和逗号(或)数字的正则表达式 逗号和空格(或)数字逗号空格数字
- python-3.x - 查找所有程序,用python3 + gtk3编写,安装在我的linux系统上
- javascript - Javascript计算textarea中的剩余字符
- node.js - AWS Cloudfront + lambda@edge 修改 html 内容(使所有链接绝对 -> 相对)
- android - lateinit 属性 recyclerView 尚未初始化 Kotlin
- jenkins - Running Danger on Jenkins 跳过错误:Not a Jenkins Pull Request
- c# - C# regex - find one or more matches for a single pattern inside parentheses
- scala - 加特林请求未得到执行