对于带有 java 应用程序的 pod,有安全上下文:
spec:
securityContext:
runAsUser: 888
runAsGroup: 888
fsGroup: 888
部署清单:
apiVersion: apps/v1
kind: Deployment
metadata:
name: springboot-demo
spec:
replicas: 1
selector:
matchLabels:
app: springboot-demo
template:
metadata:
labels:
app: springboot-demo
spec:
securityContext:
runAsUser: 888
runAsGroup: 888
containers:
- name: springboot-demo
image: k8s.192.168.20.15.nip.io:5443/springboot-demo:8.0.0
resources:
limits:
memory: "1024Mi"
cpu: "1000m"
ports:
- containerPort: 9000
---
apiVersion: v1
kind: Service
metadata:
name: springboot-demo
spec:
type: NodePort
selector:
app: springboot-demo
ports:
- port: 9000
targetPort: 9000
如果我进入容器并运行
jcmd GC.heap_dump
-> 权限被拒绝 pic 1
如果我以 root 身份输入并运行
jcmd GC.heap_dump
-> 无法打开套接字文件 /proc/1/root/tmp/.java_pid1 ... pic2
如果我删除安全上下文并运行 jcmd GC.heap_dump -> 它可以正常工作。
可能是什么问题呢?