chore: add argocd manifest files (#137)

* chore: add argocd manifests

* fix the version issues
This commit is contained in:
Rick 2023-07-21 18:47:11 +08:00 committed by GitHub
parent 0809f352b8
commit 85f70b71d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 72 additions and 12 deletions

View File

@ -1,2 +1,5 @@
console/atest-ui/node_modules console/atest-ui/node_modules
console/atest-ui/dist console/atest-ui/dist
.git/
bin/
dist/

View File

@ -1,5 +1,6 @@
FROM golang:1.18 AS builder FROM golang:1.18 AS builder
ARG VERSION
ARG GOPROXY ARG GOPROXY
WORKDIR /workspace WORKDIR /workspace
COPY cmd/ cmd/ COPY cmd/ cmd/
@ -17,7 +18,7 @@ COPY README.md README.md
COPY LICENSE LICENSE COPY LICENSE LICENSE
RUN GOPROXY=${GOPROXY} go mod download RUN GOPROXY=${GOPROXY} go mod download
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest . RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s -X github.com/linuxsuren/api-testing/pkg/version.version=${VERSION}" -o atest .
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-collector extensions/collector/main.go RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-collector extensions/collector/main.go
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-store-orm extensions/store-orm/main.go RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-store-orm extensions/store-orm/main.go
@ -25,7 +26,7 @@ FROM node:20-alpine3.17 AS ui
WORKDIR /workspace WORKDIR /workspace
COPY --from=builder /workspace/atest-ui . COPY --from=builder /workspace/atest-ui .
RUN npm install --ignore-scripts RUN npm install --ignore-scripts --registry=https://registry.npmmirror.com
RUN npm run build-only RUN npm run build-only
FROM ubuntu:23.04 FROM ubuntu:23.04

View File

@ -9,14 +9,16 @@ build-embed-ui:
cp console/atest-ui/dist/index.html cmd/data/index.html cp console/atest-ui/dist/index.html cmd/data/index.html
cp console/atest-ui/dist/assets/*.js cmd/data/index.js cp console/atest-ui/dist/assets/*.js cmd/data/index.js
cp console/atest-ui/dist/assets/*.css cmd/data/index.css cp console/atest-ui/dist/assets/*.css cmd/data/index.css
go build -ldflags "-w -s -X github.com/linuxsuren/api-testing/pkg/version.version=$(git rev-parse --short HEAD)" -o bin/atest main.go go build -ldflags "-w -s -X github.com/linuxsuren/api-testing/pkg/version.version=$(shell git rev-parse --short HEAD)" -o bin/atest main.go
echo -n '' > cmd/data/index.html echo -n '' > cmd/data/index.html
echo -n '' > cmd/data/index.js echo -n '' > cmd/data/index.js
echo -n '' > cmd/data/index.css echo -n '' > cmd/data/index.css
goreleaser: goreleaser:
goreleaser build --rm-dist --snapshot goreleaser build --rm-dist --snapshot
build-image: build-image:
${IMG_TOOL} build -t ghcr.io/linuxsuren/api-testing:master . --build-arg GOPROXY=https://goproxy.cn,direct ${IMG_TOOL} build -t ghcr.io/linuxsuren/api-testing:master . \
--build-arg GOPROXY=https://goproxy.cn,direct \
--build-arg VERSION=$(shell git describe --abbrev=0 --tags)-$(shell git rev-parse --short HEAD)
run-image: run-image:
docker run -p 7070:7070 -p 8080:8080 ghcr.io/linuxsuren/api-testing:master docker run -p 7070:7070 -p 8080:8080 ghcr.io/linuxsuren/api-testing:master
run-server: run-server:

View File

@ -66,9 +66,9 @@ consume: 1m2.153686448s
## Use in Docker ## Use in Docker
Use `atest` as server mode in Docker, then you could visit the UI from `8080` and the gRPC endpoint from `7070`: Use `atest` as server mode in Docker, then you could visit the UI from `8080`:
``` ```
docker run -p 7070:7070 -p 8080:8080 ghcr.io/linuxsuren/api-testing docker run --pull always -p 8080:8080 ghcr.io/linuxsuren/api-testing:master
``` ```
Use `atest-collector` in Docker: Use `atest-collector` in Docker:

View File

@ -116,6 +116,9 @@ func (o *serverOption) runE(cmd *cobra.Command, args []string) (err error) {
if err == nil { if err == nil {
mux.HandlePath("GET", "/", frontEndHandlerWithLocation(o.consolePath)) mux.HandlePath("GET", "/", frontEndHandlerWithLocation(o.consolePath))
mux.HandlePath("GET", "/assets/{asset}", frontEndHandlerWithLocation(o.consolePath)) mux.HandlePath("GET", "/assets/{asset}", frontEndHandlerWithLocation(o.consolePath))
mux.HandlePath("GET", "/healthz", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) {
w.Write([]byte("ok"))
})
o.httpServer.WithHandler(mux) o.httpServer.WithHandler(mux)
err = o.httpServer.Serve(httplis) err = o.httpServer.Serve(httplis)
} }

View File

@ -16,7 +16,7 @@ There are multiple storage backend supported: See the status from the list:
Local storage is the built-in solution. You can run it with the following command: Local storage is the built-in solution. You can run it with the following command:
```shell ```shell
podman run -p 8080:8080 ghcr.io/linuxsuren/api-testing:master podman run --pull always -p 8080:8080 ghcr.io/linuxsuren/api-testing:master
# The default local storage directory is: /var/www/sample # The default local storage directory is: /var/www/sample
# You can find the test case YAML files in it. # You can find the test case YAML files in it.
@ -29,6 +29,11 @@ or, you can run the CLI in terminal like this:
atest server --local-storage 'sample/*.yaml' --console-path console/atest-ui/dist atest server --local-storage 'sample/*.yaml' --console-path console/atest-ui/dist
``` ```
using the host network mode if you want to connect to your local environment:
```shell
podman run --pull always --network host ghcr.io/linuxsuren/api-testing:master
```
### ORM DataBase Storage ### ORM DataBase Storage
Start a database with the following command if you don't have a database already. You can install [tiup](https://tiup.io/) via `hd i tiup`. Start a database with the following command if you don't have a database already. You can install [tiup](https://tiup.io/) via `hd i tiup`.

25
sample/argocd/simple.yaml Normal file
View File

@ -0,0 +1,25 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: api-testing
namespace: argocd
spec:
destination:
namespace: default
server: https://kubernetes.default.svc
project: default
source:
path: sample/kubernetes
repoURL: https://github.com/LinuxSuRen/api-testing
targetRevision: master
# see also https://argo-cd.readthedocs.io/en/stable/user-guide/kustomize/
kustomize:
images:
- ghcr.io/linuxsuren/api-testing=ghcr.io/linuxsuren/api-testing:master
syncPolicy:
syncOptions:
- CreateNamespace=true
- RespectIgnoreDifferences=true
automated:
prune: true
selfHeal: true

View File

@ -0,0 +1,4 @@
resources:
- manifest.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

View File

@ -11,7 +11,7 @@ spec:
strategy: strategy:
rollingUpdate: rollingUpdate:
maxSurge: 1 maxSurge: 1
maxUnavailable: 1 maxUnavailable: 0
selector: selector:
matchLabels: matchLabels:
app: api-testing app: api-testing
@ -33,12 +33,25 @@ spec:
containers: containers:
- image: ghcr.io/linuxsuren/api-testing - image: ghcr.io/linuxsuren/api-testing
name: server name: server
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 1
periodSeconds: 5
readinessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 1
periodSeconds: 5
resources: resources:
limits: limits:
cpu: "1" cpu: 500m
memory: 1Gi memory: 512Mi
requests: requests:
cpu: "100m" cpu: 100m
memory: 100m memory: 100m
--- ---
apiVersion: v1 apiVersion: v1
@ -47,10 +60,14 @@ metadata:
name: api-testing name: api-testing
spec: spec:
ports: ports:
- name: server - name: grpc
port: 7070 port: 7070
protocol: TCP protocol: TCP
targetPort: 7070 targetPort: 7070
- name: web
port: 8080
protocol: TCP
targetPort: 8080
selector: selector:
app: api-testing app: api-testing
sessionAffinity: None sessionAffinity: None