apiVersion: v1
kind: Service
metadata:
  name: phpfpm
  labels:
    tier: backend
spec:
  selector:
    app: phpfpm
    tier: backend
  ports:  
  - name: phpfpm
    port: 9000
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: phpfpm
  labels:
    tier: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: phpfpm
      tier: backend
  template:
    metadata:
      labels:
        app: phpfpm
        tier: backend
    spec:
      securityContext:
        fsGroup: 65533 # to make SSH key readable
      volumes:
      - name: dir
        emptyDir: {}
      - name: git-secret
        secret:
          secretName: github-creds
          defaultMode: 288
      containers:
      - env:
        - name: GIT_SYNC_REPO
          value: git@github.com:<some user>/mysamplerepo.git
        - name: GIT_SYNC_BRANCH
          value: master
        - name: GIT_SYNC_SSH
          value: "true"
        - name: GIT_SYNC_PERMISSIONS
          value: "0777"
        - name: GIT_SYNC_DEST
          value: www
        - name: GIT_SYNC_ROOT
          value: /git
        name: git-sync
        image: k8s.gcr.io/git-sync:v3.1.1
        securityContext:
          runAsUser: 65533 # git-sync user
        volumeMounts:
        - name: git-secret
          mountPath: /etc/git-secret
        - name: dir
          mountPath: /git
      - name: phpfpm
        image: php:fpm
        ports:
        - containerPort: 9000
        volumeMounts:
        - name: dir
          mountPath: /usr/share/nginx
