Sar*_*ana 5 containers docker kubernetes amazon-eks
我正在 AWS EKS 上运行集群。当前运行的容器(StatefulSet POD)内部安装了 Docker。
我在我的集群中将这个镜像作为 Kubernetes StatefulSet 运行。这是我的 yaml 文件,
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: jenkins
labels:
run: jenkins
spec:
serviceName: jenkins
replicas: 1
selector:
matchLabels:
run: jenkins
template:
metadata:
labels:
run: jenkins
spec:
securityContext:
fsGroup: 1000
containers:
- name: jenkins
image: 99*****.dkr.ecr.<region>.amazonaws.com/<my_jenkins_image>:0.0.3
imagePullPolicy: Always
ports:
- containerPort: 8080
name: jenkins-port
Run Code Online (Sandbox Code Playgroud)
在这个 POD 中,我无法运行任何给出错误的 docker 命令:
/etc/init.d/docker: 96: ulimit: error setting limit (Operation not allowed)
在我的研究中,我浏览了一些没有解决我的问题的文章。我已经列出了我尝试过但在我的情况下没有修复的解决方案
第一个解决方案:(我在容器内跑) aricle链接
$ sudo service docker stop
$ sudo bash -c "echo \"limit nofile 262144 262144\" >> /etc/init/docker.conf"
$ sudo service docker start
Run Code Online (Sandbox Code Playgroud)
第二种解决方案:(我在容器内跑了)
ulimit -n 65536 in /etc/init.d/docker
Run Code Online (Sandbox Code Playgroud)
第三个解决方案:**文章链接 这似乎是一个更好的答案,我无法将其添加到我的配置文件中。它说,以特权运行 pod。但是无法在 ***Kubernetes StatefulSet* 中添加该选项。所以我尝试在配置文件中添加这样的 SecurityContext (securityContext:fsGroup: 1000),
spec:
serviceName: jenkins
replicas: 1
selector:
matchLabels:
run: jenkins
template:
metadata:
labels:
run: jenkins
spec:
securityContext:
fsGroup: 1000
Run Code Online (Sandbox Code Playgroud)
还是不行。
注意:相同的图像适用于 Docker swarm
任何帮助,将不胜感激!
我在使用 Elastic Search 时遇到了这个问题,并且添加initContainer
有效。在这种情况下,解决方案可能是:
spec:
.
.
.
initContainers:
- name: increase-fd-ulimit
image: busybox
command: ["sh", "-c", "ulimit -n 65536"]
securityContext:
privileged: true
Run Code Online (Sandbox Code Playgroud)
如果它不起作用,还有第二种方法可以解决此问题,包括创建新的 Dockerfile 或更改现有的:
FROM 99*****.dkr.ecr.<region>.amazonaws.com/<my_jenkins_image>:0.0.3
RUN ulimit -n 65536
USER 1000
Run Code Online (Sandbox Code Playgroud)
并将 securityContext 更改为:
securityContext:
runAsNonRoot: true
runAsUser: 1000
capabilities:
add: ["IPC_LOCK"]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6165 次 |
最近记录: |