apiVersion: v1
kind: Service
metadata:
  name: mediawiki
  namespace: mediawiki
  labels:
    app: mediawiki
spec:
  type: NodePort
  ports:
    - port: 80
      nodePort: 30098
      targetPort: mediawiki
  selector:
    app: mediawiki
    tier: frontend
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mw-pv-claim
  namespace: mediawiki
  labels:
    app: mediawiki
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ""
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mediawiki
  namespace: mediawiki
  labels:
    app: mediawiki
spec:
  selector:
    matchLabels:
      app: mediawiki
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mediawiki
        tier: frontend
    spec:
      containers:
      - image: mediawiki
        #- image: docker-registry:32000/mediawiki:1.0
        name: mediawiki
        env:
        - name: DB_TYPE
          value: mysql
        - name: DB_NAME
          value: mediawiki
        - name: DB_HOST
          value: mediawiki-mysql
        - name: DB_PASS
          valueFrom:
            secretKeyRef:
              name: mysqlmw-pass
              key: password
        - name: DB_USER
          valueFrom:
            secretKeyRef:
              name: mysqlmw-pass
              key: db_user
        ports:
        - containerPort: 80
          name: mediawiki
        volumeMounts:
        - name: mediawiki-persistent-storage
          mountPath: /var/www/html
      imagePullSecrets:
      - name: reg-cred-secret
      volumes:
      - name: mediawiki-persistent-storage
        persistentVolumeClaim:
          claimName: mw-pv-claim
