所以,我有一个如下所示的 yaml 文件:
service:
users:
- username: some-user
password: some-pass (would be placed in Secret)
- username: some-user
password: some-pass (would be placed in Secret)
Run Code Online (Sandbox Code Playgroud)
我需要将它添加到 env 中(在 spring boot 的优先级列表中,env 中的配置高于 yaml 中的配置。这将是基于 env(dev,stage,live) 的)。我已经用 Kustomize 尝试过这个
configMapGenerator:
- name: my-java-server-props
files:
- config.yaml
Run Code Online (Sandbox Code Playgroud)
然后在部署中使用它
envFrom:
- configMapRef:
name: my-java-server-props
Run Code Online (Sandbox Code Playgroud)
config.yml 中的其他配置如下:
spring:
datasource:
url: some-url-here
Run Code Online (Sandbox Code Playgroud)
然后添加到 configMapGenerator 的 .properties 文件中,如下所示:
spring_datasource_url=some-url-here
Run Code Online (Sandbox Code Playgroud)
但数组的配置似乎不起作用。
关于我在哪里错过了这个技巧的任何提示吗?另外,密码来自credstash;因此,我有一个不同的脚本,它从 credstash 获取值并为 Secret 创建清单。
添加密码的最终目标在部署中是这样的:
name: service_users.0.password
valueFrom:
secretKeyRef:
key: value
name: service-user-store-password
Run Code Online (Sandbox Code Playgroud) 我有一个覆盖kustomization.yaml如下:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../base/
patches:
- patch.yaml
secretGenerator:
- name: my-secrets
env: password.env
Run Code Online (Sandbox Code Playgroud)
当像嵌入一样应用它时,kustomize它工作得很好,但现在我需要在应用它之前生成最终的 yaml,所以当我尝试使用它自己时,我收到此错误:kubectlkubectl -kkustomize build devops/kustomize/my-cluster/overlay/local > local.yaml
Error: json: unknown field "env"
Run Code Online (Sandbox Code Playgroud)
secretGeneratorspec 有env参数,所以我不确定我做错了什么。
对于 Kubernetes 部署,给定一个 Kustomize Base,例如:
\napiVersion: kustomize.config.k8s.io/v1beta1\nkind: Kustomization\n...\nimages:\n - name: developmentregistry.com/myimage:v1.0\nRun Code Online (Sandbox Code Playgroud)\n有没有办法只更改图像注册表并保留带有覆盖的 og 标签,而无需使用图像转换器重新声明图像?
\n例如,如果我使用如下叠加:
\napiVersion: kustomize.config.k8s.io/v1beta1\nkind: Kustomization\n...\nimages:\n - newName: productionregistry.com/myimage\nRun Code Online (Sandbox Code Playgroud)\n该图像仅部署为productionregistry.com/myimage\xe2\x80\x94 这不是我想要的。
\n我怎样才能让我的覆盖部署产生效果productionregistry.com/myimage:v1.0?我找不到任何其他帖子或与此相关的任何问题。
\n我必须使用补丁而不是图像转换器吗?
我有以下pv.yamlKubernetes/Kustomization 文件:
apiVersion: v1
kind: PersistentVolume
metadata:
name: myapp-common-pv
namespace: myapp
labels:
app.kubernetes.io/name: myapp-common-pv
app.kubernetes.io/component: common-pv
app.kubernetes.io/part-of: myapp
spec:
capacity:
storage: 30Gi
accessModes:
- ReadWriteMany
nfs:
path: /myapp_nfs_share
server: <omitted for security purposes>
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: myapp-common-pvc
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
volumeName: myapp-common-pv
resources:
requests:
storage: 30gi
Run Code Online (Sandbox Code Playgroud)
当我运行这个时,我得到:
persistentvolume/myapp-common-pv unchanged
Error from server (BadRequest): error when creating "/Users/myuser/workspace/myapp/k8s/pv": PersistentVolumeClaim in version "v1" cannot be handled as a PersistentVolumeClaim: v1.PersistentVolumeClaim.Spec: v1.PersistentVolumeClaimSpec.StorageClassName: Resources: v1.ResourceRequirements.Requests: …Run Code Online (Sandbox Code Playgroud) kubernetes persistent-volumes persistent-volume-claims kustomize
我正在尝试使用ArgoCD和Kustomize配置Bitnami SealedSecrets。
我已成功使用 kubeseal CLI 对机密进行加密,这些机密已作为密封机密部署在 Kubernetes 集群上,并且可以通过集群上运行的密封机密控制器来解封。未密封的 Secret 包含预期值。我已经使用 Kustomize Secret Generators 定义了秘密 - 如本教程中所述:使用 Kustomize 密封秘密。这也工作正常,因为 ArgoCD 认识到应该生成 Secret。
但是,ArgoCD 希望机密为空,因为它们在应用程序的 kustomization.yaml 的 Secret Generator 部分中被定义为空:
secretGenerator:
- name: secret1
type: Opaque
- name: secret2
type: Opaque
- name: secret3
type: Opaque
...
Run Code Online (Sandbox Code Playgroud)
由于 ArgoCD 期望秘密为空,因此在密封秘密控制器解封并解密秘密后,它们被检测为“不同步”:
由于 ArgoCD 认为秘密应该为空,因此这些秘密被替换为空秘密。然后,Sealed Secrets Operator 再次更新 Secret,并用解密的数据填充数据字段 - 导致 ArgoCD 同步的无限循环。
这些秘密被标记为由 Bitnami Sealed Secrets 使用注释进行管理sealedsecrets.bitnami.com/managed: "true"。因此,它们正在由“密封的秘密”控制器进行更新。
我如何更改清单以确保未密封的秘密被识别为“同步”,并且 ArgoCD 不会由于未密封的秘密的“OutOfSync”状态而继续同步?(这似乎是由未密封秘密中的解密数据引起的 - 如上面屏幕截图中的差异所示。)
如何通过 Kustomize 将对象添加到数组?因此,我想添加两个ServiceAccounts subjects,如下所示:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: name
namespace: test1
- kind: ServiceAccount
name: name
namespace: test2
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用该补丁:
- op: add
path: "/subjects/0"
value:
kind: ServiceAccount
name: name
namespace: test1
Run Code Online (Sandbox Code Playgroud)
还有第二个环境的另一个补丁:
- op: add
path: "/subjects/1"
value:
kind: ServiceAccount
name: name
namespace: test2
Run Code Online (Sandbox Code Playgroud)
但结果我得到了重复subjects,所以当然这是错误的:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects: …Run Code Online (Sandbox Code Playgroud) 我想用 kustomize 删除容器中的一些环境变量?那可能吗?当我打补丁时,它只是添加,正如你可能知道的那样。
如果不可能,我们可以将环境变量名称和密钥名称/密钥对一起替换吗?
containers:
- name: container1
env:
- name: NAMESPACE
valueFrom:
secretKeyRef:
name: x
key: y
Run Code Online (Sandbox Code Playgroud)
对此的任何帮助将不胜感激!谢谢!
我的模板基本文件中sizeLimit的属性emptyDir设置为 2Gi。我想删除sizelimit并只拥有emptyDir: {}. 我无法使用 Kustomization 覆盖来实现这一点。我将在下面详细介绍我的文件夹结构和 kustomization yaml。
文件夹结构:
\napplication\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 majorbase\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 kustomization.yaml\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 resources\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 web-template.yaml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 minorbase\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 kustomization.yaml\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 resources\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 myoverlays\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 kustomization.yaml\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 resources\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 my-new-web.yaml\nRun Code Online (Sandbox Code Playgroud)\n该文件夹myoverlays的 kustomization.yaml 文件中包含以下内容
bases:\n- ../minorbase\npatchesStrategicMerge:\n- resources/my-new-web.yaml\nRun Code Online (Sandbox Code Playgroud)\n该文件夹minorbase的 kustomization.yaml 文件中包含以下内容
bases:\n- ../majorbase\nRun Code Online (Sandbox Code Playgroud)\n该文件夹majorbase的 kustomization.yaml 文件中包含以下内容
resources:\n- resources/web-template.yaml\nRun Code Online (Sandbox Code Playgroud)\n我想要编辑的部分在主要库/模板中看起来像这样。
\nvolumes:\n - name: test-vol\n emptyDir:\n sizeLimit: "2Gi"\nRun Code Online (Sandbox Code Playgroud)\n上述配置需要使用覆盖层进行更新,如下所示。
\n …在 Base Ingress 文件中,我添加了以下注释nginx.ingress.kubernetes.io/auth-snippet,需要在其中一个环境中将其删除。
基地入口:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress
annotations:
nginx.ingress.kubernetes.io/auth-snippet: test
Run Code Online (Sandbox Code Playgroud)
我在覆盖层中创建了一个 ingress-patch.yml 并添加了以下内容
- op: remove
path: /metadata/annotations/nginx.ingress.kubernetes.io/auth-snippet
Run Code Online (Sandbox Code Playgroud)
但执行 Kustomize Build 时出现以下错误
Error: remove operation does not apply: doc is missing path: "/metadata/annotations/nginx.ingress.kubernetes.io/auth-snippet": missing value
Run Code Online (Sandbox Code Playgroud) 我有一个巨大的补丁文件,我想将其应用于特定的叠加层。我通常会按照预期的方式在覆盖层下修补文件。但文件是相同的,我不想将其复制到每个覆盖层。如果我可以将我的补丁文件保存app-new-manifest.yaml在基础下,并在覆盖下用一行 in 修补它kustomization.yaml,那就太棒了。
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 base\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app-new-manifest.yaml # I am trying to patch this\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 kustomization.yaml\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 app.yaml\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 kustomization.yaml\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 overlay\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 environment1\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 kustomization.yaml # I want to patch app-new-manifest.yaml in base\n \xe2\x94\x82\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 environment2\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 kustomization.yaml # No patch. app.yaml will be as is\n \xe2\x94\x82\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 environment3\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 kustomization.yaml # I want to patch app-new-manifest.yaml in base\nRun Code Online (Sandbox Code Playgroud)\n当我尝试这样做时,我收到此错误:
\n'/base/app/app-new-manifest.yaml' is not in or below '/overlays/environment1'\n …Run Code Online (Sandbox Code Playgroud)