-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from zhoushuguang/dev
let's go k8s
- Loading branch information
Showing
21 changed files
with
428 additions
and
90 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
This file was deleted.
Oops, something went wrong.
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
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,24 @@ | ||
Name: article-api | ||
Host: 0.0.0.0 | ||
Port: 80 | ||
Auth: | ||
AccessSecret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx | ||
AccessExpire: 604800 | ||
RefreshSecret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx | ||
RefreshExpire: 2592000 | ||
RefreshAfter: 604800 | ||
Oss: | ||
Endpoint: oss-cn-shanghai.aliyuncs.com | ||
AccessKeyId: xxxxxxxxxxxxxxxxxxxx | ||
AccessKeySecret: xxxxxxxxxxxxxxxxxxxx | ||
BucketName: beyond-article | ||
ArticleRPC: | ||
Target: k8s://beyond/article-rpc:9090 | ||
NonBlock: false | ||
UserRPC: | ||
Target: k8s://beyond/user-rpc:9090 | ||
NonBlock: false | ||
Prometheus: | ||
Host: 0.0.0.0 | ||
Port: 9101 | ||
Path: /metrics |
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
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
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
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,22 @@ | ||
Name: article-rpc | ||
ListenOn: 0.0.0.0:9090 | ||
DataSource: root:123456@tcp(10.111.196.140:3306)/beyond_article?parseTime=true&loc=Local | ||
CacheRedis: | ||
- Host: 10.103.107.10:6379 | ||
Pass: | ||
Type: node | ||
BizRedis: | ||
Host: 10.103.107.10:6379 | ||
Pass: | ||
Type: node | ||
Consul: | ||
Host: 127.0.0.1:8500 | ||
Key: article-rpc | ||
Meta: | ||
env: test | ||
service_group: beyond | ||
service_name: article-rpc | ||
Prometheus: | ||
Host: 0.0.0.0 | ||
Port: 9102 | ||
Path: /metrics |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Name: article.rpc | ||
ListenOn: 0.0.0.0:8686 | ||
ListenOn: 0.0.0.0:9090 | ||
Etcd: | ||
Hosts: | ||
- 127.0.0.1:2379 | ||
|
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,22 @@ | ||
Name: user-rpc | ||
ListenOn: 0.0.0.0:9090 | ||
DataSource: root:123456@tcp(10.111.196.140:3306)/beyond_user?parseTime=true | ||
CacheRedis: | ||
- Host: 10.103.107.10:6379 | ||
Pass: | ||
Type: node | ||
BizRedis: | ||
Host: 10.103.107.10:6379 | ||
Pass: | ||
Type: node | ||
Consul: | ||
Host: 127.0.0.1:8500 | ||
Key: user-rpc | ||
Meta: | ||
env: test | ||
service_group: beyond | ||
service_name: user-rpc | ||
Prometheus: | ||
Host: 0.0.0.0 | ||
Port: 9103 | ||
Path: /metrics |
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,30 @@ | ||
FROM golang:alpine AS builder | ||
|
||
LABEL stage=gobuilder | ||
|
||
ENV CGO_ENABLED 0 | ||
ENV GOPROXY https://goproxy.cn,direct | ||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories | ||
|
||
RUN apk update --no-cache && apk add --no-cache tzdata | ||
|
||
WORKDIR /build | ||
|
||
ADD go.mod . | ||
ADD go.sum . | ||
RUN go mod download | ||
COPY . . | ||
COPY application/article/api/etc/article-api-dev.yaml /app/etc/article-api.yaml | ||
RUN go build -ldflags="-s -w" -o /app/article-api application/article/api/article.go | ||
|
||
FROM scratch | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai | ||
ENV TZ Asia/Shanghai | ||
|
||
WORKDIR /app | ||
COPY --from=builder /app/article-api /app/article-api | ||
COPY --from=builder /app/etc /app/etc | ||
|
||
CMD ["./article-api", "-f", "etc/article-api.yaml"] |
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,61 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: article-api | ||
namespace: beyond | ||
labels: | ||
app: article-api | ||
spec: | ||
replicas: 1 | ||
revisionHistoryLimit: 5 | ||
selector: | ||
matchLabels: | ||
app: article-api | ||
template: | ||
metadata: | ||
labels: | ||
app: article-api | ||
spec: | ||
serviceAccountName: endpoints-reader | ||
containers: | ||
- name: article-api | ||
image: article-api:v1.0.0 | ||
ports: | ||
- containerPort: 80 | ||
readinessProbe: | ||
tcpSocket: | ||
port: 80 | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
livenessProbe: | ||
tcpSocket: | ||
port: 80 | ||
initialDelaySeconds: 15 | ||
periodSeconds: 20 | ||
resources: | ||
requests: | ||
cpu: 200m | ||
memory: 256Mi | ||
limits: | ||
cpu: 200m | ||
memory: 256Mi | ||
volumeMounts: | ||
- name: timezone | ||
mountPath: /etc/localtime | ||
volumes: | ||
- name: timezone | ||
hostPath: | ||
path: /usr/share/zoneinfo/Asia/Shanghai | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: article-api-svc | ||
namespace: beyond | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: 80 | ||
selector: | ||
app: article-api |
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,30 @@ | ||
FROM golang:alpine AS builder | ||
|
||
LABEL stage=gobuilder | ||
|
||
ENV CGO_ENABLED 0 | ||
ENV GOPROXY https://goproxy.cn,direct | ||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories | ||
|
||
RUN apk update --no-cache && apk add --no-cache tzdata | ||
|
||
WORKDIR /build | ||
|
||
ADD go.mod . | ||
ADD go.sum . | ||
RUN go mod download | ||
COPY . . | ||
COPY application/article/rpc/etc/article-rpc-dev.yaml /app/etc/article-rpc.yaml | ||
RUN go build -ldflags="-s -w" -o /app/article-rpc application/article/rpc/article.go | ||
|
||
FROM scratch | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai | ||
ENV TZ Asia/Shanghai | ||
|
||
WORKDIR /app | ||
COPY --from=builder /app/article-rpc /app/article-rpc | ||
COPY --from=builder /app/etc /app/etc | ||
|
||
CMD ["./article-rpc", "-f", "etc/article-rpc.yaml"] |
Oops, something went wrong.