作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 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
最佳答案
这对我来说很好用 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/
在我的 kustomization.yaml我有: ... secretGenerator: - name: db-env behavior: create envs:
我是一名优秀的程序员,十分优秀!