Surprise! We've been running on hardware provided by BuyVM for a few months and wanted to show them a little appreciation.
Running a paste site comes with unique challenges, ones that aren't always obvious and hard to control. As such, BuyVM offered us a home where we could worry less about the hosting side of things and focus on maintaining a clean and useful service! Go check them out and show them some love!
Description: K8S deployment.yaml and GCP cloudbuild.yaml
Submitted by dzhi on July 23, 2018

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: dev
  name: app
  labels:
    app: app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: app
  template:
    metadata:
      labels:
        app: app
    spec:
      initContainers:
      - name: init
        image: eu.gcr.io/project/init
        imagePullPolicy: Always
        command: ['sh', '-c', 'cp -r /app /srv; chown -R 82:82 /srv/app']
        volumeMounts:
        - name: code
          mountPath: /srv
      containers:
      - name: nginx
        image: eu.gcr.io/project/nginx
        imagePullPolicy: Always
        ports:
        - containerPort: 80
        volumeMounts:
        - name: code
          mountPath: /srv
        - name: php-socket
          mountPath: /var/run
        livenessProbe:
          httpGet:
            path: /health.html
            port: 80
            httpHeaders:
            - name: X-Healthcheck
              value: Checked
          initialDelaySeconds: 10
          timeoutSeconds: 1
          periodSeconds: 15
        readinessProbe:
          httpGet:
            path: /health.html
            port: 80
            httpHeaders:
            - name: X-Healthcheck
              value: Checked
          initialDelaySeconds: 10
          timeoutSeconds: 1
          periodSeconds: 15
      - name: php
        image: eu.gcr.io/project/php
        imagePullPolicy: Always
        volumeMounts:
        - name: code
          mountPath: /srv
        - name: php-socket
          mountPath: /var/run
        livenessProbe:
          httpGet:
            path: /health.html
            port: 80
            httpHeaders:
            - name: X-Healthcheck
              value: Checked
          initialDelaySeconds: 10
          timeoutSeconds: 1
          periodSeconds: 15
        readinessProbe:
          httpGet:
            path: /health.html
            port: 80
            httpHeaders:
            - name: X-Healthcheck
              value: Checked
          initialDelaySeconds: 10
          timeoutSeconds: 1
          periodSeconds: 15
      volumes:
        - name: code
          emptyDir: {}
        - name: php-socket
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  namespace: dev
  name: app-service
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
  selector:
    app: app
steps:

# Build Images
- id: Building Init Image
  name: gcr.io/cloud-builders/docker
  args:
    - build
    - -t
    - eu.gcr.io/$PROJECT_ID/init:latest
    - -t
    - eu.gcr.io/$PROJECT_ID/init:$SHORT_SHA
    - -f
    - init.dockerfile
    - .

- id: Building Nginx Image
  name: gcr.io/cloud-builders/docker
  args:
    - build
    - -t
    - eu.gcr.io/$PROJECT_ID/nginx:latest
    - -t
    - eu.gcr.io/$PROJECT_ID/nginx:$SHORT_SHA
    - -f
    - nginx.dockerfile
    - .
  waitFor: ['-']

- id: Building PHP-FPM Image
  name: gcr.io/cloud-builders/docker
  args:
    - build
    - -t
    - eu.gcr.io/$PROJECT_ID/php:latest
    - -t
    - eu.gcr.io/$PROJECT_ID/php:$SHORT_SHA
    - -f
    - php.dockerfile
    - .
  waitFor: ['-']

# Push Images
- id: Push Init Image
  name: gcr.io/cloud-builders/docker
  args:
    - push
    - eu.gcr.io/$PROJECT_ID/init:$SHORT_SHA

- id: Push Nginx Image
  name: gcr.io/cloud-builders/docker
  args:
    - push
    - eu.gcr.io/$PROJECT_ID/nginx:$SHORT_SHA

- id: Push PHP-FPM Image
  name: gcr.io/cloud-builders/docker
  args:
    - push
    - eu.gcr.io/$PROJECT_ID/php:$SHORT_SHA

# Update Deployment
- id: Updating Deployment
  name: gcr.io/cloud-builders/kubectl
  args:
    - apply
    - -f
    - deployment.yaml

  env:
    - CLOUDSDK_COMPUTE_ZONE=europe-west1-b
    - CLOUDSDK_CONTAINER_CLUSTER=cluster-1

# Images
images:
  - eu.gcr.io/$PROJECT_ID/init:latest
  - eu.gcr.io/$PROJECT_ID/init:$SHORT_SHA
  - eu.gcr.io/$PROJECT_ID/nginx:latest
  - eu.gcr.io/$PROJECT_ID/nginx:$SHORT_SHA
  - eu.gcr.io/$PROJECT_ID/php:latest
  - eu.gcr.io/$PROJECT_ID/php:$SHORT_SHA

# Tags
tags:
  - master
  - dev
  - init