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.24k stars 499 forks source link

Can't change tiproxy service type #5664

Open ztelliot opened 5 months ago

ztelliot commented 5 months ago

Bug Report

What version of Kubernetes are you using? v1.26.6

What version of TiDB Operator are you using? v1.6.0

What did you do? add spec.tiproxy.service.type = LoadBalancer in TidbCluster

What did you expect to see? service type change to LoadBalancer

What did you see instead?

The request is invalid: patch: Invalid value: "...": strict decoding error: unknown field "spec.tiproxy.service"

part of my TidbCluster file:

spec:
  ....
  tiproxy:
    baseImage: pingcap/tiproxy
    version: main
    imagePullPolicy: Always
    replicas: 3
    service:
        type: LoadBalancer
    config: {}
csuzhangxc commented 5 months ago

it does support changing the service type now, if you need to use LoadBalancer, you can create another service (with type: LoadBalancer) manually. /cc @xhebox

tradergt commented 3 months ago

I just tried it and it does not work? How are you doing it?

csuzhangxc commented 3 months ago

I just tried it and it does not work? How are you doing it?

Do you mean, an extra service manually added does not work?

Have you set the same lableSelector as the original one?

tradergt commented 3 months ago

Is there an example some where? I am kind of lost on how to actually set this up, tbh. I would appreciate any help here.

ztelliot commented 3 months ago

Hello, here is my tiproxy service config:

Original service created by operator

apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/component: tiproxy
    app.kubernetes.io/instance: tidb
    app.kubernetes.io/managed-by: tidb-operator
    app.kubernetes.io/name: tidb-cluster
    app.kubernetes.io/used-by: end-user
  name: tidb-tiproxy
  namespace: tidb
spec:
  ipFamilyPolicy: PreferDualStack
  ports:
  - name: tiproxy-api
    nodePort: 21982
    port: 3080
    protocol: TCP
    targetPort: 3080
  - name: tiproxy-sql
    nodePort: 29742
    port: 6000
    protocol: TCP
    targetPort: 6000
  selector:
    app.kubernetes.io/component: tiproxy
    app.kubernetes.io/instance: tidb
    app.kubernetes.io/managed-by: tidb-operator
    app.kubernetes.io/name: tidb-cluster
  type: NodePort

And the LoadBalancer service created by myself

apiVersion: v1
kind: Service
metadata:
  name: tidb-tiproxy-lb
  namespace: tidb
spec:
  ipFamilyPolicy: PreferDualStack
  ports:
  - name: tiproxy-api
    port: 3080
    protocol: TCP
    targetPort: 3080
  - name: tiproxy-sql
    port: 6000
    protocol: TCP
    targetPort: 6000
  selector:
    app.kubernetes.io/component: tiproxy
    app.kubernetes.io/instance: tidb
    app.kubernetes.io/managed-by: tidb-operator
    app.kubernetes.io/name: tidb-cluster
  type: LoadBalancer

Just copy your original service yaml, delete the nodePort in ports and change the type to LoadBalancer.

tradergt commented 3 months ago

ok, so here is the issue and where the confusion comes in. If you install via: https://docs.pingcap.com/tidb-in-kubernetes/stable/get-started There is no way to change the above file. Which is why i was so confused..

I just used the above as i have a simplish install trying to play with tidb in my home lab

csuzhangxc commented 3 months ago

ok, so here is the issue and where the confusion comes in. If you install via: https://docs.pingcap.com/tidb-in-kubernetes/stable/get-started There is no way to change the above file. Which is why i was so confused..

I just used the above as i have a simplish install trying to play with tidb in my home lab

not CHANGE the original one, just copy to a new file and give the resource another name