From 2769ca11c27478eac50f376f5c5422df3020917b Mon Sep 17 00:00:00 2001 From: liuhaotian Date: Tue, 11 Jan 2022 13:18:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=8B=E6=9D=80=E4=B9=8B=E8=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 6 ++ app/brahma/api/murder/Dockerfile | 20 +++++ app/brahma/api/murder/deploy/.helmignore | 23 ++++++ app/brahma/api/murder/deploy/Chart.yaml | 24 ++++++ .../api/murder/deploy/templates/NOTES.txt | 1 + .../api/murder/deploy/templates/_helpers.tpl | 0 .../murder/deploy/templates/application.yaml | 20 +++++ .../murder/deploy/templates/deployment.yaml | 76 +++++++++++++++++++ .../api/murder/deploy/templates/ingress.yaml | 30 ++++++++ .../api/murder/deploy/templates/service.yaml | 26 +++++++ app/brahma/api/murder/deploy/values.yaml | 7 ++ app/brahma/api/murder/main.go | 7 ++ 12 files changed, 240 insertions(+) create mode 100755 app/brahma/api/murder/Dockerfile create mode 100755 app/brahma/api/murder/deploy/.helmignore create mode 100755 app/brahma/api/murder/deploy/Chart.yaml create mode 100755 app/brahma/api/murder/deploy/templates/NOTES.txt create mode 100755 app/brahma/api/murder/deploy/templates/_helpers.tpl create mode 100755 app/brahma/api/murder/deploy/templates/application.yaml create mode 100755 app/brahma/api/murder/deploy/templates/deployment.yaml create mode 100755 app/brahma/api/murder/deploy/templates/ingress.yaml create mode 100755 app/brahma/api/murder/deploy/templates/service.yaml create mode 100755 app/brahma/api/murder/deploy/values.yaml create mode 100755 app/brahma/api/murder/main.go diff --git a/.drone.yml b/.drone.yml index bdca684..f2b032d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,6 +10,12 @@ api: root: app/zeus/api/lark type: golang port: "8080" + - namespace: brahma + name: murder + alias_name: 剧本杀 + root: app/brahma/api/murder + type: golang + port: "8080" service: - namespace: zeus name: lark diff --git a/app/brahma/api/murder/Dockerfile b/app/brahma/api/murder/Dockerfile new file mode 100755 index 0000000..8f02315 --- /dev/null +++ b/app/brahma/api/murder/Dockerfile @@ -0,0 +1,20 @@ +FROM golang:1.17 as builder +ENV GO111MODULE on +ENV GOPROXY https://goproxy.io,direct +WORKDIR /go/cache +ADD go.mod . +ADD go.sum . +RUN go mod download -x +WORKDIR /go/src +ADD . . +RUN go mod tidy +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o api_murder ./app/brahma/api/murder + +FROM reg.icechen.cn/alpine as murder +WORKDIR /go/src +COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=builder /go/src/api_murder ./ +ENV TZ=Asia/Shanghai +RUN chmod +x ./api_murder +EXPOSE 8080 +CMD ["./api_murder"] \ No newline at end of file diff --git a/app/brahma/api/murder/deploy/.helmignore b/app/brahma/api/murder/deploy/.helmignore new file mode 100755 index 0000000..0e8a0eb --- /dev/null +++ b/app/brahma/api/murder/deploy/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/app/brahma/api/murder/deploy/Chart.yaml b/app/brahma/api/murder/deploy/Chart.yaml new file mode 100755 index 0000000..06b4e10 --- /dev/null +++ b/app/brahma/api/murder/deploy/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: murder +description: 剧本杀 + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.0.1" diff --git a/app/brahma/api/murder/deploy/templates/NOTES.txt b/app/brahma/api/murder/deploy/templates/NOTES.txt new file mode 100755 index 0000000..3041ade --- /dev/null +++ b/app/brahma/api/murder/deploy/templates/NOTES.txt @@ -0,0 +1 @@ +notes \ No newline at end of file diff --git a/app/brahma/api/murder/deploy/templates/_helpers.tpl b/app/brahma/api/murder/deploy/templates/_helpers.tpl new file mode 100755 index 0000000..e69de29 diff --git a/app/brahma/api/murder/deploy/templates/application.yaml b/app/brahma/api/murder/deploy/templates/application.yaml new file mode 100755 index 0000000..ec8cc30 --- /dev/null +++ b/app/brahma/api/murder/deploy/templates/application.yaml @@ -0,0 +1,20 @@ +apiVersion: app.k8s.io/v1beta1 +kind: Application +metadata: + name: {{ .Release.Name }} + namespace: {{ .Values.nameSpace }} + labels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + annotations: + servicemesh.kubesphere.io/enabled: 'true' +spec: + selector: + matchLabels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + addOwnerRef: true \ No newline at end of file diff --git a/app/brahma/api/murder/deploy/templates/deployment.yaml b/app/brahma/api/murder/deploy/templates/deployment.yaml new file mode 100755 index 0000000..6f357bb --- /dev/null +++ b/app/brahma/api/murder/deploy/templates/deployment.yaml @@ -0,0 +1,76 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: {{ .Release.Name }} + namespace: {{ .Values.nameSpace }} + labels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + app.kubernetes.io/instance: {{ .Release.Name }} + annotations: + kubesphere.io/alias-name: {{ .Values.aliasName }} + kubesphere.io/creator: drone + meta.helm.sh/release-name: {{ .Release.Name }} + meta.helm.sh/release-namespace: {{ .Values.nameSpace }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + volumes: + - name: host-time + hostPath: + path: /etc/localtime + type: '' + containers: + - name: {{ .Release.Name }} + image: {{ .Values.image }}:{{ .Values.imageTag }} + ports: + - containerPort: {{ .Values.port }} + protocol: TCP + env: + - name: endpoints + value: 'etcd:2379' + resources: + limits: + cpu: 200m + memory: 1000Mi + requests: + cpu: 10m + memory: 200Mi + volumeMounts: + - name: host-time + readOnly: true + mountPath: /etc/localtime + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + imagePullPolicy: IfNotPresent + restartPolicy: Always + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + securityContext: {} + imagePullSecrets: + - name: registry-secret + schedulerName: default-scheduler + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 25% + maxSurge: 25% + revisionHistoryLimit: 10 + progressDeadlineSeconds: 600 \ No newline at end of file diff --git a/app/brahma/api/murder/deploy/templates/ingress.yaml b/app/brahma/api/murder/deploy/templates/ingress.yaml new file mode 100755 index 0000000..cd01aa7 --- /dev/null +++ b/app/brahma/api/murder/deploy/templates/ingress.yaml @@ -0,0 +1,30 @@ +{{ if and .Values.host .Values.path }} +kind: Ingress +apiVersion: networking.k8s.io/v1 +metadata: + name: {{ .Release.Name }} + namespace: {{ .Values.nameSpace }} + labels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + app.kubernetes.io/instance: {{ .Release.Name }} + annotations: + kubesphere.io/creator: drone + nginx.ingress.kubernetes.io/enable-cors: 'true' + nginx.ingress.kubernetes.io/rewrite-target: /$1 + nginx.ingress.kubernetes.io/use-regex: 'true' +spec: + rules: + - host: {{ .Values.host }} + http: + paths: + - path: {{ .Values.path }} + pathType: ImplementationSpecific + backend: + service: + name: {{ .Release.Name }} + port: + number: 80 + {{ end }} \ No newline at end of file diff --git a/app/brahma/api/murder/deploy/templates/service.yaml b/app/brahma/api/murder/deploy/templates/service.yaml new file mode 100755 index 0000000..4cbc43c --- /dev/null +++ b/app/brahma/api/murder/deploy/templates/service.yaml @@ -0,0 +1,26 @@ +kind: Service +apiVersion: v1 +metadata: + name: {{ .Release.Name }} + namespace: {{ .Values.nameSpace }} + annotations: + kubesphere.io/creator: drone + labels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + app.kubernetes.io/instance: {{ .Release.Name }} +spec: + ports: + - name: http-{{ .Release.Name }} + protocol: TCP + port: 80 + targetPort: {{ .Values.port }} + selector: + app: {{ .Release.Name }} + type: ClusterIP + sessionAffinity: None + ipFamilies: + - IPv4 + ipFamilyPolicy: SingleStack \ No newline at end of file diff --git a/app/brahma/api/murder/deploy/values.yaml b/app/brahma/api/murder/deploy/values.yaml new file mode 100755 index 0000000..310dd1e --- /dev/null +++ b/app/brahma/api/murder/deploy/values.yaml @@ -0,0 +1,7 @@ +nameSpace: brahma +aliasName: 剧本杀 +image: reg.icechen.cn/brahma/api-murder +imageTag: latest +port: 8080 +host: api.seamlesser.com +path: /brahma/murder/?(.*) \ No newline at end of file diff --git a/app/brahma/api/murder/main.go b/app/brahma/api/murder/main.go new file mode 100755 index 0000000..21ec4e8 --- /dev/null +++ b/app/brahma/api/murder/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("我是个示例") +}