Skip to content

Commit

Permalink
Merge branch 'master' into cdc-graceful-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielZhangQD authored Aug 2, 2022
2 parents 2a063f1 + af0fda7 commit 7a90ab2
Show file tree
Hide file tree
Showing 24 changed files with 5,429 additions and 4,937 deletions.
8 changes: 7 additions & 1 deletion docs/api-references/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4669,7 +4669,13 @@ Note that the following env names cannot be used and will be overridden by TiDB
</td>
<td>
<em>(Optional)</em>
<p>Additional containers of the component.</p>
<p>Additional containers of the component.
If the container names in this field match with the ones generated by
TiDB Operator, the container configurations will be merged into the
containers generated by TiDB Operator via strategic merge patch.
If the container names in this field do not match with the ones
generated by TiDB Operator, the container configurations will be
appended to the Pod container spec directly.</p>
</td>
</tr>
<tr>
Expand Down
48 changes: 48 additions & 0 deletions examples/podpatch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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"
```
64 changes: 64 additions & 0 deletions examples/podpatch/tidb-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# IT IS NOT SUITABLE FOR PRODUCTION USE.
# This YAML describes a basic TiDB cluster with minimum resource requirements,
# which should be able to run in any Kubernetes cluster with storage support.
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"
tikv:
baseImage: pingcap/tikv
maxFailoverCount: 0
# If only 1 TiKV is deployed, the TiKV region leader
# cannot be transferred during upgrade, so we have
# to configure a short timeout
evictLeaderTimeout: 1m
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:
storage:
# In basic examples, we set this to avoid using too much storage.
reserve-space: "0MB"
rocksdb:
# In basic examples, we set this to avoid the following error in some Kubernetes clusters:
# "the maximum number of open file descriptors is too small, got 1024, expect greater or equal to 82920"
max-open-files: 256
raftdb:
max-open-files: 256
tidb:
baseImage: pingcap/tidb
maxFailoverCount: 0
replicas: 1
service:
type: ClusterIP
config: {}
35 changes: 35 additions & 0 deletions examples/podpatch/tidb-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: pingcap.com/v1alpha1
kind: TidbMonitor
metadata:
name: basic
spec:
replicas: 1
clusters:
- name: basic
prometheus:
baseImage: prom/prometheus
version: v2.27.1
grafana:
baseImage: grafana/grafana
version: 7.5.11
initializer:
baseImage: pingcap/tidb-monitor-initializer
version: v5.4.1
reloader:
baseImage: pingcap/tidb-monitor-reloader
version: v1.0.1
prometheusReloader:
baseImage: quay.io/prometheus-operator/prometheus-config-reloader
version: v0.49.0
imagePullPolicy: IfNotPresent
additionalContainers:
- name: test
image: busybox:1.34.1
lifecycle:
preStop:
exec:
command:
- "sh"
- "-c"
- |
echo "test"
Loading

0 comments on commit 7a90ab2

Please sign in to comment.