I'am new to Kustomize, and i would like to know:
- How to "patch" metadata.name in a specific yaml like kind: RedisInstance.
I have tried to set a nameSuffix to a specific yaml (kind: RedisInstance), but it didn't worked.
Kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: community-organization-uat-product
bases:
- ../../../../common/base/custom/gcp
- ../../../../common/base/custom/gcp/organization
commonAnnotations:
cnrm.cloud.google.com/managed: "true"
cnrm.cloud.google.com/project-id: community-organization-uat-product
patchesStrategicMerge:
- 1-cXXXXX-patch.yaml
- 3-mXXXXX-patch.yaml
- 4-mXXXXX-patch.yaml
- 5-cXXXXX-patch.yaml
- 6-mXXXXX-patch.yaml
- 7-memorystore-patch.yaml
This is my patch:
7-memorystore-patch.yaml
apiVersion: redis.cnrm.cloud.google.com/v1beta1
kind: RedisInstance
metadata:
name: memorystore-redis
spec:
displayName: memorystore-redis-organization-community-uat
memorySizeGb: 2
redisVersion: REDIS_5_0
reservedIpRange: 10.1XXXXX/29
memorystore.yaml
apiVersion: redis.cnrm.cloud.google.com/v1beta1
kind: RedisInstance
metadata:
name: memorystore-redis
spec:
displayName: Value defined by Kustomize
region: XXXX
connectMode: PRIVATE_SERVICE_ACCESS
locationId: usXXXX
memorySizeGb: Value defined by Kustomize
redisVersion: REDIS_5_0
reservedIpRange: Value defined by Kustomize
tier: BASIC
I don't think you can do it with the
patchesStrategicMerge
: thename
field is used to match resources to which the patch should be applied, so either:The good news is that it can be done with the patchesJson6902:
Kustomization.yaml
redisInstanceNamePatch.yaml