-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The powerful cloud-native redis-operator
- Loading branch information
house
authored and
house
committed
Nov 24, 2021
1 parent
746e609
commit 7d59960
Showing
2,330 changed files
with
776,555 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
ROOT := redis-priv-operator | ||
#TARGETS := operator admin | ||
#TARGETS := admin | ||
TARGETS := operator | ||
REGISTRY := registry.tongdun.me | ||
PROJECT := db | ||
VERSION := `date +%Y%m%d`-`git rev-parse --short=11 HEAD` | ||
LDFLAGS := `./hack/version.sh` | ||
|
||
.PHONY: codegen compile build push deploy | ||
|
||
codegen: | ||
go generate -v ./... | ||
|
||
build: codegen | ||
rm -rf _output | ||
mkdir _output | ||
@for target in $(TARGETS); do \ | ||
go build \ | ||
-v \ | ||
--ldflags "$(LDFLAGS)" \ | ||
-o ./_output/$${target} \ | ||
./cmd/$${target}; \ | ||
done | ||
|
||
container: codegen | ||
rm -rf _output | ||
mkdir _output | ||
@for target in $(TARGETS); do \ | ||
docker run \ | ||
--rm \ | ||
-w /go/src/$(ROOT) \ | ||
-v $(PWD):/go/src/$(ROOT) \ | ||
-v $(GOCACHE):/go/.cache \ | ||
-v $(GOPATH)/pkg/mod:/go/pkg/mod \ | ||
-e GO111MODULE=on \ | ||
-e GOCACHE=/go/.cache \ | ||
-e GOPROXY=https://goproxy.cn \ | ||
golang:1.13.12-alpine3.12 \ | ||
go build \ | ||
-o _output/$${target} \ | ||
-v \ | ||
--ldflags "$(LDFLAGS)" \ | ||
./cmd/$${target}; \ | ||
docker build \ | ||
-t $(REGISTRY)/$(PROJECT)/redis-priv-$${target}:$(VERSION) \ | ||
-f $(PWD)/build/$${target}/Dockerfile .; \ | ||
done | ||
|
||
push: | ||
@for target in $(TARGETS); do \ | ||
docker push \ | ||
$(REGISTRY)/$(PROJECT)/redis-priv-$${target}:$(VERSION); \ | ||
done | ||
|
||
deploy: | ||
kubectl apply -f $(PWD)/deploy/crd.yaml | ||
@for target in $(TARGETS); do \ | ||
cat $(PWD)/deploy/$${target}/$${target}.yaml | \ | ||
VERSION=$(VERSION) envsubst | \ | ||
kubectl apply -f -; \ | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM alpine:3.12 | ||
|
||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
COPY _output/admin admin | ||
|
||
CMD ["/app/admin"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM redis:alpine3.12 | ||
|
||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
COPY _output/operator operator | ||
|
||
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.12/main/" > /etc/apk/repositories | ||
|
||
RUN apk update \ | ||
&& apk upgrade \ | ||
&& apk add --no-cache bash \ | ||
bash-doc \ | ||
bash-completion \ | ||
&& rm -rf /var/cache/apk/* \ | ||
&& /bin/bash | ||
|
||
CMD ["/app/operator"] | ||
|
Oops, something went wrong.