【问题标题】:How to set SMTP (email configration) in .yaml file in kubernetes如何在 kubernetes 的 .yaml 文件中设置 SMTP(电子邮件配置)
【发布时间】:2020-01-13 05:02:19
【问题描述】:

我想通过谷歌云中的电子邮件配置在 Kubernetes 上部署 ghost(博客)。 ghost 在 k8s 中运行良好。但是,我无法修复部署文件中的 SMTP 设置

我的 .yaml 文件

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: blog
  labels:
    app: blog
spec:
  replicas: 1
  selector:
    matchLabels:
      app: blog
  template:
    metadata:
      labels:
        app: blog
    spec:
      containers:
      - name: blog
        image: ghost:2.6-alpine
        imagePullPolicy: Always
        ports:
        - containerPort: 2368
        env:
        - name: url
          value: http://my-blog.com
   environment:
      url: http://my-blog.com
      mail__transport: 2525
      mail__options__service: {Sendgrid}
      mail__options__auth__user: "gurpreet004"
      mail__options__auth__pass: "Server@1234"

显示错误:

error: error validating "deployment.yaml": error validating data: ValidationError(Deployment.spec.template): unknown field "environment" in io.k8s.api.core.v1.PodTemplateSpec; if you choose to ignore these errors, turn validation off with --validate=false

请提供任何解决方案

【问题讨论】:

    标签: kubernetes google-cloud-platform yaml


    【解决方案1】:

    environment 字段不存在。如果您希望这些值作为容器中的环境变量,您可以这样做:

    apiVersion: apps/v1beta1
    kind: Deployment
    metadata:
      name: blog
      labels:
        app: blog
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: blog
      template:
        metadata:
          labels:
            app: blog
        spec:
          containers:
          - name: blog
            image: ghost:2.6-alpine
            imagePullPolicy: Always
            ports:
            - containerPort: 2368
            env:
            - name: url
              value: http://my-blog.com
            - name: mail__transport
              value: SMTP
            - name: mail__options__service
              value: Sendgrid
            - name: mail__options__auth__user
              value: gurpreet004
            - name: mail__options__auth__pass
              value: Server@1234
    

    【讨论】:

    • 您的代码正在运行,但是当我从 ghost 发送邮件时,它给我一个错误“发送电子邮件失败。原因:未定义传输方法”
    • 您需要向 Ghost 或 Sendgrid 查询您需要提供哪些参数。
    • 尝试更新的清单 (2525 => SMTP)。也可以在这里查看blog.ryanhalliday.com/2018/05/…
    • 我试过但没用,发送网格是 Ghost SMTP 的正确选择吗?
    • 你可以在这里查看你有哪些选项ghost.org/docs/concepts/config/#mail
    【解决方案2】:

    给出的答案是正确的,但您需要执行一些步骤: . Create the account in the Mailgun. . verify the account and also register your domain. . Mailgun provides you with "demo SMTP" details to test your mail. . if you need you can reset your (demo SMTP)password. . Enter these details in the mail section of yours.YAML file and run it. . Open ghost admin and click the option "labs"-> test mail

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-18
      • 2018-06-11
      • 2020-02-18
      • 1970-01-01
      • 1970-01-01
      • 2013-12-18
      • 2016-08-28
      • 1970-01-01
      相关资源
      最近更新 更多