How to set SMTP (email configration) in .yaml file in kubernetes

9/11/2019

I want to deploy ghost (blog) on Kubernetes with email configuration in google cloud. ghost is running fine in k8s. But, I'm not able to fix my SMTP setting in deployment file

my .yaml file

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"

it showing an error :

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

please provide any solution

-- Gurpreet
google-cloud-platform
kubernetes
yaml

2 Answers

10/19/2019

The given answer is correct but you need to follow some steps: . 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

-- saaya kasta
Source: StackOverflow

9/11/2019

The environment field doesn't exist. If you want these values as environment variables in the container, you can do like this:

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
-- weibeld
Source: StackOverflow