【发布时间】:2021-10-08 13:21:44
【问题描述】:
我正在使用 OKD4,我正在尝试使用 ConfigMap 在我的 pod 中挂载 /etc/php.ini。 为此,我在我的项目中创建了以下 K8S 对象。
Configmap(之前为 Deployment 创建):
- apiVersion: v1
kind: ConfigMap
data:
php.ini: |-
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
metadata:
name: php-ini
部署对象:
- kind: Deployment
apiVersion: apps/v1
metadata:
name: privatebin
labels:
app: privatebin
spec:
replicas: 1
selector:
matchLabels:
app: privatebin
template:
metadata:
creationTimestamp: null
labels:
app: privatebin
deploymentconfig: privatebin
spec:
containers:
- name: privatebin
image: <my container registry>/privatebin:${IMAGE_TAG}
volumeMounts:
- name: config-volume
mountPath: php.ini
livenessProbe:
exec:
command:
- /bin/sh
- -c
- "[ -f /run/nginx.pid ] && ps -C nginx >/dev/null 2>&1 && ps -C php-fpm >/dev/null 2>&1"
initialDelaySeconds: 10
periodSeconds: 5
readinessProbe:
httpGet:
scheme: HTTP
path: /
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: "250m" # parameterize in tekton pipeline
memory: "368Mi" # parameterize in tekton pipeline, maybe using template
requests:
cpu: "100m" # parameterize in tekton pipeline, maybe using template
memory: "256Mi" # parameterize in tekton pipeline, maybe using template
securityContext:
runAsUser: 1000
fsGroup: 1000
fsGroupChangePolicy: "OnRootMismatch"
imagePullPolicy: Always
restartPolicy: Always
terminationGracePeriodSeconds: 30
volumes:
- name: config-volume
configMap:
name: php-ini
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
由于某种原因,我的 pod 丢失并且出现以下错误:
- lastTransitionTime: "2021-10-08T12:53:01Z" 上次更新时间:“2021-10-08T12:53:01Z” 消息:'pods“privatebin-55678c66c5-”被禁止:无法验证 任何安全上下文约束:[spec.containers[0].securityContext.runAsUser: 无效值:1000:必须在范围内:[1002460000, 1002469999] spec.volumes[0]: 无效值:“configMap”:不允许使用 configMap 卷]'
ReplicaSet 也会出现类似的错误: 地位: 条件:
- lastTransitionTime: "2021-10-08T12:53:01Z" 消息:'pods“privatebin-55678c66c5-”被禁止:无法验证 任何安全上下文约束:[spec.containers[0].securityContext.runAsUser: 无效值:1000:必须在范围内:[1002460000, 1002469999] spec.volumes[0]: 无效值:“configMap”:不允许使用 configMap 卷]'
为什么我不能挂载 ConfigMap?是因为Deployment中的Securitycontext吗?
提前致谢,
【问题讨论】:
标签: kubernetes openshift openshift-origin configmap