diff --git a/manifests/dm/README.md b/manifests/dm/README.md new file mode 100644 index 00000000000..5fb0b9ee9f9 --- /dev/null +++ b/manifests/dm/README.md @@ -0,0 +1,48 @@ +--- +title: Deploy DM on Kubernetes +summary: Deploy DM on Kubernetes +category: how-to +--- + +# Deploy DM on Kubernetes + +This document describes how to deploy DM of the new HA architecture with the yamls in this directory. + +## Deploy dm-master + +Update the rpc configs if necessary in `master/config/config.toml`. + +{{< copyable "shell-regular" >}} + +``` shell +kubectl apply -k master -n +``` + +> **Note: ** +> +> - `3` replicas are deployed by default. +> - `storageClassName` is set to `local-storage` by default. + +## Deploy dm-worker + +- If you only need to use DM for incremental data migration, no need to create PVC for dm-worker, just deploy it with below command: + + {{< copyable "shell-regular" >}} + + ``` shell + kubectl apply -k worker/base -n + ``` + +- If you need to use DM for both full and incremental data migration, you have to create PVC for dm-worker, deploy it with below command: + + {{< copyable "shell-regular" >}} + + ``` shell + kubectl apply -k worker/overlays/full -n + ``` + +> **Note: ** +> +> - `3` replicas are deployed by default. +> - `storageClassName` is set to `local-storage` for PVC by default. +> - If PVCs are created, they are mounted to `/data` directory. diff --git a/manifests/dm/master/config/config.toml b/manifests/dm/master/config/config.toml new file mode 100644 index 00000000000..b2e265aa59d --- /dev/null +++ b/manifests/dm/master/config/config.toml @@ -0,0 +1,14 @@ +# rpc configuration +# +# rpc timeout is a positive number plus time unit. we use golang standard time +# units including: "ns", "us", "ms", "s", "m", "h". You should provide a proper +# rpc timeout according to your use scenario. +rpc-timeout = "30s" +# rpc limiter controls how frequently events are allowed to happen. +# It implements a "token bucket" of size `rpc-rate-limit`, initially full and +# refilled at rate `rpc-rate-limit` tokens per second. Note `rpc-rate-limit` +# is float64 type, so remember to add a decimal point and one trailing 0 if its +# literal value happens to be an integer. +rpc-rate-limit = 10.0 +rpc-rate-burst = 40 + diff --git a/manifests/dm/master/dm-master.yaml b/manifests/dm/master/dm-master.yaml new file mode 100644 index 00000000000..c19c9a4e2dd --- /dev/null +++ b/manifests/dm/master/dm-master.yaml @@ -0,0 +1,148 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + labels: + app.kubernetes.io/component: dm-master + name: dm-master +spec: + podManagementPolicy: Parallel + replicas: 3 + revisionHistoryLimit: 10 + selector: + matchLabels: + app.kubernetes.io/component: dm-master + serviceName: dm-master-peer + template: + metadata: + annotations: + prometheus.io/path: /metrics + prometheus.io/port: "8261" + prometheus.io/scrape: "true" + creationTimestamp: null + labels: + app.kubernetes.io/component: dm-master + spec: + affinity: {} + containers: + - command: + - /dm-master + - --data-dir=/data + - --config=/etc/config/config.toml + - --name=$(MY_POD_NAME) + - --master-addr=:8261 + - --advertise-addr=$(MY_POD_NAME).$(PEER_SERVICE_NAME).$(NAMESPACE):8261 + - --peer-urls=:8291 + - --advertise-peer-urls=http://$(MY_POD_NAME).$(PEER_SERVICE_NAME).$(NAMESPACE):8291 + - --initial-cluster=dm-master-0=http://dm-master-0.$(PEER_SERVICE_NAME).$(NAMESPACE):8291,dm-master-1=http://dm-master-1.$(PEER_SERVICE_NAME).$(NAMESPACE):8291,dm-master-2=http://dm-master-2.$(PEER_SERVICE_NAME).$(NAMESPACE):8291 + env: + - name: MY_POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: PEER_SERVICE_NAME + value: dm-master-peer + - name: SERVICE_NAME + value: dm-master + - name: TZ + value: UTC + image: pingcap/dm:ha-alpha + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 8 + httpGet: + path: /status + port: 8261 + scheme: HTTP + initialDelaySeconds: 5 + timeoutSeconds: 5 + readinessProbe: + failureThreshold: 5 + httpGet: + path: /status + port: 8261 + scheme: HTTP + initialDelaySeconds: 5 + timeoutSeconds: 5 + name: master + ports: + - containerPort: 8291 + name: server + protocol: TCP + - containerPort: 8261 + name: client + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /data + name: data + - mountPath: /etc/config + name: config + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 + volumes: + - configMap: + name: dm-master-config + name: config + updateStrategy: + rollingUpdate: + partition: 3 + type: RollingUpdate + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: + - ReadWriteOnce + dataSource: null + resources: + requests: + storage: 10Gi + storageClassName: local-storage +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: dm-master + name: dm-master +spec: + ports: + - name: client + port: 8261 + protocol: TCP + targetPort: 8261 + selector: + app.kubernetes.io/component: dm-master + sessionAffinity: None + type: ClusterIP +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: dm-master + name: dm-master-peer +spec: + clusterIP: None + ports: + - name: peer + port: 8291 + protocol: TCP + targetPort: 8291 + selector: + app.kubernetes.io/component: dm-master + publishNotReadyAddresses: true + sessionAffinity: None + type: ClusterIP + diff --git a/manifests/dm/master/kustomization.yaml b/manifests/dm/master/kustomization.yaml new file mode 100644 index 00000000000..38a802b3177 --- /dev/null +++ b/manifests/dm/master/kustomization.yaml @@ -0,0 +1,10 @@ +resources: +- dm-master.yaml +configMapGenerator: +- name: dm-master-config + files: + - config/config.toml +generatorOptions: + labels: + app.kubernetes.io/component: dm-master + diff --git a/manifests/dm/worker/base/dm-worker.yaml b/manifests/dm/worker/base/dm-worker.yaml new file mode 100644 index 00000000000..a4b8215b090 --- /dev/null +++ b/manifests/dm/worker/base/dm-worker.yaml @@ -0,0 +1,121 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + labels: + app.kubernetes.io/component: dm-worker + name: dm-worker +spec: + podManagementPolicy: Parallel + replicas: 3 + revisionHistoryLimit: 10 + selector: + matchLabels: + app.kubernetes.io/component: dm-worker + serviceName: dm-worker-peer + template: + metadata: + annotations: + prometheus.io/path: /metrics + prometheus.io/port: "8262" + prometheus.io/scrape: "true" + creationTimestamp: null + labels: + app.kubernetes.io/component: dm-worker + spec: + affinity: {} + containers: + - command: + - /dm-worker + - --name=$(MY_POD_NAME) + - --worker-addr=:8262 + - --advertise-addr=$(MY_POD_NAME).$(PEER_SERVICE_NAME).$(NAMESPACE):8262 + - --join=dm-master.$(NAMESPACE):8261 + env: + - name: MY_POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: PEER_SERVICE_NAME + value: dm-worker-peer + - name: SERVICE_NAME + value: dm-worker + - name: TZ + value: UTC + image: pingcap/dm:ha-alpha + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 8 + httpGet: + path: /status + port: 8262 + scheme: HTTP + initialDelaySeconds: 5 + timeoutSeconds: 5 + readinessProbe: + failureThreshold: 5 + httpGet: + path: /status + port: 8262 + scheme: HTTP + initialDelaySeconds: 5 + timeoutSeconds: 5 + name: worker + ports: + - containerPort: 8262 + name: client + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 + updateStrategy: + rollingUpdate: + partition: 3 + type: RollingUpdate +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: dm-worker + name: dm-worker +spec: + ports: + - name: client + port: 8262 + protocol: TCP + targetPort: 8262 + selector: + app.kubernetes.io/component: dm-worker + sessionAffinity: None + type: ClusterIP +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: dm-worker + name: dm-worker-peer +spec: + clusterIP: None + ports: + - name: peer + port: 8262 + protocol: TCP + targetPort: 8262 + selector: + app.kubernetes.io/component: dm-worker + publishNotReadyAddresses: true + sessionAffinity: None + type: ClusterIP + diff --git a/manifests/dm/worker/base/kustomization.yaml b/manifests/dm/worker/base/kustomization.yaml new file mode 100644 index 00000000000..ccfbc341090 --- /dev/null +++ b/manifests/dm/worker/base/kustomization.yaml @@ -0,0 +1,2 @@ +resources: +- dm-worker.yaml diff --git a/manifests/dm/worker/overlays/full/dm-worker-pvc.yaml b/manifests/dm/worker/overlays/full/dm-worker-pvc.yaml new file mode 100644 index 00000000000..b84cd43da88 --- /dev/null +++ b/manifests/dm/worker/overlays/full/dm-worker-pvc.yaml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: dm-worker +spec: + template: + spec: + containers: + - name: worker + volumeMounts: + - mountPath: /data + name: data + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: + - ReadWriteOnce + dataSource: null + resources: + requests: + storage: 10Gi + storageClassName: local-storage diff --git a/manifests/dm/worker/overlays/full/kustomization.yaml b/manifests/dm/worker/overlays/full/kustomization.yaml new file mode 100644 index 00000000000..473fec2a6a0 --- /dev/null +++ b/manifests/dm/worker/overlays/full/kustomization.yaml @@ -0,0 +1,4 @@ +bases: +- ../../base +patches: +- dm-worker-pvc.yaml