initial import

This commit is contained in:
kevin
2020-07-26 17:09:05 +08:00
commit 7e3a369a8f
647 changed files with 54754 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
FROM golang:1.13-alpine AS builder
LABEL stage=gobuilder
ENV CGO_ENABLED 0
ENV GOOS linux
ENV GOPROXY https://goproxy.cn,direct
WORKDIR $GOPATH/src/zero
COPY . .
RUN go build -ldflags="-s -w" -o /app/pub example/etcd/pub/pub.go
FROM alpine
RUN apk add --no-cache tzdata
ENV TZ Asia/Shanghai
WORKDIR /app
COPY --from=builder /app/pub /app/pub
CMD ["./pub"]

11
example/etcd/pub/Makefile Normal file
View File

@@ -0,0 +1,11 @@
version := v$(shell /bin/date "+%y%m%d%H%M%S")
build:
cd $(GOPATH)/src/zero && docker build -t registry.cn-hangzhou.aliyuncs.com/xapp/pub:$(version) . -f example/etcd/pub/Dockerfile
docker image prune --filter label=stage=gobuilder -f
push: build
docker push registry.cn-hangzhou.aliyuncs.com/xapp/pub:$(version)
deploy: push
kubectl -n adhoc set image deployment/pub-deployment pub=registry-vpc.cn-hangzhou.aliyuncs.com/xapp/pub:$(version)

27
example/etcd/pub/pub.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
"flag"
"fmt"
"log"
"time"
"zero/core/discov"
)
var value = flag.String("v", "value", "the value")
func main() {
flag.Parse()
client := discov.NewPublisher([]string{"etcd.discovery:2379"}, "028F2C35852D", *value)
if err := client.KeepAlive(); err != nil {
log.Fatal(err)
}
defer client.Stop()
for {
time.Sleep(time.Second)
fmt.Println(*value)
}
}

26
example/etcd/pub/pub.yaml Normal file
View File

@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pub-deployment
namespace: adhoc
labels:
app: pub
spec:
replicas: 1
selector:
matchLabels:
app: pub
template:
metadata:
labels:
app: pub
spec:
containers:
- name: pub
image: registry-vpc.cn-hangzhou.aliyuncs.com/xapp/pub:v200213172101
command:
- /app/pub
- -v
- ccc
imagePullSecrets:
- name: aliyun