...
 
Commits (1)
VERSION
rendered_k8s_manifests.yaml
FROM nginx:1.15.2-alpine
COPY public /usr/share/nginx/html
all:
auth:
gcloud auth login
deploy-prod: all
-gsutil -m rm gs://www.code.supply/*
gsutil -m cp -z html public/* gs://www.code.supply
gsutil -m setmeta \
-h "Cache-Control:private, max-age=0, no-transform" \
gs://www.code.supply/*
deploy-stage: all
-gsutil -m rm gs://stage.code.supply/*
gsutil -m cp -z html public/* gs://stage.code.supply
gsutil -m setmeta \
-h "Cache-Control:private, max-age=0, no-transform" \
gs://stage.code.supply/*
serve: all
cd public && python -m SimpleHTTPServer
VERSION:
git rev-parse --short HEAD > $@
build: all
docker build . -t eu.gcr.io/code-supply/code-supply:$$(cat VERSION)
push: build
docker push eu.gcr.io/code-supply/code-supply
rendered_k8s_manifests.yaml: VERSION k8s/deployment.yaml k8s/service.yaml k8s/ingress.yaml
cat k8s/*.yaml | VERSION=$$(cat VERSION) envsubst > $@
deploy: rendered_k8s_manifests.yaml
kubectl --context=code-supply-production apply -f $<
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: &name codesupply-web
labels:
app: *name
spec:
replicas: 3
selector:
matchLabels:
app: *name
template:
metadata:
labels:
app: *name
spec:
containers:
- name: *name
image: eu.gcr.io/codesupply/web/codesupply-web:${VERSION}
ports:
- name: http
containerPort: 80
protocol: TCP
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: &name codesupply-web
annotations:
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/redirect-regex: ^https?://(?:www.)?code.supply/(.*)
traefik.ingress.kubernetes.io/redirect-replacement: https://code.supply/$1
traefik.ingress.kubernetes.io/redirect-permanent: "true"
spec:
rules:
- host: code.supply
http:
paths:
- path: /
backend:
serviceName: *name
servicePort: http
- host: www.code.supply
http:
paths:
- path: /
backend:
serviceName: *name
servicePort: http
---
apiVersion: v1
kind: Service
metadata:
name: &name codesupply-web
labels:
app: *name
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: *name