Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request help: 代理集群 MySQL TCP不能生效 #2332

Closed
wfy-belief opened this issue Dec 1, 2024 · 1 comment
Closed

request help: 代理集群 MySQL TCP不能生效 #2332

wfy-belief opened this issue Dec 1, 2024 · 1 comment

Comments

@wfy-belief
Copy link

Issue description

1、使用 helm 创建的 MySQL 单节点,已确认,通过 k8s service 映射端口能够成功连接。
创建的命令为: helm install mysql bitnami/mysql --debug --atomic --timeout 20m
2、创建 apisix 的 helm,使用最新版的镜像
helm upgrade --install apisix apisix/apisix --create-namespace --namespace apisix --values=values.yaml --set dashboard.enabled=true --set ingress-controller.enabled=true --set ingress-controller.config.apisix.serviceNamespace=apisix

values 的改动点如下
type:LoadBalancer
TCP: 增加 3306

service:
  # -- Apache APISIX service type for user access itself
  type: LoadBalancer
  # -- Setting how the Service route external traffic
  # If you want to keep the client source IP, you can set this to Local.

  # ref: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip
  externalTrafficPolicy: Cluster
  # type: LoadBalancer
  # annotations:
  #   service.beta.kubernetes.io/aws-load-balancer-type: nlb
  externalIPs: []
  # -- Apache APISIX service settings for http
  http:
    enabled: true
    servicePort: 80
    containerPort: 9080
    # -- Support multiple http ports, See [Configuration](https://github.com/apache/apisix/blob/0bc65ea9acd726f79f80ae0abd8f50b7eb172e3d/conf/config-default.yaml#L24)
    additionalContainerPorts: []
      # - port: 9081
      #   enable_http2: true          # If not set, the default value is `false`.
      # - ip: 127.0.0.2               # Specific IP, If not set, the default value is `0.0.0.0`.
      #   port: 9082
      #   enable_http2: true
  # -- Apache APISIX service settings for tls
  tls:
    servicePort: 443
    # nodePort: 4443

  # -- Apache APISIX service settings for stream. L4 proxy (TCP/UDP)
  stream:
    enabled: true
    tcp:
      - 3306
    udp: []

创建 stream 路由

apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: mysql-stream-route
spec:
  stream:
    - name: mysql-master
      protocol: TCP
      match:
        ingressPort: 3306
      backend:
        serviceName: mysql-headless
        servicePort: 3306

最后执行验证,发现无法通信

❯ mysql -h 10.11.32.12 -P3306 -u root -p
Enter password: 
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 2

Environment

  • your apisix-ingress-controller version (output of apisix-ingress-controller version --long):
    使用的最新版 1.8.0
helm upgrade --install apisix apisix/apisix --create-namespace  --namespace apisix --set dashboard.enabled=true --set ingress-controller.enabled=true --set ingress
-controller.config.apisix.serviceNamespace=apisix
  • your Kubernetes cluster version (output of kubectl version):
Client Version: v1.31.2
Kustomize Version: v5.4.2
Server Version: v1.30.5+k3s1
  • if you run apisix-ingress-controller in Bare-metal environment, also show your OS version (uname -a):
    Ubuntu 24.04 LTS 6.8.0-40-generic containerd://1.7.21-k3s2
@wfy-belief
Copy link
Author

  • -CRD 有问题已经解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant