pingcap / tidb-operator

TiDB operator creates and manages TiDB clusters running in Kubernetes.
https://docs.pingcap.com/tidb-in-kubernetes/
Apache License 2.0
1.22k stars 496 forks source link

Set labels for TiProxy instances #5649

Closed djshow832 closed 4 months ago

djshow832 commented 4 months ago

What problem does this PR solve?

TiProxy needs to route to the local TiDB instances in the same AZ. To implement that, TiProxy needs to know its own AZ.

What is changed and how does it work?

Code changes

Tests

Manual test steps:

  1. Start a tidb cluster with tiproxy
  2. Set the location-labels on PD: ./pd-ctl config set replication.location-labels "zone"
  3. Label the node: kubectl label node minikube zone="east"
  4. Check the label of TiProxy:
    $ curl 127.1:3080/api/admin/config/ | grep zone
    zone = 'east'

Side effects

Related changes

Release Notes

Please refer to Release Notes Language Style Guide before writing the release note.

- Support automatically set location labels for TiProxy
csuzhangxc commented 4 months ago

/run-all-tests

ti-chi-bot[bot] commented 4 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: csuzhangxc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/pingcap/tidb-operator/blob/master/OWNERS)~~ [csuzhangxc] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
ti-chi-bot[bot] commented 4 months ago

[LGTM Timeline notifier]

Timeline:

csuzhangxc commented 4 months ago

/run-all-tests

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 2.94118% with 99 lines in your changes are missing coverage. Please review.

Project coverage is 32.35%. Comparing base (3897095) to head (076e427). Report is 7 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #5649 +/- ## =========================================== - Coverage 61.46% 32.35% -29.11% =========================================== Files 235 219 -16 Lines 30397 30403 +6 =========================================== - Hits 18683 9837 -8846 - Misses 9840 19240 +9400 + Partials 1874 1326 -548 ``` | [Flag](https://app.codecov.io/gh/pingcap/tidb-operator/pull/5649/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [e2e](https://app.codecov.io/gh/pingcap/tidb-operator/pull/5649/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `32.35% <2.94%> (?)` | | | [unittest](https://app.codecov.io/gh/pingcap/tidb-operator/pull/5649/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `?` | |