kustomize,secretGenerator和修补程序策略合并:envFrom.secretRef不读取散列的秘密名称

问题描述

在我的kustomization.yaml中,我有:

...
secretGenerator:
  - name: db-env
    behavior: create
    envs:
      - my.env
patchesStrategicMerge:
  - app.yaml

然后在我的app.yaml(补丁)中,我有:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-deployment
spec:
  template:
    spec:
      containers:
        - name: server
          envFrom:
            - secretRef:
                name: db-env

当我尝试通过kustomize build k8s/development进行构建时,我退出了:

apiVersion: apps/v1
kind: Deployment
...
    spec:
      containers:
      - envFrom:
        - secretRef:
            name: db-env
        name: server

何时应该:

      - envFrom:
        - secretRef:
            name: db-env-4g95hhmhfc

如何获取secretGenerator的名称哈希也可以应用于patchesStrategicMerge

或者,将某些环境变量注入到特定叠加层的部署中的正确方法是什么?

这是为了发展。


我的文件结构如下:

❯ tree k8s
k8s
├── base
│   ├── app.yaml
│   └── kustomization.yaml
├── development
│   ├── app.yaml
│   ├── golinks.sql
│   ├── kustomization.yaml
│   ├── mariadb.yaml
│   ├── my.cnf
│   └── my.env
└── production
    ├── ingress.yaml
    └── kustomization.yaml

base/kustomization.yaml在哪里:

namespace: go-mpen
resources:
- app.yaml
images:
- name: server
  newName: reg/proj/server

development/kustomization.yaml是:

resources:
  - ../base
  - mariadb.yaml
configMapGenerator:
  - name: mariadb-config
    files:
      - my.cnf
  - name: initdb-config
    files:
      - golinks.sql  # TODO: can we mount this w/out a config file?
secretGenerator:
  - name: db-env
    behavior: create
    envs:
      - my.env
patchesStrategicMerge:
  - app.yaml

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)