<small id='XdLMz'></small><noframes id='XdLMz'>

  1. <i id='XdLMz'><tr id='XdLMz'><dt id='XdLMz'><q id='XdLMz'><span id='XdLMz'><b id='XdLMz'><form id='XdLMz'><ins id='XdLMz'></ins><ul id='XdLMz'></ul><sub id='XdLMz'></sub></form><legend id='XdLMz'></legend><bdo id='XdLMz'><pre id='XdLMz'><center id='XdLMz'></center></pre></bdo></b><th id='XdLMz'></th></span></q></dt></tr></i><div id='XdLMz'><tfoot id='XdLMz'></tfoot><dl id='XdLMz'><fieldset id='XdLMz'></fieldset></dl></div>

    • <bdo id='XdLMz'></bdo><ul id='XdLMz'></ul>

    1. <tfoot id='XdLMz'></tfoot>
    2. <legend id='XdLMz'><style id='XdLMz'><dir id='XdLMz'><q id='XdLMz'></q></dir></style></legend>

      如何在我的 kubernetes 集群外访问 mysql?

      时间:2023-08-21
      • <bdo id='nxrUj'></bdo><ul id='nxrUj'></ul>
          <tfoot id='nxrUj'></tfoot>

            <legend id='nxrUj'><style id='nxrUj'><dir id='nxrUj'><q id='nxrUj'></q></dir></style></legend>

                <tbody id='nxrUj'></tbody>

              <i id='nxrUj'><tr id='nxrUj'><dt id='nxrUj'><q id='nxrUj'><span id='nxrUj'><b id='nxrUj'><form id='nxrUj'><ins id='nxrUj'></ins><ul id='nxrUj'></ul><sub id='nxrUj'></sub></form><legend id='nxrUj'></legend><bdo id='nxrUj'><pre id='nxrUj'><center id='nxrUj'></center></pre></bdo></b><th id='nxrUj'></th></span></q></dt></tr></i><div id='nxrUj'><tfoot id='nxrUj'></tfoot><dl id='nxrUj'><fieldset id='nxrUj'></fieldset></dl></div>

              <small id='nxrUj'></small><noframes id='nxrUj'>

              • 本文介绍了如何在我的 kubernetes 集群外访问 mysql?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我在我的 centos 机器上运行一个 kubernetes 集群.我不想为 mysql 创建一个 pod.MySQL安装在同一网络的另一台机器上(机器不在kubernates私有网络中).

                I am running a kubernetes cluster in my centos machine. I donot want to create a pod for mysql. MySQL is installed in another machine in same network (Machine is not in kubernates private network).

                如何从运行在 kubernetes 集群中的 pod 访问 mysql 服务?

                How can I access the mysql service from the pods running in kubernetes cluster ?

                我已尝试使用以下配置的服务和端点.但是,运气不好.

                I have tried with service and end point with below configuration. But, No luck.

                apiVersion: v1
                kind: Service
                metadata:
                  name: database
                spec:
                  ports:
                  - port: 13080
                    targetPort: 13080
                    protocol: TCP
                ---
                kind: Deployment
                apiVersion: v1
                metadata:
                  name: database
                subsets:
                  - addresses:
                      - ip: XX.XX.XX.XX
                    ports:
                      - port: 13080
                ---
                kind: ReplicationController
                metadata:
                  name: test
                spec:
                  replicas: 1
                  selector:
                    app: test
                  template:
                    metadata:
                      name: test
                      labels:
                        app: test
                    spec:
                      containers:
                      - name: my_pods
                        image: my_pods
                        env:
                         - name: DATABASE_HOST
                           value: database
                         - name: DATABASE_PORT
                           value: "13080"
                         - name: DATABASE_USER
                           value: "SAAS"
                         - name: DATABASE_PASSWORD
                           value: "SAAS"
                         - name: DATABASE_NAME
                           value: "SAASDB"
                        ports:
                          - containerPort: 8080
                      imagePullSecrets:
                        - name: my-secret
                ---
                apiVersion: v1
                kind: Service
                metadata:
                  name: test-service
                  labels:
                    name: test-service
                spec:
                  type: NodePort
                  ports:
                     - port: 11544
                       targetPort: 8080
                       nodePort: 30600
                  selector:
                    name: test
                

                推荐答案

                对于集群外的事物,您不需要服务.根据您使用的网络模型,docker 容器(即 kubernetes pod)应该能够通过 Docker 设置的网桥正常连接到 MySQL 容器.检查主机在端口 3306 上是否具有连接性,并且确实如此,只需输入 DNS 名称(您的 kube-dns pod 应该将任何基于非 kubernetes 的请求转发到它被调度到的主机的主机 resolv.conf)

                You don't need a service for things outside the cluster. Depending on the networking model you're using, the docker container (ie kubernetes pod) should be able to connect to the MySQL container normally via the bridge that Docker sets up. Check the host has connectivity on port 3306, and it does, simply put in the DNS name (your kube-dns pod should forward any non kubernetes based requests on to the hosts resolv.conf of the host it was scheduled on)

                这篇关于如何在我的 kubernetes 集群外访问 mysql?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:LSN 在 SQL Server 中是什么意思? 下一篇:有没有办法在SQL中使用json对象

                相关文章

                最新文章

              • <small id='b8vM6'></small><noframes id='b8vM6'>

                    <i id='b8vM6'><tr id='b8vM6'><dt id='b8vM6'><q id='b8vM6'><span id='b8vM6'><b id='b8vM6'><form id='b8vM6'><ins id='b8vM6'></ins><ul id='b8vM6'></ul><sub id='b8vM6'></sub></form><legend id='b8vM6'></legend><bdo id='b8vM6'><pre id='b8vM6'><center id='b8vM6'></center></pre></bdo></b><th id='b8vM6'></th></span></q></dt></tr></i><div id='b8vM6'><tfoot id='b8vM6'></tfoot><dl id='b8vM6'><fieldset id='b8vM6'></fieldset></dl></div>
                    • <bdo id='b8vM6'></bdo><ul id='b8vM6'></ul>
                    <tfoot id='b8vM6'></tfoot>
                  1. <legend id='b8vM6'><style id='b8vM6'><dir id='b8vM6'><q id='b8vM6'></q></dir></style></legend>