Skip to content

Instantly share code, notes, and snippets.

@caleblloyd
Created July 10, 2020 02:20
Show Gist options
  • Save caleblloyd/ff271401e71d17531c3c429a592d6025 to your computer and use it in GitHub Desktop.
Save caleblloyd/ff271401e71d17531c3c429a592d6025 to your computer and use it in GitHub Desktop.
CoreDNS Caching Sidecar
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: busybox
spec:
replicas: 1
selector:
matchLabels:
app: busybox
version: v1
template:
metadata:
labels:
app: busybox
version: v1
spec:
initContainers:
- name: init-dns
image: busybox
imagePullPolicy: IfNotPresent
command:
- sh
args:
- -c
- |
sed 's/nameserver.*/nameserver 127.0.0.1/g' /etc/resolv.conf > /mnt/resolvconf/resolv.conf
echo ".:53 {
errors
health
forward . /etc/resolv.conf
cache 300 {
prefetch 1
}
}" > /etc/coredns/Corefile
volumeMounts:
- name: etc-resolvconf
mountPath: /mnt/resolvconf
- name: coredns-config
mountPath: /etc/coredns
containers:
- name: busybox
image: busybox
imagePullPolicy: IfNotPresent
command:
- sh
args:
- -c
- |
while true; do
sleep 1
done
volumeMounts:
- name: etc-resolvconf
mountPath: /etc/resolv.conf
subPath: resolv.conf
- name: coredns
image: mcr.microsoft.com/oss/kubernetes/coredns:1.6.6
imagePullPolicy: IfNotPresent
args:
- -conf
- /etc/coredns/Corefile
livenessProbe:
failureThreshold: 5
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
resources:
limits:
memory: 170Mi
requests:
cpu: 100m
memory: 70Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
add:
- NET_BIND_SERVICE
drop:
- all
procMount: Default
readOnlyRootFilesystem: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- name: coredns-config
mountPath: /etc/coredns
readOnly: true
- name: coredns-tmp
mountPath: /tmp
volumes:
- name: coredns-config
emptyDir: {}
- name: coredns-tmp
emptyDir: {}
- name: etc-resolvconf
emptyDir: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment