Skip to content

Instantly share code, notes, and snippets.

@akhenakh
Created April 29, 2019 13:52
Show Gist options
  • Save akhenakh/f3836dc3cf6ca06a003c562dde43ff07 to your computer and use it in GitHub Desktop.
Save akhenakh/f3836dc3cf6ca06a003c562dde43ff07 to your computer and use it in GitHub Desktop.
deploy caddy with a git clone and hugo transform
---
apiVersion: v1
kind: ConfigMap
metadata:
name: caddy-git-config
labels:
app: caddy-git
data:
Caddyfile: |
:80
tls off
root /public
puregit {$REPO} {
auth_token {$TOKEN}
path /data
then hugo --source=/data --destination=/public
interval 14400
}
---
apiVersion: v1
kind: Secret
metadata:
name: caddy-git-secret
labels:
app: caddy-git
type: Opaque
data:
token: "bXlzZWNyZXR0b2tlbg=="
---
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: caddy-git
labels:
app: caddy-git
spec:
replicas: 1
selector:
matchLabels:
app: caddy-git
template:
metadata:
labels:
app: caddy-git
spec:
containers:
- name: caddy-git
image: "akhenakh/caddy-hugo:latest"
imagePullPolicy: IfNotPresent
args: ['--conf', '/config/Caddyfile']
volumeMounts:
- name: config
mountPath: "/config/Caddyfile"
subPath: Caddyfile
ports:
- name: http
containerPort: 80
protocol: TCP
env:
- name: REPO
value: "https://github.com/myrepo/xxxx"
- name: TOKEN
valueFrom:
secretKeyRef:
name: caddy-git-secret
key: token
volumes:
- name: config
configMap:
name: caddy-git-config
---
apiVersion: v1
kind: Service
metadata:
name: caddy-git
labels:
app: "caddy-git"
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
name: http
selector:
app: "caddy-git"
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: caddy-git
labels:
app: "caddy-git"
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: blog.mydomain.com
http:
paths:
- path: /
backend:
serviceName: caddy-git
servicePort: http
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment