From a519cb11e6e6941e48b789f301739732ef792ec1 Mon Sep 17 00:00:00 2001 From: Eric Greer Date: Thu, 7 Sep 2017 10:56:35 -0700 Subject: [PATCH 1/7] dockerfile, makefile and readme --- cmd/dnsp/.gitignore | 1 + cmd/dnsp/Dockerfile | 11 +++++++++++ cmd/dnsp/Makefile | 6 ++++++ cmd/dnsp/README.md | 11 +++++++++++ 4 files changed, 29 insertions(+) create mode 100644 cmd/dnsp/.gitignore create mode 100644 cmd/dnsp/Dockerfile create mode 100644 cmd/dnsp/Makefile create mode 100644 cmd/dnsp/README.md diff --git a/cmd/dnsp/.gitignore b/cmd/dnsp/.gitignore new file mode 100644 index 0000000..718d694 --- /dev/null +++ b/cmd/dnsp/.gitignore @@ -0,0 +1 @@ +dnsp diff --git a/cmd/dnsp/Dockerfile b/cmd/dnsp/Dockerfile new file mode 100644 index 0000000..090b580 --- /dev/null +++ b/cmd/dnsp/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:latest + +RUN mkdir /app +ADD *.go /app/ +WORKDIR /app +RUN go get -u github.com/gophergala/dnsp/... +RUN go build -o dnsp + +EXPOSE 53 + +ENTRYPOINT ["/app/dnsp"] diff --git a/cmd/dnsp/Makefile b/cmd/dnsp/Makefile new file mode 100644 index 0000000..cd3929e --- /dev/null +++ b/cmd/dnsp/Makefile @@ -0,0 +1,6 @@ +build: + docker build . -t dnsp +serve: + docker run --rm -p 53:53/udp dnsp --resolve 8.8.4.4,8.8.8.8 --blacklist=https://hosts-file.net/download/hosts.txt --poll 1h -l 0.0.0.0:53 +debug: + docker run --rm -p 5353:53/udp dnsp --resolve 8.8.4.4,8.8.8.8 --blacklist=https://hosts-file.net/download/hosts.txt --poll 1h -l 0.0.0.0:53 diff --git a/cmd/dnsp/README.md b/cmd/dnsp/README.md new file mode 100644 index 0000000..fd14a64 --- /dev/null +++ b/cmd/dnsp/README.md @@ -0,0 +1,11 @@ +# dnsp +DNSP Server binary and docker file. + +# Building Docker Image +`make build` + +# Running Docker Container Locally (port 5353) +`make debug` + +# Running Docker Container as Server (port 53) +`make serve` From e59febfb20a3fe9e675e3cced7cee45259f87127 Mon Sep 17 00:00:00 2001 From: Eric Greer Date: Thu, 9 Nov 2017 12:57:38 +0800 Subject: [PATCH 2/7] include nslookup in dockerfile. added kubernetes deployment. tweaked readme --- cmd/dnsp/Dockerfile | 4 +++- cmd/dnsp/README.md | 9 +++++--- cmd/dnsp/deployment.yaml | 47 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 cmd/dnsp/deployment.yaml diff --git a/cmd/dnsp/Dockerfile b/cmd/dnsp/Dockerfile index 090b580..e968903 100644 --- a/cmd/dnsp/Dockerfile +++ b/cmd/dnsp/Dockerfile @@ -1,10 +1,12 @@ FROM golang:latest +RUN apt-get update +RUN apt-get install dnsutils -y RUN mkdir /app ADD *.go /app/ WORKDIR /app RUN go get -u github.com/gophergala/dnsp/... -RUN go build -o dnsp +RUN go build -o /app/dnsp EXPOSE 53 diff --git a/cmd/dnsp/README.md b/cmd/dnsp/README.md index fd14a64..6ee66a5 100644 --- a/cmd/dnsp/README.md +++ b/cmd/dnsp/README.md @@ -1,11 +1,14 @@ # dnsp DNSP Server binary and docker file. -# Building Docker Image +### Building Docker Image + `make build` -# Running Docker Container Locally (port 5353) +### Running Docker Container Locally (port 5353) + `make debug` -# Running Docker Container as Server (port 53) +### Running Docker Container as Server (port 53) + `make serve` diff --git a/cmd/dnsp/deployment.yaml b/cmd/dnsp/deployment.yaml new file mode 100644 index 0000000..3c5c22b --- /dev/null +++ b/cmd/dnsp/deployment.yaml @@ -0,0 +1,47 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: dnsp-home + labels: + app: dnsp-home +spec: + replicas: 2 + selector: + matchLabels: + app: dnsp-home + strategy: + rollingUpdate: + maxSurge: 2 + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + labels: + app: dnsp-home + name: dnsp-home + spec: + containers: + - args: + - "--blacklist=https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" + - "--poll=72h" + - "--resolve=8.8.8.8,4.4.4.4" + image: "docker.io/integrii/dnsp" + imagePullPolicy: Always + name: "dnsp-home" + readinessProbe: + exec: + command: + - "nslookup" + - "google.com." + - "127.0.0.1" + initialDelaySeconds: 10 + periodSeconds: 1 + livenessProbe: + exec: + command: + - "nslookup" + - "google.com." + - "127.0.0.1" + initialDelaySeconds: 360 + periodSeconds: 1 + terminationGracePeriodSeconds: 15 From b09147191fedcee06b7b3e89df7d838ad362cb3b Mon Sep 17 00:00:00 2001 From: Eric Greer Date: Thu, 9 Nov 2017 13:54:43 +0800 Subject: [PATCH 3/7] adding kubernetes service for AWS --- cmd/dnsp/service.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cmd/dnsp/service.yaml diff --git a/cmd/dnsp/service.yaml b/cmd/dnsp/service.yaml new file mode 100644 index 0000000..1980790 --- /dev/null +++ b/cmd/dnsp/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: dnsp-home + name: dnsp-home +spec: + ports: + - port: 53 + protocol: UDP + targetPort: 53 + selector: + app: dnsp-home + type: LoadBalancer From 5d5ef2eb985875ff12dcc13af072b4bf00e0a522 Mon Sep 17 00:00:00 2001 From: Eric Greer Date: Fri, 10 Nov 2017 00:34:08 +0800 Subject: [PATCH 4/7] improve readiness and liveness checks and limited revision history --- cmd/dnsp/deployment.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/dnsp/deployment.yaml b/cmd/dnsp/deployment.yaml index 3c5c22b..39cca5e 100644 --- a/cmd/dnsp/deployment.yaml +++ b/cmd/dnsp/deployment.yaml @@ -5,6 +5,7 @@ metadata: labels: app: dnsp-home spec: + revisionHistoryLimit: 2 replicas: 2 selector: matchLabels: @@ -34,7 +35,7 @@ spec: - "nslookup" - "google.com." - "127.0.0.1" - initialDelaySeconds: 10 + initialDelaySeconds: 5 periodSeconds: 1 livenessProbe: exec: @@ -42,6 +43,6 @@ spec: - "nslookup" - "google.com." - "127.0.0.1" - initialDelaySeconds: 360 + initialDelaySeconds: 120 periodSeconds: 1 terminationGracePeriodSeconds: 15 From 2b6a72b2c9f5c1edb671bcd3a1e303bddbb32fae Mon Sep 17 00:00:00 2001 From: Eric Greer Date: Sat, 11 Nov 2017 09:56:45 +0800 Subject: [PATCH 5/7] health check revamps --- cmd/dnsp/deployment.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/dnsp/deployment.yaml b/cmd/dnsp/deployment.yaml index 39cca5e..3e7354c 100644 --- a/cmd/dnsp/deployment.yaml +++ b/cmd/dnsp/deployment.yaml @@ -5,14 +5,14 @@ metadata: labels: app: dnsp-home spec: - revisionHistoryLimit: 2 + revisionHistoryLimit: 1 replicas: 2 selector: matchLabels: app: dnsp-home strategy: rollingUpdate: - maxSurge: 2 + maxSurge: 1 maxUnavailable: 0 type: RollingUpdate template: @@ -36,7 +36,9 @@ spec: - "google.com." - "127.0.0.1" initialDelaySeconds: 5 - periodSeconds: 1 + periodSeconds: 5 + timeoutSeconds: 3 + failureThreshold: 1 livenessProbe: exec: command: @@ -44,5 +46,7 @@ spec: - "google.com." - "127.0.0.1" initialDelaySeconds: 120 - periodSeconds: 1 + periodSeconds: 5 + timeoutSeconds: 3 + failureThreshold: 1 terminationGracePeriodSeconds: 15 From a37a4fdccf5257a4f034c20f1977816aabda41a5 Mon Sep 17 00:00:00 2001 From: Eric Greer Date: Sat, 11 Nov 2017 10:20:44 +0800 Subject: [PATCH 6/7] pod resource requirements --- cmd/dnsp/deployment.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/dnsp/deployment.yaml b/cmd/dnsp/deployment.yaml index 3e7354c..97ca516 100644 --- a/cmd/dnsp/deployment.yaml +++ b/cmd/dnsp/deployment.yaml @@ -29,6 +29,10 @@ spec: image: "docker.io/integrii/dnsp" imagePullPolicy: Always name: "dnsp-home" + resources: + requests: + memory: "50Mi" + cpu: "100m" readinessProbe: exec: command: From 2863d75a46ef901516443dc3fde4d5aea5d63309 Mon Sep 17 00:00:00 2001 From: Eric Greer Date: Sat, 11 Nov 2017 14:41:57 +0800 Subject: [PATCH 7/7] moving to named port --- cmd/dnsp/deployment.yaml | 16 ++++++++++------ cmd/dnsp/service.yaml | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/dnsp/deployment.yaml b/cmd/dnsp/deployment.yaml index 97ca516..d9dcda6 100644 --- a/cmd/dnsp/deployment.yaml +++ b/cmd/dnsp/deployment.yaml @@ -1,4 +1,4 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1beta1 kind: Deployment metadata: name: dnsp-home @@ -21,14 +21,15 @@ spec: app: dnsp-home name: dnsp-home spec: + terminationGracePeriodSeconds: 15 containers: - args: - - "--blacklist=https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" - - "--poll=72h" - - "--resolve=8.8.8.8,4.4.4.4" + - --blacklist=https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts + - --poll=72h + - --resolve=8.8.8.8,4.4.4.4 + name: "dnsp-home" image: "docker.io/integrii/dnsp" imagePullPolicy: Always - name: "dnsp-home" resources: requests: memory: "50Mi" @@ -53,4 +54,7 @@ spec: periodSeconds: 5 timeoutSeconds: 3 failureThreshold: 1 - terminationGracePeriodSeconds: 15 + ports: + - containerPort: 53 + name: dns-server + protocol: UDP diff --git a/cmd/dnsp/service.yaml b/cmd/dnsp/service.yaml index 1980790..27f510e 100644 --- a/cmd/dnsp/service.yaml +++ b/cmd/dnsp/service.yaml @@ -8,7 +8,7 @@ spec: ports: - port: 53 protocol: UDP - targetPort: 53 + targetPort: dns-server selector: app: dnsp-home type: LoadBalancer