nginx - Nginx Config.json 在 k8s 部署 Angular App 中挂载 ConfigMap
问题描述
我正在尝试将 ConfigMap 挂载到 Nginx 中,但是当我挂载 ConfigMap 时,我的 POD 无法启动并出现错误Error: container has runAsNonRoot and image will run as root
我的部署.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "fullname" . }}
namespace: {{ .Values.namespace }}
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app: {{ template "fullname" . }}
release: "{{ .Release.Name }}" # We dont need a large deployment history limit as Helm keeps it's own # history revisionHistoryLimit: 2 template:
metadata:
namespace: {{ .Values.namespace }}
labels:
app: {{ template "fullname" . }}
release: "{{ .Release.Name }}"
spec:
containers:
- name: container
image: {{ template "docker-image" . }}
lifecycle:
preStop:
exec:
command: ["sleep", "15"]
imagePullPolicy: Always
ports:
# The port that our container listens for HTTP requests on. Might also
# be 3000 or 8000
- containerPort: 8080
name: http
env:
# You can set environment variables that don't change across environments here
- name: ACTIVE_ENVIRONMENT
value: {{ .Values.environment }}
volumeMounts:
- name: msal-config-volume
mountPath: /etc/nginx/html/assets/config.json
subPath: config.json
readOnly: true
resources: {{ toYaml .Values.resources | indent 10 }}
imagePullSecrets:
- name: secret
volumes:
- name: msal-config-volume
configMap:
name: msal-configmap
我/etc/nginx/html/assets/
是我的人工部署,我试图config.json
从 ConfigMap 替换文件。当我安装msal-config-volume
吊舱时无法启动。
解决方案
推荐阅读
- pine-script - 如何在最后一个最高点和最后一个最低点之间画一条线?
- javascript - 将 JQuery append() 限制为父 div 的大小
- reactjs - 如何提及'@'提及与反应 webgifted 聊天的集成
- r - 复制重复观察的数量并生成一个新 ID,该 ID 根据计数值唯一标识观察
- php - 如何在帐户不活动 30 秒后自动注销
- wpf - 是否可以将 UpdateSourceTrigger 绑定到 DependencyProperty?
- javascript - Laravel 7 - 加载资源失败:服务器响应状态为 400(错误请求)
- reactjs - React Redux - 按 2 个参数对数组进行排序
- cookies - Magento 2:完全禁用最近查看和比较//禁用 Cookie 设置
- cordova - 更改不会反映到 apk