Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
publicarray committed Mar 21, 2018
1 parent 2b9ed68 commit 4d2f733
Show file tree
Hide file tree
Showing 23 changed files with 166 additions and 76 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
@@ -0,0 +1,3 @@
**/.*
**/*.md
**/*.yml
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
*secret*
node.yml
40 changes: 39 additions & 1 deletion Readme.md
Expand Up @@ -7,7 +7,6 @@ kubectl create -f cloudflare-secret.yml
# kubectl get secrets
# kubectl get secret cloudflare -o yaml


kubectl create -f acme-init-job.yml
kubectl create -f kube/dnscrypt-init-job.yml
```
Expand All @@ -29,3 +28,42 @@ kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/
# or
minikube dashboard
```

Debugging

```sh
kubectl get nodes
kubectl get jobs
kubectl get deployments
kubectl get services
kubectl get pods -o wide
kubectl get all -l app=dns-server

## SSH into the container/pod
export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
kubectl exec -ti $POD_NAME sh

## SSH into a new neighbouring container/pod
kubectl run busybox -it --image=busybox --restart=Never --rm
kubectl run alpine -it --image=alpine --restart=Never --rm

minikube ssh

kubectl logs deployment/nsd
kubectl describe deployment/nsd
```

Build docker images

```sh
docker build -t publicarray/nsd nsd/
docker build -t publicarray/unbound unbound/
docker build -t publicarray/doh-proxy doh-proxy/
docker build -t publicarray/haproxy haproxy/
docker build -t publicarray/dnscrypt-wrapper dnscrypt-wrapper/
docker images
docker push publicarray/unbound

docker run --rm --name myunbound -it publicarray/unbound sh
docker run -p 5300:53/udp -v (pwd)/unbound/unbound.conf:/etc/unbound/unbound.conf:ro --name myunbound publicarray/unbound
```
4 changes: 2 additions & 2 deletions doh-proxy/Dockerfile
Expand Up @@ -30,6 +30,6 @@ EXPOSE 3000/udp 3000/tcp

RUN doh-proxy --version

CMD ["/sbin/runsvdir -P /etc/service"]
CMD ["-u 9.9.9.9:53"]

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/usr/local/bin/doh-proxy"]
2 changes: 1 addition & 1 deletion doh-proxy/doh-proxy-deployment.yml
Expand Up @@ -17,6 +17,6 @@ spec:
containers:
- env:
image: publicarray/doh-proxy
name: ssl-keys
name: doh-proxy
command: ["/entrypoint.sh"]
restartPolicy: Always
4 changes: 0 additions & 4 deletions doh-proxy/doh-proxy.sh

This file was deleted.

14 changes: 0 additions & 14 deletions doh-proxy/entrypoint.sh

This file was deleted.

6 changes: 3 additions & 3 deletions haproxy/Dockerfile
Expand Up @@ -29,7 +29,7 @@ RUN set -x && \
#------------------------------------------------------------------------------#
FROM alpine:latest

ENV HAPROXY_RUN_DEPS openssl runit shadow
ENV HAPROXY_RUN_DEPS openssl shadow

RUN apk add --no-cache $HAPROXY_RUN_DEPS

Expand All @@ -50,6 +50,6 @@ EXPOSE 443/udp 443/tcp

RUN haproxy -v

CMD ["/sbin/runsvdir -P /etc/service"]
CMD ["-f /etc/haproxy.conf"]

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/usr/local/sbin/haproxy"]
14 changes: 0 additions & 14 deletions haproxy/entrypoint.sh

This file was deleted.

11 changes: 6 additions & 5 deletions haproxy/haproxy-deployment.yml
Expand Up @@ -12,20 +12,21 @@ spec:
template:
metadata:
labels:
component: dns-server
app: dns-server
component: haproxy
service: haproxy
spec:
containers:
- env:
image: publicarray/haproxy
name: ssl-keys
name: haproxy
volumeMounts:
- name: ssl-keys
mountPath: /opt/ssl-keys
command: ["/entrypoint.sh"]
resources:
requests:
memory: "1Gi"
# resources:
# requests:
# memory: "1Gi"
restartPolicy: Always
volumes:
- name: ssl-keys
Expand Down
2 changes: 2 additions & 0 deletions haproxy/haproxy-srv.yml
Expand Up @@ -9,6 +9,7 @@ spec:
port: 453
targetPort: 453
selector:
application: dns-server
service: haproxy
type: LoadBalancer
loadBalancerIP: 0.0.0.0
Expand All @@ -24,6 +25,7 @@ spec:
port: 453
targetPort: 453
selector:
application: dns-server
service: haproxy
type: LoadBalancer
loadBalancerIP: 0.0.0.0
4 changes: 0 additions & 4 deletions haproxy/haproxy.sh

This file was deleted.

4 changes: 4 additions & 0 deletions namespace.yml
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespce
metadata:
name: dns
6 changes: 3 additions & 3 deletions nsd/Dockerfile
Expand Up @@ -25,7 +25,7 @@ RUN set -x && \
#------------------------------------------------------------------------------#
FROM alpine:latest

ENV NSD_RUN_DEPS libressl libevent runit shadow
ENV NSD_RUN_DEPS libressl libevent shadow

RUN apk add --no-cache $NSD_RUN_DEPS

Expand All @@ -52,6 +52,6 @@ EXPOSE 552/udp 552/tcp

RUN nsd -v

CMD ["/sbin/runsvdir -P /etc/service"]
CMD ["-d"]

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/usr/local/sbin/nsd"]
14 changes: 0 additions & 14 deletions nsd/entrypoint.sh

This file was deleted.

27 changes: 27 additions & 0 deletions nsd/nsd-deployment.yml
@@ -0,0 +1,27 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
namespace: default
labels:
service: nsd
name: nsd
spec:
strategy:
type: Recreate
replicas: 1
template:
metadata:
labels:
app: dns-server
component: nsd
service: nsd
spec:
containers:
- env:
image: publicarray/nsd
name: nsd
command: ["/entrypoint.sh"]
resources:
requests:
memory: "1Gi"
restartPolicy: Always
31 changes: 31 additions & 0 deletions nsd/nsd-srv.yml
@@ -0,0 +1,31 @@
apiVersion: v1
kind: Service
metadata:
name: nsd-tcp
namespace: default
spec:
ports:
- protocol: TCP
port: 552
targetPort: 53
selector:
application: dns-server
service: nsd
type: ClusterIP
# clusterIP: 192.168.99.100
---
apiVersion: v1
kind: Service
metadata:
name: nsd-udp
namespace: default
spec:
ports:
- protocol: UDP
port: 552
targetPort: 53
selector:
application: dns-server
service: nsd
type: ClusterIP
# clusterIP: 192.168.99.100
5 changes: 3 additions & 2 deletions nsd/nsd.conf
Expand Up @@ -18,7 +18,8 @@ server:
# ip-address: 1.2.3.4
# ip-address: 1.2.3.4@5678
# ip-address: 12fe::8ef0
ip-address: 127.0.0.1
# ip-address: 127.0.0.1
ip-address: 0.0.0.0

# listen on IPv4 connections
do-ip4: yes
Expand All @@ -27,7 +28,7 @@ server:
do-ip6: yes

# port to answer queries on. default is 53.
port: 552
port: 53

# Verbosity level.
verbosity: 0
Expand Down
4 changes: 0 additions & 4 deletions nsd/nsd.sh

This file was deleted.

11 changes: 9 additions & 2 deletions unbound/Dockerfile
@@ -1,5 +1,12 @@
FROM alpine:latest
MAINTAINER Frank Denis
MAINTAINER publicarray
# LABEL org.label-schema.name="unbound"
# LABEL org.label-schema.vendor="publicarray"
# LABEL org.label-schema.description=""
# LABEL org.label-schema.vcs-url="https://github.com/publicarray/dns-resolver-infra"
# LABEL org.label-schema.version="3.7"
# LABEL org.label-schema.license="MIT"

ENV SERIAL 7

ENV UNBOUND_BUILD_DEPS make gcc musl-dev libressl-dev libevent-dev expat-dev
Expand Down Expand Up @@ -58,7 +65,7 @@ EXPOSE 53/udp 53/tcp

RUN unbound -h || true

CMD ["/sbin/runsvdir -P /etc/service"]
# CMD [""] --munin

ENTRYPOINT ["/entrypoint.sh"]

Expand Down
3 changes: 2 additions & 1 deletion unbound/entrypoint.sh
@@ -1,8 +1,9 @@
#!/bin/sh
# Borrowed from: https://github.com/faisyl/alpine-runit/blob/master/start_runit

set -e

# export > /etc/envvars

if [ $# -eq 0 ]; then
exec /sbin/runsvdir -P /etc/service
fi
Expand Down
27 changes: 27 additions & 0 deletions unbound/unbound-deployment.yml
@@ -0,0 +1,27 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
namespace: default
labels:
service: unbound
name: unbound
spec:
strategy:
type: Recreate
replicas: 1
template:
metadata:
labels:
app: dns-server
component: unbound
service: unbound
spec:
containers:
- env:
image: publicarray/unbound
name: unbound
command: ["/entrypoint.sh"]
resources:
requests:
memory: "1Gi"
restartPolicy: Always
5 changes: 3 additions & 2 deletions unbound/unbound.sh
@@ -1,4 +1,5 @@
#!/bin/sh
set -e

/usr/local/sbin/unbound -d
exec 2>&1
# . /etc/envvars
exec /usr/local/sbin/unbound -d

0 comments on commit 4d2f733

Please sign in to comment.