Skip to content

Commit c7b23bd

Browse files
author
haotao geng
authored
Merge pull request #31 from FabEdge/v0.1.0
V0.1.0
2 parents 056c495 + e1754f6 commit c7b23bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+8907
-419
lines changed

.github/workflows/main.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- 'v*'
8+
branches:
9+
- 'v*'
10+
paths-ignore:
11+
- 'docs/**'
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
include:
19+
- platforms: linux/amd64,linux/arm64,linux/arm/v7
20+
tags: fabedge/service-hub
21+
file: build/service-hub/Dockerfile
22+
23+
- platforms: linux/amd64,linux/arm64,linux/arm/v7
24+
tags: fabedge/fabdns
25+
file: build/fabdns/Dockerfile
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
30+
- name: Set tags
31+
shell: bash
32+
env:
33+
TAGS: ${{ matrix.tags }}
34+
run: |
35+
if [[ ${TAGS} =~ ":" ]]; then
36+
echo "::set-output name=tags::${TAGS}"
37+
else
38+
echo "::set-output name=tags::${TAGS}:${GITHUB_REF##*/}"
39+
fi
40+
id: set_tags
41+
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v1
44+
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v1
47+
48+
- name: Login to DockerHub
49+
uses: docker/login-action@v1
50+
with:
51+
username: ${{ secrets.DOCKER_USERNAME }}
52+
password: ${{ secrets.DOCKER_PASSWORD }}
53+
54+
- name: Build and push
55+
uses: docker/build-push-action@v2
56+
with:
57+
context: .
58+
platforms: ${{ matrix.platforms }}
59+
push: true
60+
tags: ${{ steps.set_tags.outputs.tags }}
61+
file: ${{ matrix.file }}

.github/workflows/sync2gitee.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: sync2gitee
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
branches:
8+
- '*'
9+
10+
jobs:
11+
repo-sync:
12+
env:
13+
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
14+
dst_token: ${{ secrets.GITEE_TOKEN }}
15+
gitee_user: ${{ secrets.GITEE_USER }}
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
with:
20+
persist-credentials: false
21+
22+
- name: sync github -> gitee
23+
uses: Yikun/hub-mirror-action@master
24+
if: env.dst_key && env.dst_token && env.gitee_user
25+
with:
26+
src: 'github/${{ github.repository_owner }}'
27+
dst: 'gitee/${{ secrets.GITEE_USER }}'
28+
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
29+
dst_token: ${{ secrets.GITEE_TOKEN }}
30+
account_type: org
31+
static_list: ${{ github.event.repository.name }}

Makefile

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,59 @@
1-
CRD_OPTIONS ?= "crd:trivialVersions=true"
1+
OUTPUT_DIR ?= _output
2+
3+
VERSION := v0.1.0.alpha
4+
BUILD_TIME := $(shell date -u '+%Y-%m-%d_%H:%M:%S%z')
5+
GIT_COMMIT := $(shell git rev-parse --short HEAD)
6+
META := github.com/fabedge/fab-dns/pkg/about
7+
FLAG_VERSION := ${META}.version=${VERSION}
8+
FLAG_BUILD_TIME := ${META}.buildTime=${BUILD_TIME}
9+
FLAG_GIT_COMMIT := ${META}.gitCommit=${GIT_COMMIT}
10+
GOLDFLAGS ?= -s -w
11+
LDFLAGS := -ldflags "${GOLDFLAGS} -X ${FLAG_VERSION} -X ${FLAG_BUILD_TIME} -X ${FLAG_GIT_COMMIT}"
12+
13+
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true"
14+
KUBEBUILDER_VERSION ?= 2.3.1
15+
GOOS ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
16+
GOARCH ?= amd64
17+
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
18+
ifeq (,$(shell go env GOBIN))
19+
GOBIN=$(shell go env GOPATH)/bin
20+
else
21+
GOBIN=$(shell go env GOBIN)
22+
endif
23+
24+
export KUBEBUILDER_ASSETS ?= $(GOBIN)
25+
export ACK_GINKGO_DEPRECATIONS ?= 1.16.4
26+
27+
fmt:
28+
go fmt ./...
29+
30+
vet:
31+
go vet ./...
32+
33+
bin: $(if $(QUICK),, fmt vet) service-hub
34+
35+
service-hub:
36+
GOOS=${GOOS} go build ${LDFLAGS} -o ${OUTPUT_DIR}/$@ ./cmd/$@
37+
38+
service-hub-image:
39+
docker build -t fabedge/service-hub:latest -f build/service-hub/Dockerfile .
40+
41+
fabdns:
42+
GOOS=${GOOS} go build -ldflags="-X github.com/coredns/coredns/coremain.GitCommit=$(GIT_COMMIT)" -o ${OUTPUT_DIR}/$@ ./cmd/$@
43+
44+
fabdns-image:
45+
docker build -t fabedge/fabdns:latest -f build/fabdns/Dockerfile .
46+
47+
.PHONY: test
48+
test:
49+
ifneq (,$(shell which ginkgo))
50+
ginkgo ./pkg/...
51+
else
52+
go test ./pkg/...
53+
endif
54+
55+
e2e-test:
56+
go test ${LDFLAGS} -c ./test/e2e -o ${OUTPUT_DIR}/fabdns-e2e.test
257

358
# Generate manifests e.g. CRD, RBAC etc.
459
manifests: controller-gen
@@ -17,7 +72,7 @@ ifeq (, $(shell which controller-gen))
1772
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
1873
cd $$CONTROLLER_GEN_TMP_DIR ;\
1974
go mod init tmp ;\
20-
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 ;\
75+
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.7.0 ;\
2176
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
2277
}
2378
CONTROLLER_GEN=$(GOBIN)/controller-gen

build/fabdns/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM golang:1.16.4 as builder
2+
COPY . /fab-dns
3+
RUN cd /fab-dns && make fabdns QUICK=1 CGO_ENABLED=0 GOPROXY=https://goproxy.cn,direct
4+
5+
FROM alpine:3.15
6+
COPY --from=builder /fab-dns/_output/fabdns /usr/local/bin/
7+
8+
ENTRYPOINT ["/usr/local/bin/fabdns"]

build/service-hub/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM golang:1.16.4 as builder
2+
COPY . /fab-dns
3+
RUN cd /fab-dns && make service-hub QUICK=1 CGO_ENABLED=0 GOPROXY=https://goproxy.cn,direct
4+
5+
FROM alpine:3.15
6+
COPY --from=builder /fab-dns/_output/service-hub /usr/local/bin/
7+
8+
ENTRYPOINT ["/usr/local/bin/service-hub"]

cmd/fabdns/main.go

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package main
2+
3+
// build with external golang source code
4+
// https://coredns.io/2017/07/25/compile-time-enabling-or-disabling-plugins/#build-with-external-golang-source-code
5+
6+
import (
7+
_ "github.com/caddyserver/caddy/onevent"
8+
"github.com/coredns/coredns/core/dnsserver"
9+
"github.com/coredns/coredns/coremain"
10+
_ "github.com/coredns/coredns/plugin/any"
11+
_ "github.com/coredns/coredns/plugin/auto"
12+
_ "github.com/coredns/coredns/plugin/autopath"
13+
_ "github.com/coredns/coredns/plugin/bind"
14+
_ "github.com/coredns/coredns/plugin/cache"
15+
_ "github.com/coredns/coredns/plugin/cancel"
16+
_ "github.com/coredns/coredns/plugin/chaos"
17+
_ "github.com/coredns/coredns/plugin/debug"
18+
_ "github.com/coredns/coredns/plugin/dnssec"
19+
_ "github.com/coredns/coredns/plugin/dnstap"
20+
_ "github.com/coredns/coredns/plugin/erratic"
21+
_ "github.com/coredns/coredns/plugin/errors"
22+
_ "github.com/coredns/coredns/plugin/etcd"
23+
_ "github.com/coredns/coredns/plugin/file"
24+
_ "github.com/coredns/coredns/plugin/forward"
25+
_ "github.com/coredns/coredns/plugin/grpc"
26+
_ "github.com/coredns/coredns/plugin/health"
27+
_ "github.com/coredns/coredns/plugin/hosts"
28+
_ "github.com/coredns/coredns/plugin/k8s_external"
29+
_ "github.com/coredns/coredns/plugin/loadbalance"
30+
_ "github.com/coredns/coredns/plugin/log"
31+
_ "github.com/coredns/coredns/plugin/loop"
32+
_ "github.com/coredns/coredns/plugin/metadata"
33+
_ "github.com/coredns/coredns/plugin/metrics"
34+
_ "github.com/coredns/coredns/plugin/nsid"
35+
_ "github.com/coredns/coredns/plugin/pprof"
36+
_ "github.com/coredns/coredns/plugin/ready"
37+
_ "github.com/coredns/coredns/plugin/reload"
38+
_ "github.com/coredns/coredns/plugin/rewrite"
39+
_ "github.com/coredns/coredns/plugin/root"
40+
_ "github.com/coredns/coredns/plugin/route53"
41+
_ "github.com/coredns/coredns/plugin/secondary"
42+
_ "github.com/coredns/coredns/plugin/template"
43+
_ "github.com/coredns/coredns/plugin/tls"
44+
_ "github.com/coredns/coredns/plugin/trace"
45+
_ "github.com/coredns/coredns/plugin/whoami"
46+
47+
_ "github.com/fabedge/fab-dns/pkg/fabdns"
48+
)
49+
50+
var directives = []string{
51+
"metadata",
52+
"cancel",
53+
"tls",
54+
"reload",
55+
"nsid",
56+
"root",
57+
"bind",
58+
"debug",
59+
"trace",
60+
"ready",
61+
"health",
62+
"pprof",
63+
"prometheus",
64+
"errors",
65+
"log",
66+
"dnstap",
67+
"any",
68+
"chaos",
69+
"loadbalance",
70+
"cache",
71+
"rewrite",
72+
"dnssec",
73+
"autopath",
74+
"template",
75+
"hosts",
76+
"route53",
77+
"k8s_external",
78+
"fabdns",
79+
"file",
80+
"auto",
81+
"secondary",
82+
"etcd",
83+
"loop",
84+
"forward",
85+
"grpc",
86+
"erratic",
87+
"whoami",
88+
"on",
89+
}
90+
91+
func init() {
92+
dnsserver.Directives = directives
93+
}
94+
95+
func main() {
96+
coremain.Run()
97+
}

cmd/service-hub/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"os"
5+
6+
service_hub "github.com/fabedge/fab-dns/pkg/service-hub"
7+
)
8+
9+
func main() {
10+
if err := service_hub.Execute(); err != nil {
11+
os.Exit(1)
12+
}
13+
}

deploy/coredns-configmap.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# 请参考docs/fabdns-guideline.md
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: coredns
6+
namespace: kube-system
7+
data:
8+
Corefile: |
9+
global {
10+
forward . 10.96.140.51
11+
}
12+
.:53 {
13+
errors
14+
health {
15+
lameduck 5s
16+
}
17+
ready
18+
kubernetes cluster.local in-addr.arpa ip6.arpa {
19+
pods insecure
20+
fallthrough in-addr.arpa ip6.arpa
21+
ttl 30
22+
}
23+
prometheus :9153
24+
forward . /etc/resolv.conf {
25+
max_concurrent 1000
26+
}
27+
cache 30
28+
loop
29+
reload
30+
loadbalance
31+
}

0 commit comments

Comments
 (0)