4 Commits

5 changed files with 85 additions and 0 deletions

View File

@@ -1,2 +1,3 @@
# varnish-kustom
Deploy a simple varnish server with kustomize

6
files/default.vcl Normal file
View File

@@ -0,0 +1,6 @@
vcl 4.0;
backend default {
.host = "127.0.0.1";
.port = "8080";
}

14
kustomization.yaml Normal file
View File

@@ -0,0 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- resources/deployment.yaml
- resources/svc.yaml
configMapGenerator:
- name: varnish-env
literals:
- VARNISH_SIZE=1G
- name: varnish-config
files:
- files/default.vcl

53
resources/deployment.yaml Normal file
View File

@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: varnish
labels:
app: varnish
spec:
replicas: 1
selector:
matchLabels:
app: varnish
template:
metadata:
labels:
app: varnish
spec:
containers:
- name: varnish
image: reg.cadoles.com/dh/library/varnish:7.6.1-alpine
imagePullPolicy: IfNotPresent
env:
- name: VARNISH_HTTP_PORT
value: "8080"
envFrom:
- configMapRef:
name: varnish-env
ports:
- containerPort: 8080
volumeMounts:
- mountPath: /etc/varnish/default.vcl
name: varnish-config
subPath: default.vcl
- mountPath: /var/lib/varnish/varnishd
name: varnish-lib
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
add: [ "IPC_LOCK" ]
volumes:
- name: varnish-config
configMap:
name: varnish-config
items:
- key: default.vcl
path: default.vcl
- name: varnish-lib
emptyDir:
sizeLimit: 1Gi
securityContext:
runAsUser: 1000
runAsGroup: 1000
runAsNonRoot: true

11
resources/svc.yaml Normal file
View File

@@ -0,0 +1,11 @@
kind: Service
apiVersion: v1
metadata:
name: varnish
spec:
selector:
app: varnish
ports:
- protocol: TCP
port: 8080
targetPort: 8080