Everyone. I have tried to use kustomize to manage application deploymentconfig in openshift cluster, and I defined deploymentconfig manifest yaml file in the base directory
base |__kustomization.yaml |__deploymentconfig.yaml
cat base/deploymentconfig.yaml
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: helloword
spec:
replicas: 1
template:
metadata:
creationTimestamp: null
labels:
application: helloword
deploymentConfig: helloword
name: helloword
spec:
containers:
- env:
- name: PROBE_DISABLE_BOOT_ERRORS_CHECK
value: "true"
- name: DT_RELEASE_BUILD_VERSION
value: "2022-10-27 22:20:24"
- name: DT_RELEASE_PRODUCT
value: helloword
- name: DT_RELEASE_STAGE
value: OCP_PROD
- name: APP_ENVIRONMENT
value: PROD
envFrom:
- secretRef:
name: helloword
image: repo.example.com:5000/helloword:0.0.3
imagePullPolicy: Always
name: helloword
ports:
- containerPort: 8080
name: http
protocol: TCP
resources:
limits:
memory: 512Mi
requests:
memory: 128Mi
-------------------------------------------------
cat base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deploymentconfig.yaml
--------------------------------------------------
in the overlays directory
overlays
|_dev
|__helloworld
|__patches
|__deploymentconfig.yaml
|__kustomization.yaml
cat overlays/dev/helloworld/patches/deploymentconfig.yaml
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: helloworld
spec:
template:
spec:
containers:
- name: helloworld
env:
- name: REGION
value: dev
- name: APP_DATA
value: /apps/data
--------------------------------------
cat overlays/dev/helloworld/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: default
bases:
- ../../../base
patchesStrategicMerge:
- patches/deploymentconfig.yaml
when I ran "kubectl kustomize overlays/dev/helloworld/" , it seem like the deploymentconfig of overlays/patches folder overwritten the one base folder, but all I want is the overlays/dev/helloworld/patches/deploymentconfig.yaml will be merged into the base/deploymentconfig.yaml file.
~/git/gitops/apps_configs/overlays/dev/helloworld$ kubectl kustomize .
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: helloworld
namespace: default
spec:
replicas: 1
template:
metadata:
creationTimestamp: null
labels:
application: helloworld
deploymentConfig: helloworld
name: helloworld
spec:
containers:
- env:
- name: REGION
value: dev
- name: APP_DATA
value: /apps/data
name: helloworld
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 75
test: false
triggers:
- type: ConfigChange