apiVersion: apps/v1
kind: Deployment
metadata:
  name: blog
  labels:
    app: blog
spec:
  replicas: 2
  selector:
    matchLabels:
      app: blog
  template:
    metadata:
      labels:
        app: blog
    spec:
      containers:
      - name: blog
        image: openshiftkatacoda/blog-django-py:latest
        ports:
        - containerPort: 8080
        env:
        - name: BLOG_SITE_NAME
          value: OpenShift Blog
        - name: DATABASE_HOST
          value: blog-db
        - name: DATABASE_USER
          valueFrom:
            secretKeyRef:
              key: database-user
              name: blog-credentials
        - name: DATABASE_PASSWORD
          valueFrom:
            secretKeyRef:
              key: database-password
              name: blog-credentials
        - name: DATABASE_NAME
          valueFrom:
            secretKeyRef:
              key: database-name
              name: blog-credentials
        volumeMounts:
        - name: media
          mountPath: "/opt/app-root/src/media"
      volumes:
      - name: media
        persistentVolumeClaim:
          claimName: blog-media
