From 52be1d7b1977257f4256c8111f2505206fd96632 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 6 Nov 2017 14:13:10 -0800 Subject: [PATCH] hack/scripts-dev: add Makefile, Dockerfile-test Signed-off-by: Gyu-Ho Lee --- Dockerfile-test | 57 +++++ hack/scripts-dev/Makefile | 243 ++++++++++++++++++++ hack/scripts-dev/README | 2 + hack/scripts-dev/docker-dns-srv/.Dockerfile | 48 ++++ hack/scripts-dev/docker-dns-srv/Dockerfile | 48 ++++ hack/scripts-dev/docker-dns-srv/Procfile | 5 + hack/scripts-dev/docker-dns-srv/etcd.zone | 16 ++ hack/scripts-dev/docker-dns-srv/named.conf | 23 ++ hack/scripts-dev/docker-dns-srv/rdns.zone | 13 ++ hack/scripts-dev/docker-dns-srv/resolv.conf | 1 + hack/scripts-dev/docker-dns-srv/run.sh | 16 ++ hack/scripts-dev/docker-dns/Dockerfile | 48 ++++ hack/scripts-dev/docker-dns/Procfile.tls | 6 + hack/scripts-dev/docker-dns/etcd.zone | 14 ++ hack/scripts-dev/docker-dns/named.conf | 23 ++ hack/scripts-dev/docker-dns/rdns.zone | 13 ++ hack/scripts-dev/docker-dns/resolv.conf | 1 + hack/scripts-dev/docker-dns/run.sh | 16 ++ 18 files changed, 593 insertions(+) create mode 100644 Dockerfile-test create mode 100644 hack/scripts-dev/Makefile create mode 100644 hack/scripts-dev/README create mode 100644 hack/scripts-dev/docker-dns-srv/.Dockerfile create mode 100644 hack/scripts-dev/docker-dns-srv/Dockerfile create mode 100644 hack/scripts-dev/docker-dns-srv/Procfile create mode 100644 hack/scripts-dev/docker-dns-srv/etcd.zone create mode 100644 hack/scripts-dev/docker-dns-srv/named.conf create mode 100644 hack/scripts-dev/docker-dns-srv/rdns.zone create mode 100644 hack/scripts-dev/docker-dns-srv/resolv.conf create mode 100755 hack/scripts-dev/docker-dns-srv/run.sh create mode 100644 hack/scripts-dev/docker-dns/Dockerfile create mode 100644 hack/scripts-dev/docker-dns/Procfile.tls create mode 100644 hack/scripts-dev/docker-dns/etcd.zone create mode 100644 hack/scripts-dev/docker-dns/named.conf create mode 100644 hack/scripts-dev/docker-dns/rdns.zone create mode 100644 hack/scripts-dev/docker-dns/resolv.conf create mode 100755 hack/scripts-dev/docker-dns/run.sh diff --git a/Dockerfile-test b/Dockerfile-test new file mode 100644 index 000000000..8e0be6a3f --- /dev/null +++ b/Dockerfile-test @@ -0,0 +1,57 @@ +FROM ubuntu:16.10 + +RUN rm /bin/sh && ln -s /bin/bash /bin/sh +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + +RUN apt-get -y update \ + && apt-get -y install \ + build-essential \ + gcc \ + apt-utils \ + pkg-config \ + software-properties-common \ + apt-transport-https \ + libssl-dev \ + sudo \ + bash \ + curl \ + wget \ + tar \ + git \ + netcat \ + libaspell-dev \ + libhunspell-dev \ + hunspell-en-us \ + aspell-en \ + shellcheck \ + && apt-get -y update \ + && apt-get -y upgrade \ + && apt-get -y autoremove \ + && apt-get -y autoclean + +ENV GOROOT /usr/local/go +ENV GOPATH /go +ENV PATH ${GOPATH}/bin:${GOROOT}/bin:${PATH} +ENV GO_VERSION REPLACE_ME_GO_VERSION +ENV GO_DOWNLOAD_URL https://storage.googleapis.com/golang +RUN rm -rf ${GOROOT} \ + && curl -s ${GO_DOWNLOAD_URL}/go${GO_VERSION}.linux-amd64.tar.gz | tar -v -C /usr/local/ -xz \ + && mkdir -p ${GOPATH}/src ${GOPATH}/bin \ + && go version + +RUN mkdir -p ${GOPATH}/src/github.com/coreos/etcd +WORKDIR ${GOPATH}/src/github.com/coreos/etcd + +ADD ./scripts/install-marker.sh /tmp/install-marker.sh + +RUN go get -v -u -tags spell github.com/chzchzchz/goword \ + && go get -v -u github.com/coreos/license-bill-of-materials \ + && go get -v -u honnef.co/go/tools/cmd/gosimple \ + && go get -v -u honnef.co/go/tools/cmd/unused \ + && go get -v -u honnef.co/go/tools/cmd/staticcheck \ + && go get -v -u github.com/wadey/gocovmerge \ + && go get -v -u github.com/gordonklaus/ineffassign \ + && /tmp/install-marker.sh amd64 \ + && rm -f /tmp/install-marker.sh \ + && curl -s https://codecov.io/bash >/codecov \ + && chmod 700 /codecov diff --git a/hack/scripts-dev/Makefile b/hack/scripts-dev/Makefile new file mode 100644 index 000000000..7ad3063d2 --- /dev/null +++ b/hack/scripts-dev/Makefile @@ -0,0 +1,243 @@ +# run from repository root +# +# Example: +# make clean -f ./hack/scripts-dev/Makefile +# make build -f ./hack/scripts-dev/Makefile + +.PHONY: build +build: + GO_BUILD_FLAGS="-v" ./build + ./bin/etcd --version + ETCDCTL_API=3 ./bin/etcdctl version + +clean: + rm -f ./codecov + rm -rf ./covdir + rm -f ./*.log + rm -f ./bin/Dockerfile-release + rm -rf ./bin/*.etcd + rm -rf ./gopath + rm -rf ./release + rm -f ./integration/127.0.0.1:* ./integration/localhost:* + rm -f ./clientv3/integration/127.0.0.1:* ./clientv3/integration/localhost:* + rm -f ./clientv3/ordering/127.0.0.1:* ./clientv3/ordering/localhost:* + +_GO_VERSION = 1.9.2 +ifdef GO_VERSION + _GO_VERSION = $(GO_VERSION) +endif + +# Example: +# GO_VERSION=1.8.5 make build-docker-test -f ./hack/scripts-dev/Makefile +# make build-docker-test -f ./hack/scripts-dev/Makefile +# gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io +# GO_VERSION=1.8.5 make push-docker-test -f ./hack/scripts-dev/Makefile +# make push-docker-test -f ./hack/scripts-dev/Makefile +# gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com +# GO_VERSION=1.8.5 make pull-docker-test -f ./hack/scripts-dev/Makefile +# make pull-docker-test -f ./hack/scripts-dev/Makefile + +build-docker-test: + $(info GO_VERSION: $(_GO_VERSION)) + @cat ./Dockerfile-test | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \ + > ./.Dockerfile-test + docker build \ + --tag gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \ + --file ./.Dockerfile-test . + +push-docker-test: + $(info GO_VERSION: $(_GO_VERSION)) + gcloud docker -- push gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) + +pull-docker-test: + $(info GO_VERSION: $(_GO_VERSION)) + docker pull gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) + +compile-with-docker-test: + $(info GO_VERSION: $(_GO_VERSION)) + docker run \ + --rm \ + --volume=`pwd`/:/etcd \ + gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \ + /bin/bash -c "cd /etcd && GO_BUILD_FLAGS=-v ./build && ./bin/etcd --version" + +# Local machine: +# TEST_OPTS="PASSES='fmt'" make test -f ./hack/scripts-dev/Makefile +# TEST_OPTS="PASSES='fmt bom dep compile build unit'" make test -f ./hack/scripts-dev/Makefile +# TEST_OPTS="RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional'" make test -f ./hack/scripts-dev/Makefile +# TEST_OPTS="PASSES='build grpcproxy'" make test -f ./hack/scripts-dev/Makefile +# +# Example (test with docker): +# make pull-docker-test -f ./hack/scripts-dev/Makefile +# TEST_OPTS="PASSES='fmt'" make docker-test -f ./hack/scripts-dev/Makefile +# TEST_OPTS="VERBOSE=2 PASSES='unit'" make docker-test -f ./hack/scripts-dev/Makefile +# +# Travis CI (test with docker): +# TEST_OPTS="PASSES='fmt bom dep compile build unit'" make docker-test -f ./hack/scripts-dev/Makefile +# +# Semaphore CI (test with docker): +# TEST_OPTS="RELEASE_TEST=y INTEGRATION=y PASSES='build unit release integration_e2e functional'" make docker-test -f ./hack/scripts-dev/Makefile +# TEST_OPTS="GOARCH=386 PASSES='build unit integration_e2e'" make docker-test -f ./hack/scripts-dev/Makefile +# +# grpc-proxy tests (test with docker): +# TEST_OPTS="PASSES='build grpcproxy'" make docker-test -f ./hack/scripts-dev/Makefile + +TEST_SUFFIX = $(shell date +%s | base64 | head -c 15) + +_TEST_OPTS = "PASSES='unit'" +ifdef TEST_OPTS + _TEST_OPTS = $(TEST_OPTS) +endif + +.PHONY: test +test: + $(info TEST_OPTS: $(_TEST_OPTS)) + $(info log-file: test-$(TEST_SUFFIX).log) + $(_TEST_OPTS) ./test 2>&1 | tee test-$(TEST_SUFFIX).log + ! egrep "(--- FAIL:|leak)" -A10 -B50 test-$(TEST_SUFFIX).log + +docker-test: + $(info GO_VERSION: $(_GO_VERSION)) + $(info TEST_OPTS: $(_TEST_OPTS)) + $(info log-file: test-$(TEST_SUFFIX).log) + docker run \ + --rm \ + --volume=`pwd`:/go/src/github.com/coreos/etcd \ + gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \ + /bin/bash -c "$(_TEST_OPTS) ./test 2>&1 | tee test-$(TEST_SUFFIX).log" + ! egrep "(--- FAIL:|leak)" -A10 -B50 test-$(TEST_SUFFIX).log + +docker-test-coverage: + $(info GO_VERSION: $(_GO_VERSION)) + $(info log-file: docker-test-coverage-$(TEST_SUFFIX).log) + docker run \ + --rm \ + --volume=`pwd`:/go/src/github.com/coreos/etcd \ + gcr.io/etcd-development/etcd-test:go$(_GO_VERSION) \ + /bin/bash -c "COVERDIR=covdir PASSES='build build_cov cov' ./test 2>&1 | tee docker-test-coverage-$(TEST_SUFFIX).log && /codecov -t 6040de41-c073-4d6f-bbf8-d89256ef31e1" + ! egrep "(--- FAIL:|leak)" -A10 -B50 docker-test-coverage-$(TEST_SUFFIX).log + +# build release container image with Linux +_ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound") +ifdef ETCD_VERSION + _ETCD_VERSION = $(ETCD_VERSION) +endif + +# Example: +# ETCD_VERSION=v3.3.0-test.0 make build-docker-release-master -f ./hack/scripts-dev/Makefile +# ETCD_VERSION=v3.3.0-test.0 make push-docker-release-master -f ./hack/scripts-dev/Makefile +# gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com + +build-docker-release-master: compile-with-docker-test + $(info ETCD_VERSION: $(_ETCD_VERSION)) + cp ./Dockerfile-release ./bin/Dockerfile-release + docker build \ + --tag gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \ + --file ./bin/Dockerfile-release \ + ./bin + rm -f ./bin/Dockerfile-release + + docker run \ + --rm \ + gcr.io/etcd-development/etcd:$(_ETCD_VERSION) \ + /bin/sh -c "/usr/local/bin/etcd --version && ETCDCTL_API=3 /usr/local/bin/etcdctl version" + +push-docker-release-master: + $(info ETCD_VERSION: $(_ETCD_VERSION)) + gcloud docker -- push gcr.io/etcd-development/etcd:$(_ETCD_VERSION) + +# Example: +# make build-docker-test -f ./hack/scripts-dev/Makefile +# make compile-with-docker-test -f ./hack/scripts-dev/Makefile +# make build-docker-dns-test -f ./hack/scripts-dev/Makefile +# gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io +# make push-docker-dns-test -f ./hack/scripts-dev/Makefile +# gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com +# make pull-docker-dns-test -f ./hack/scripts-dev/Makefile +# make docker-dns-test-run -f ./hack/scripts-dev/Makefile + +# build base container image for DNS testing +build-docker-dns-test: + $(info GO_VERSION: $(_GO_VERSION)) + @cat ./hack/scripts-dev/docker-dns/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \ + > ./hack/scripts-dev/docker-dns/.Dockerfile + + docker build \ + --tag gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \ + --file ./hack/scripts-dev/docker-dns/.Dockerfile \ + ./hack/scripts-dev/docker-dns + + docker run \ + --rm \ + --dns 127.0.0.1 \ + gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \ + /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig etcd.local" + +push-docker-dns-test: + $(info GO_VERSION: $(_GO_VERSION)) + gcloud docker -- push gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) + +pull-docker-dns-test: + $(info GO_VERSION: $(_GO_VERSION)) + docker pull gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) + +# run DNS tests inside container +docker-dns-test-run: + $(info GO_VERSION: $(_GO_VERSION)) + docker run \ + --rm \ + --tty \ + --dns 127.0.0.1 \ + --volume=`pwd`/bin:/etcd \ + --volume=`pwd`/integration/fixtures:/certs \ + gcr.io/etcd-development/etcd-dns-test:go$(_GO_VERSION) \ + /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd" + +# Example: +# make build-docker-test -f ./hack/scripts-dev/Makefile +# make compile-with-docker-test -f ./hack/scripts-dev/Makefile +# make build-docker-dns-srv-test -f ./hack/scripts-dev/Makefile +# gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd.json)" https://gcr.io +# make push-docker-dns-srv-test -f ./hack/scripts-dev/Makefile +# gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com +# make pull-docker-dns-srv-test -f ./hack/scripts-dev/Makefile +# make docker-dns-srv-test-run -f ./hack/scripts-dev/Makefile + +# build base container image for DNS/SRV testing +build-docker-dns-srv-test: + $(info GO_VERSION: $(_GO_VERSION)) + @cat ./hack/scripts-dev/docker-dns-srv/Dockerfile | sed s/REPLACE_ME_GO_VERSION/$(_GO_VERSION)/ \ + > ./hack/scripts-dev/docker-dns-srv/.Dockerfile + + docker build \ + --tag gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \ + --file ./hack/scripts-dev/docker-dns-srv/.Dockerfile \ + ./hack/scripts-dev/docker-dns-srv + + docker run \ + --rm \ + --dns 127.0.0.1 \ + gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \ + /bin/bash -c "/etc/init.d/bind9 start && cat /dev/null >/etc/hosts && dig +noall +answer SRV _etcd-client-ssl._tcp.etcd.local && dig +noall +answer SRV _etcd-server-ssl._tcp.etcd.local && dig +noall +answer m1.etcd.local m2.etcd.local m3.etcd.local" + +push-docker-dns-srv-test: + $(info GO_VERSION: $(_GO_VERSION)) + gcloud docker -- push gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) + +pull-docker-dns-srv-test: + $(info GO_VERSION: $(_GO_VERSION)) + docker pull gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) + +# run DNS/SRV tests inside container +docker-dns-srv-test-run: + $(info GO_VERSION: $(_GO_VERSION)) + docker run \ + --rm \ + --tty \ + --dns 127.0.0.1 \ + --volume=`pwd`/bin:/etcd \ + --volume=`pwd`/integration/fixtures:/certs \ + gcr.io/etcd-development/etcd-dns-srv-test:go$(_GO_VERSION) \ + /bin/bash -c "cd /etcd && /run.sh && rm -rf m*.etcd" + +# TODO: add DNS integration tests diff --git a/hack/scripts-dev/README b/hack/scripts-dev/README new file mode 100644 index 000000000..16c3e583d --- /dev/null +++ b/hack/scripts-dev/README @@ -0,0 +1,2 @@ + +scripts for etcd development diff --git a/hack/scripts-dev/docker-dns-srv/.Dockerfile b/hack/scripts-dev/docker-dns-srv/.Dockerfile new file mode 100644 index 000000000..8d138e4ba --- /dev/null +++ b/hack/scripts-dev/docker-dns-srv/.Dockerfile @@ -0,0 +1,48 @@ +FROM ubuntu:16.10 + +RUN rm /bin/sh && ln -s /bin/bash /bin/sh +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + +RUN apt-get -y update \ + && apt-get -y install \ + build-essential \ + gcc \ + apt-utils \ + pkg-config \ + software-properties-common \ + apt-transport-https \ + libssl-dev \ + sudo \ + bash \ + curl \ + tar \ + git \ + netcat \ + bind9 \ + dnsutils \ + && apt-get -y update \ + && apt-get -y upgrade \ + && apt-get -y autoremove \ + && apt-get -y autoclean + +ENV GOROOT /usr/local/go +ENV GOPATH /go +ENV PATH ${GOPATH}/bin:${GOROOT}/bin:${PATH} +ENV GO_VERSION 1.9.2 +ENV GO_DOWNLOAD_URL https://storage.googleapis.com/golang +RUN rm -rf ${GOROOT} \ + && curl -s ${GO_DOWNLOAD_URL}/go${GO_VERSION}.linux-amd64.tar.gz | tar -v -C /usr/local/ -xz \ + && mkdir -p ${GOPATH}/src ${GOPATH}/bin \ + && go version + +RUN mkdir -p /var/bind /etc/bind +RUN chown root:bind /var/bind /etc/bind +ADD Procfile /Procfile +ADD run.sh /run.sh + +ADD named.conf etcd.zone rdns.zone /etc/bind/ +RUN chown root:bind /etc/bind/named.conf /etc/bind/etcd.zone /etc/bind/rdns.zone +ADD resolv.conf /etc/resolv.conf + +RUN go get github.com/mattn/goreman +CMD ["/run.sh"] diff --git a/hack/scripts-dev/docker-dns-srv/Dockerfile b/hack/scripts-dev/docker-dns-srv/Dockerfile new file mode 100644 index 000000000..e53787e4f --- /dev/null +++ b/hack/scripts-dev/docker-dns-srv/Dockerfile @@ -0,0 +1,48 @@ +FROM ubuntu:16.10 + +RUN rm /bin/sh && ln -s /bin/bash /bin/sh +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + +RUN apt-get -y update \ + && apt-get -y install \ + build-essential \ + gcc \ + apt-utils \ + pkg-config \ + software-properties-common \ + apt-transport-https \ + libssl-dev \ + sudo \ + bash \ + curl \ + tar \ + git \ + netcat \ + bind9 \ + dnsutils \ + && apt-get -y update \ + && apt-get -y upgrade \ + && apt-get -y autoremove \ + && apt-get -y autoclean + +ENV GOROOT /usr/local/go +ENV GOPATH /go +ENV PATH ${GOPATH}/bin:${GOROOT}/bin:${PATH} +ENV GO_VERSION REPLACE_ME_GO_VERSION +ENV GO_DOWNLOAD_URL https://storage.googleapis.com/golang +RUN rm -rf ${GOROOT} \ + && curl -s ${GO_DOWNLOAD_URL}/go${GO_VERSION}.linux-amd64.tar.gz | tar -v -C /usr/local/ -xz \ + && mkdir -p ${GOPATH}/src ${GOPATH}/bin \ + && go version + +RUN mkdir -p /var/bind /etc/bind +RUN chown root:bind /var/bind /etc/bind +ADD Procfile /Procfile +ADD run.sh /run.sh + +ADD named.conf etcd.zone rdns.zone /etc/bind/ +RUN chown root:bind /etc/bind/named.conf /etc/bind/etcd.zone /etc/bind/rdns.zone +ADD resolv.conf /etc/resolv.conf + +RUN go get github.com/mattn/goreman +CMD ["/run.sh"] diff --git a/hack/scripts-dev/docker-dns-srv/Procfile b/hack/scripts-dev/docker-dns-srv/Procfile new file mode 100644 index 000000000..e1b2c411c --- /dev/null +++ b/hack/scripts-dev/docker-dns-srv/Procfile @@ -0,0 +1,5 @@ +etcd1: ./etcd --name m1 --listen-client-urls https://127.0.0.1:2379 --advertise-client-urls https://m1.etcd.local:2379 --listen-peer-urls https://127.0.0.1:2380 --initial-advertise-peer-urls=https://m1.etcd.local:2380 --initial-cluster-token tkn --discovery-srv=etcd.local --initial-cluster-state new --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --trusted-ca-file=/certs/ca.crt --client-cert-auth + +etcd2: ./etcd --name m2 --listen-client-urls https://127.0.0.1:22379 --advertise-client-urls https://m2.etcd.local:22379 --listen-peer-urls https://127.0.0.1:22380 --initial-advertise-peer-urls=https://m2.etcd.local:22380 --initial-cluster-token tkn --discovery-srv=etcd.local --initial-cluster-state new --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --trusted-ca-file=/certs/ca.crt --client-cert-auth + +etcd3: ./etcd --name m3 --listen-client-urls https://127.0.0.1:32379 --advertise-client-urls https://m3.etcd.local:32379 --listen-peer-urls https://127.0.0.1:32380 --initial-advertise-peer-urls=https://m3.etcd.local:32380 --initial-cluster-token tkn --discovery-srv=etcd.local --initial-cluster-state new --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --trusted-ca-file=/certs/ca.crt --client-cert-auth diff --git a/hack/scripts-dev/docker-dns-srv/etcd.zone b/hack/scripts-dev/docker-dns-srv/etcd.zone new file mode 100644 index 000000000..e501ed399 --- /dev/null +++ b/hack/scripts-dev/docker-dns-srv/etcd.zone @@ -0,0 +1,16 @@ +etcd.local. IN SOA bindhostname. admin.etcd.local. ( +1452607488 +10800 +3600 +604800 +38400 ) +etcd.local. IN NS bindhostname. +m1.etcd.local. 300 IN A 127.0.0.1 +m2.etcd.local. 300 IN A 127.0.0.1 +m3.etcd.local. 300 IN A 127.0.0.1 +_etcd-client-ssl._tcp 300 IN SRV 0 0 2379 m1.etcd.local. +_etcd-client-ssl._tcp 300 IN SRV 0 0 22379 m2.etcd.local. +_etcd-client-ssl._tcp 300 IN SRV 0 0 32379 m3.etcd.local. +_etcd-server-ssl._tcp 300 IN SRV 0 0 2380 m1.etcd.local. +_etcd-server-ssl._tcp 300 IN SRV 0 0 22380 m2.etcd.local. +_etcd-server-ssl._tcp 300 IN SRV 0 0 32380 m3.etcd.local. \ No newline at end of file diff --git a/hack/scripts-dev/docker-dns-srv/named.conf b/hack/scripts-dev/docker-dns-srv/named.conf new file mode 100644 index 000000000..83549305c --- /dev/null +++ b/hack/scripts-dev/docker-dns-srv/named.conf @@ -0,0 +1,23 @@ +options { + directory "/var/bind"; + listen-on { 127.0.0.1; }; + listen-on-v6 { none; }; + allow-transfer { + none; + }; + // If you have problems and are behind a firewall: + query-source address * port 53; + pid-file "/var/run/named/named.pid"; + allow-recursion { none; }; + recursion no; +}; + +zone "etcd.local" IN { + type master; + file "/etc/bind/etcd.zone"; +}; + +zone "0.0.127.in-addr.arpa" { + type master; + file "/etc/bind/rdns.zone"; +}; diff --git a/hack/scripts-dev/docker-dns-srv/rdns.zone b/hack/scripts-dev/docker-dns-srv/rdns.zone new file mode 100644 index 000000000..fb71b30b1 --- /dev/null +++ b/hack/scripts-dev/docker-dns-srv/rdns.zone @@ -0,0 +1,13 @@ +$TTL 86400 +@ IN SOA etcdns.local. root.etcdns.local. ( + 100500 ; Serial + 604800 ; Refresh + 86400 ; Retry + 2419200 ; Expire + 86400 ) ; Negative Cache TTL + IN NS ns.etcdns.local. + IN A 127.0.0.1 + +1 IN PTR m1.etcd.local. +1 IN PTR m2.etcd.local. +1 IN PTR m3.etcd.local. diff --git a/hack/scripts-dev/docker-dns-srv/resolv.conf b/hack/scripts-dev/docker-dns-srv/resolv.conf new file mode 100644 index 000000000..bbc8559cd --- /dev/null +++ b/hack/scripts-dev/docker-dns-srv/resolv.conf @@ -0,0 +1 @@ +nameserver 127.0.0.1 diff --git a/hack/scripts-dev/docker-dns-srv/run.sh b/hack/scripts-dev/docker-dns-srv/run.sh new file mode 100755 index 000000000..7c7415f8d --- /dev/null +++ b/hack/scripts-dev/docker-dns-srv/run.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +/etc/init.d/bind9 start + +# get rid of hosts so go lookup won't resolve 127.0.0.1 to localhost +cat /dev/null >/etc/hosts + +goreman -f /Procfile start & +sleep 7s + +ETCDCTL_API=3 ./etcdctl \ + --cacert=/certs/ca.crt \ + --cert=/certs/server-wildcard.crt \ + --key=/certs//server-wildcard.key.insecure \ + --discovery-srv etcd.local \ + put foo bar diff --git a/hack/scripts-dev/docker-dns/Dockerfile b/hack/scripts-dev/docker-dns/Dockerfile new file mode 100644 index 000000000..7b8548d8e --- /dev/null +++ b/hack/scripts-dev/docker-dns/Dockerfile @@ -0,0 +1,48 @@ +FROM ubuntu:16.10 + +RUN rm /bin/sh && ln -s /bin/bash /bin/sh +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + +RUN apt-get -y update \ + && apt-get -y install \ + build-essential \ + gcc \ + apt-utils \ + pkg-config \ + software-properties-common \ + apt-transport-https \ + libssl-dev \ + sudo \ + bash \ + curl \ + tar \ + git \ + netcat \ + bind9 \ + dnsutils \ + && apt-get -y update \ + && apt-get -y upgrade \ + && apt-get -y autoremove \ + && apt-get -y autoclean + +ENV GOROOT /usr/local/go +ENV GOPATH /go +ENV PATH ${GOPATH}/bin:${GOROOT}/bin:${PATH} +ENV GO_VERSION REPLACE_ME_GO_VERSION +ENV GO_DOWNLOAD_URL https://storage.googleapis.com/golang +RUN rm -rf ${GOROOT} \ + && curl -s ${GO_DOWNLOAD_URL}/go${GO_VERSION}.linux-amd64.tar.gz | tar -v -C /usr/local/ -xz \ + && mkdir -p ${GOPATH}/src ${GOPATH}/bin \ + && go version + +RUN mkdir -p /var/bind /etc/bind +RUN chown root:bind /var/bind /etc/bind +ADD Procfile.tls /Procfile.tls +ADD run.sh /run.sh + +ADD named.conf etcd.zone rdns.zone /etc/bind/ +RUN chown root:bind /etc/bind/named.conf /etc/bind/etcd.zone /etc/bind/rdns.zone +ADD resolv.conf /etc/resolv.conf + +RUN go get github.com/mattn/goreman +CMD ["/run.sh"] diff --git a/hack/scripts-dev/docker-dns/Procfile.tls b/hack/scripts-dev/docker-dns/Procfile.tls new file mode 100644 index 000000000..c4842ae56 --- /dev/null +++ b/hack/scripts-dev/docker-dns/Procfile.tls @@ -0,0 +1,6 @@ +# Use goreman to run `go get github.com/mattn/goreman` +etcd1: ./etcd --name m1 --listen-client-urls https://127.0.0.1:2379 --advertise-client-urls https://m1.etcd.local:2379 --listen-peer-urls https://127.0.0.1:2380 --initial-advertise-peer-urls=https://m1.etcd.local:2380 --initial-cluster-token tkn --initial-cluster=m1=https://m1.etcd.local:2380,m2=https://m2.etcd.local:22380,m3=https://m3.etcd.local:32380 --initial-cluster-state new --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --trusted-ca-file=/certs/ca.crt --client-cert-auth + +etcd2: ./etcd --name m2 --listen-client-urls https://127.0.0.1:22379 --advertise-client-urls https://m2.etcd.local:22379 --listen-peer-urls https://127.0.0.1:22380 --initial-advertise-peer-urls=https://m2.etcd.local:22380 --initial-cluster-token tkn --initial-cluster=m1=https://m1.etcd.local:2380,m2=https://m2.etcd.local:22380,m3=https://m3.etcd.local:32380 --initial-cluster-state new --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --trusted-ca-file=/certs/ca.crt --client-cert-auth + +etcd3: ./etcd --name m3 --listen-client-urls https://127.0.0.1:32379 --advertise-client-urls https://m3.etcd.local:32379 --listen-peer-urls https://127.0.0.1:32380 --initial-advertise-peer-urls=https://m3.etcd.local:32380 --initial-cluster-token tkn --initial-cluster=m1=https://m1.etcd.local:2380,m2=https://m2.etcd.local:22380,m3=https://m3.etcd.local:32380 --initial-cluster-state new --peer-cert-file=/certs/server-wildcard.crt --peer-key-file=/certs/server-wildcard.key.insecure --peer-trusted-ca-file=/certs/ca.crt --peer-client-cert-auth --cert-file=/certs/server-wildcard.crt --key-file=/certs/server-wildcard.key.insecure --trusted-ca-file=/certs/ca.crt --client-cert-auth \ No newline at end of file diff --git a/hack/scripts-dev/docker-dns/etcd.zone b/hack/scripts-dev/docker-dns/etcd.zone new file mode 100644 index 000000000..03c15fe8e --- /dev/null +++ b/hack/scripts-dev/docker-dns/etcd.zone @@ -0,0 +1,14 @@ +$TTL 86400 +@ IN SOA etcdns.local. root.etcdns.local. ( + 100500 ; Serial + 604800 ; Refresh + 86400 ; Retry + 2419200 ; Expire + 86400 ) ; Negative Cache TTL + IN NS ns.etcdns.local. + IN A 127.0.0.1 + +ns IN A 127.0.0.1 +m1 IN A 127.0.0.1 +m2 IN A 127.0.0.1 +m3 IN A 127.0.0.1 diff --git a/hack/scripts-dev/docker-dns/named.conf b/hack/scripts-dev/docker-dns/named.conf new file mode 100644 index 000000000..83549305c --- /dev/null +++ b/hack/scripts-dev/docker-dns/named.conf @@ -0,0 +1,23 @@ +options { + directory "/var/bind"; + listen-on { 127.0.0.1; }; + listen-on-v6 { none; }; + allow-transfer { + none; + }; + // If you have problems and are behind a firewall: + query-source address * port 53; + pid-file "/var/run/named/named.pid"; + allow-recursion { none; }; + recursion no; +}; + +zone "etcd.local" IN { + type master; + file "/etc/bind/etcd.zone"; +}; + +zone "0.0.127.in-addr.arpa" { + type master; + file "/etc/bind/rdns.zone"; +}; diff --git a/hack/scripts-dev/docker-dns/rdns.zone b/hack/scripts-dev/docker-dns/rdns.zone new file mode 100644 index 000000000..fb71b30b1 --- /dev/null +++ b/hack/scripts-dev/docker-dns/rdns.zone @@ -0,0 +1,13 @@ +$TTL 86400 +@ IN SOA etcdns.local. root.etcdns.local. ( + 100500 ; Serial + 604800 ; Refresh + 86400 ; Retry + 2419200 ; Expire + 86400 ) ; Negative Cache TTL + IN NS ns.etcdns.local. + IN A 127.0.0.1 + +1 IN PTR m1.etcd.local. +1 IN PTR m2.etcd.local. +1 IN PTR m3.etcd.local. diff --git a/hack/scripts-dev/docker-dns/resolv.conf b/hack/scripts-dev/docker-dns/resolv.conf new file mode 100644 index 000000000..bbc8559cd --- /dev/null +++ b/hack/scripts-dev/docker-dns/resolv.conf @@ -0,0 +1 @@ +nameserver 127.0.0.1 diff --git a/hack/scripts-dev/docker-dns/run.sh b/hack/scripts-dev/docker-dns/run.sh new file mode 100755 index 000000000..5e877c7b9 --- /dev/null +++ b/hack/scripts-dev/docker-dns/run.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +/etc/init.d/bind9 start + +# get rid of hosts so go lookup won't resolve 127.0.0.1 to localhost +cat /dev/null >/etc/hosts + +goreman -f /Procfile.tls start & +sleep 7s + +ETCDCTL_API=3 ./etcdctl \ + --cacert=/certs/ca.crt \ + --cert=/certs/server-wildcard.crt \ + --key=/certs//server-wildcard.key.insecure \ + --endpoints=https://m1.etcd.local:2379,https://m2.etcd.local:22379,https://m3.etcd.local:32379 \ + put abc def