# Container merge patch strategic

> When users need to apply a specific configuration to containers that we do not support or do not currently exist, merge patch can be used.
> This document describes how to overwrite the container configuration generated by the operator by merging patches.

## How the "strategic merge patch" works

The operator supports `additionalContainers` field in `TidbCluster.spec.pd`, `TidbCluster.spec.tikv`, `TidbCluster.spec.tidb`,`TidbMonitor.spec` configuration etc. 
This field allows injecting additional containers, and the existing configuration can be overwritten by sharing the same container name.

### Merge patch example of pd pod

The following manifest merge the `lifecycle` configuration into pd container.

```yaml
apiVersion: pingcap.com/v1alpha1
kind: TidbCluster
metadata:
  name: basic
spec:
  version: v5.4.1
  timezone: UTC
  pvReclaimPolicy: Retain
  enableDynamicConfiguration: true
  configUpdateStrategy: RollingUpdate
  discovery: {}
  helper:
    image: busybox:1.34.1
  pd:
    baseImage: pingcap/pd
    maxFailoverCount: 0
    replicas: 1
    # if storageClassName is not set, the default Storage Class of the Kubernetes cluster will be used
    # storageClassName: local-storage
    requests:
      storage: "1Gi"
    config: {}
    additionalContainers:
      - name: pd
        lifecycle:
          preStop:
            exec:
              command:
                - "sh"
                - "-c"
                - |
                  echo "test"
```
