Skip to content

Commit 7d59960

Browse files
househouse
house
authored and
house
committed
The powerful cloud-native redis-operator
1 parent 746e609 commit 7d59960

File tree

2,330 files changed

+776555
-0
lines changed

Some content is hidden

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

2,330 files changed

+776555
-0
lines changed

Makefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
ROOT := redis-priv-operator
2+
#TARGETS := operator admin
3+
#TARGETS := admin
4+
TARGETS := operator
5+
REGISTRY := registry.tongdun.me
6+
PROJECT := db
7+
VERSION := `date +%Y%m%d`-`git rev-parse --short=11 HEAD`
8+
LDFLAGS := `./hack/version.sh`
9+
10+
.PHONY: codegen compile build push deploy
11+
12+
codegen:
13+
go generate -v ./...
14+
15+
build: codegen
16+
rm -rf _output
17+
mkdir _output
18+
@for target in $(TARGETS); do \
19+
go build \
20+
-v \
21+
--ldflags "$(LDFLAGS)" \
22+
-o ./_output/$${target} \
23+
./cmd/$${target}; \
24+
done
25+
26+
container: codegen
27+
rm -rf _output
28+
mkdir _output
29+
@for target in $(TARGETS); do \
30+
docker run \
31+
--rm \
32+
-w /go/src/$(ROOT) \
33+
-v $(PWD):/go/src/$(ROOT) \
34+
-v $(GOCACHE):/go/.cache \
35+
-v $(GOPATH)/pkg/mod:/go/pkg/mod \
36+
-e GO111MODULE=on \
37+
-e GOCACHE=/go/.cache \
38+
-e GOPROXY=https://goproxy.cn \
39+
golang:1.13.12-alpine3.12 \
40+
go build \
41+
-o _output/$${target} \
42+
-v \
43+
--ldflags "$(LDFLAGS)" \
44+
./cmd/$${target}; \
45+
docker build \
46+
-t $(REGISTRY)/$(PROJECT)/redis-priv-$${target}:$(VERSION) \
47+
-f $(PWD)/build/$${target}/Dockerfile .; \
48+
done
49+
50+
push:
51+
@for target in $(TARGETS); do \
52+
docker push \
53+
$(REGISTRY)/$(PROJECT)/redis-priv-$${target}:$(VERSION); \
54+
done
55+
56+
deploy:
57+
kubectl apply -f $(PWD)/deploy/crd.yaml
58+
@for target in $(TARGETS); do \
59+
cat $(PWD)/deploy/$${target}/$${target}.yaml | \
60+
VERSION=$(VERSION) envsubst | \
61+
kubectl apply -f -; \
62+
done
63+

build/admin/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM alpine:3.12
2+
3+
RUN mkdir /app
4+
WORKDIR /app
5+
6+
COPY _output/admin admin
7+
8+
CMD ["/app/admin"]
9+

build/operator/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM redis:alpine3.12
2+
3+
RUN mkdir /app
4+
WORKDIR /app
5+
6+
COPY _output/operator operator
7+
8+
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.12/main/" > /etc/apk/repositories
9+
10+
RUN apk update \
11+
&& apk upgrade \
12+
&& apk add --no-cache bash \
13+
bash-doc \
14+
bash-completion \
15+
&& rm -rf /var/cache/apk/* \
16+
&& /bin/bash
17+
18+
CMD ["/app/operator"]
19+

0 commit comments

Comments
 (0)