【问题标题】:connecting jenkins hosted on kubernetes to MySQL on Google Cloud Platform将托管在 kubernetes 上的 jenkins 连接到 Google Cloud Platform 上的 MySQL
【发布时间】:2019-01-03 00:30:17
【问题描述】:

我在托管在 Google Cloud Platform 上的 Kubernetes 集群上托管了 Jenkins。我正在尝试通过 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我遇到了

根据文档,我尝试通过私有 IP 地址进行连接。 生成了一个包含 MySQL 用户名和密码的密钥,并包含以下格式的主机 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 文件。

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

【问题讨论】:

    标签: mysql jenkins kubernetes google-cloud-platform


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-05
      • 2020-08-22
      • 2023-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多