gpt4 book ai didi

kubernetes - kustomize、secretGenerator 和 patchStrategicMerge : envFrom. secretRef 未读取散列的 secret 名称

转载 作者:行者123 更新时间:2023-12-04 12:57:45 34 4
gpt4 key购买 nike

在我的 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也?
或者,将某些环境变量注入(inject)特定覆盖的部署的正确方法是什么?
这是为了发展。

我的文件结构是这样的:
❯ 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

最佳答案

这对我来说很好用 kustomize v3.8.4 .你能检查一下你的版本吗disableNameSuffixHash或许不是你设置的真实。
以下是我用来测试的 list :

➜  app.yaml  deployment.yaml  kustomization.yaml   my.env
应用程序.yaml
kind: Deployment
metadata:
name: app-deployment
spec:
template:
spec:
containers:
- name: server
envFrom:
- secretRef:
name: db-env
部署文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
和我的 kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

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

resources:
- deployment.yaml
结果如下:
apiVersion: v1
data:
ASD: MTIz
kind: Secret
metadata:
name: db-env-f5tt4gtd7d
type: Opaque
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: app-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx:1.14.2
name: nginx
ports:
- containerPort: 80
- envFrom:
- secretRef:
name: db-env-f5tt4gtd7d
name: server

关于kubernetes - kustomize、secretGenerator 和 patchStrategicMerge : envFrom. secretRef 未读取散列的 secret 名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64022055/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com