Skip to content

Commit

Permalink
The powerful cloud-native redis-operator
Browse files Browse the repository at this point in the history
  • Loading branch information
house authored and house committed Nov 24, 2021
1 parent 746e609 commit 7d59960
Show file tree
Hide file tree
Showing 2,330 changed files with 776,555 additions and 0 deletions.
63 changes: 63 additions & 0 deletions Makefile
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

9 changes: 9 additions & 0 deletions build/admin/Dockerfile
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"]

19 changes: 19 additions & 0 deletions build/operator/Dockerfile
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"]

Loading

0 comments on commit 7d59960

Please sign in to comment.