gpt4 book ai didi

mysql - 将 kubernetes 上托管的 jenkins 连接到 Google Cloud Platform 上的 MySQL

转载 作者:行者123 更新时间:2023-11-29 16:31:16 25 4
gpt4 key购买 nike

我在 Kubernetes 集群上托管了 Jenkins,该集群托管在 Google Cloud Platform 上。我正在尝试通过 Jenkins 运行 python 脚本。该脚本需要读取 MySQL 上的一些值。 MySQL 实例在其中一个实例上单独运行。我在将 Kubernetes 连接到 MySQL 实例时遇到了问题。我收到以下错误:

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '35.199.154.36' (timed out)

This is the document 我遇到了

根据文档,我尝试通过私有(private)IP地址进行连接。生成一个包含 MySQL 用户名和密码的 key ,并包含主机 IP 地址,格式如下,以 this document 为引用:

apiVersion: v1
kind: Secret
metadata:
name: db-credentials
type: Opaque
data:
hostname:<MySQL external ip address>
kubectl create secret generic literal-token --from-literal user=<username> --from-literal password=<password>

这是我尝试插入到 Jenkins Pod 模板中的 pod 的原始 yaml 文件。

The image of the Kubernetes pod template as on Jenkins

任何有关如何克服此 SQL 连接问题的帮助将不胜感激。

最佳答案

您无法在 Pod 模板字段中创建 secret 。您需要在运行作业之前创建 key 并从 pod 模板挂载它,或者仅将 pod 模板中的用户/密码引用为环境变量,具体取决于您的安全级别

关于mysql - 将 kubernetes 上托管的 jenkins 连接到 Google Cloud Platform 上的 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53863355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com