LoginSignup
0
0

More than 1 year has passed since last update.

kustomize listに項目を追加

Posted at

kustomizeでlistに要素を追加する方法

deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
spec:
  template:
    spec:
      containers:
        - name: app
          env:
            - name: ENV1
              value: env1
          resources:
            requests:
              cpu: 250m
              memory: 512Mi
deployment-patch.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
spec:
  template:
    spec:
      containers:
        - name: app
          image: my-image
          env:
            - name: ENV2
              value: env2
kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ../../../../base/app
patches:
  - path: deployment-patch.yaml
    target:
      kind: Deployment

kustomize build

build.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
spec:
  template:
    spec:
      containers:
      - env:
        - name: ENV2
          value: env2
        - name: ENV1
          value: env1
        image: my-image
        name: app
        resources:
          requests:
            cpu: 250m
            memory: 512Mi

Deploymentにimage,envなどを追加するときはdeployment-patch.yamlでcontainersのnameを指定しないといけない。(nameが識別子となる)

しかし、Ingressでrulesのhostを置換する場合はこの方法は使えないみたい。(rulesにnameがないため?)
現状Path JSON6902を使用するのがよさそうだが別の手段が欲しい。

https://github.com/kubernetes-sigs/kustomize/issues/581
https://github.com/kubernetes-sigs/kustomize/issues/347

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0