Skip to content

Commit

Permalink
Merge pull request kubeagi#396 from bjwswang/chore
Browse files Browse the repository at this point in the history
refactor: rename  graphql-server as apiserver
  • Loading branch information
bjwswang authored Dec 18, 2023
2 parents d6e0f55 + 0db5df8 commit 62ea64b
Show file tree
Hide file tree
Showing 84 changed files with 536 additions and 521 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/graphql_sdk_generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [main]
paths:
- 'graphql-server/go-server/graph/schema/*.gql'
- 'apiserver/graph/schema/*.gql'
workflow_dispatch:

env:
Expand Down Expand Up @@ -38,4 +38,4 @@ jobs:
run: |
kubectl port-forward svc/arcadia-apiserver -n arcadia 8888:8081 --address 0.0.0.0 >/dev/null 2>&1 &
export GRAPH_API_ENDPOINT="http://0.0.0.0:8888/bff"
make gql-sdk-generator
make bff-sdk-generator
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY pkg/ pkg/
COPY graphql-server/ graphql-server/
COPY apiserver/ apiserver/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o graphql-server-bin graphql-server/go-server/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o apiserver-bin apiserver/main.go
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
COPY --from=builder /workspace/graphql-server-bin ./graphql-server
COPY --from=builder /workspace/apiserver-bin ./apiserver
USER 65532:65532

ENTRYPOINT ["/manager"]
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,25 +252,25 @@ unkind: ## Uninstall a kind cluster.
arctl: fmt vet ## Build manager binary.
go build -o bin/arctl cmd/arctl/main.go

# graphql-server go
# apiserver go
gql-gen:
@go run github.com/99designs/[email protected] generate
build-graphql-server: gql-gen
@CGO_ENABLED=0 GOOS=linux go build -o bin/graphql-server graphql-server/go-server/main.go
run-graphql-server:
POD_NAMESPACE=arcadia go run graphql-server/go-server/main.go --enable-playground=true &
build-apiserver: gql-gen
@CGO_ENABLED=0 GOOS=linux go build -o bin/apiserver apiserver/main.go
run-apiserver:
POD_NAMESPACE=arcadia go run apiserver/main.go --enable-playground=true &

# sdk for graphql-server api
# sdk for apiserver api
GRL_SDK_GENERATOR_IMAGE ?= yuntijs/gql-sdk-generator:latest
GRAPH_API_ENDPOINT ?= http://0.0.0.0:8888/bff
# TODO change this config to a more constant value: /kubeagi-apis/bff after frontend code is ready
GRAPH_CLIENT_ENDPOINT ?= /kubeagi-apis/bff
.PHONY: gql-sdk-generator
gql-sdk-generator:
.PHONY: bff-sdk-generator
bff-sdk-generator:
docker run --rm --net=host --env SDK_PACKAGE_NAME=@yuntijs/arcadia-bff-sdk \
--env SDK_YUNTI_NAME=ArcadiaBffSDK --env GRAPH_API_ENDPOINT=${GRAPH_API_ENDPOINT} \
--env GRAPH_CLIENT_ENDPOINT=${GRAPH_CLIENT_ENDPOINT} \
-v $(shell pwd)/graphql-server/go-server/graph/schema:/schema \
-v $(shell pwd)/apiserver/graph/schema:/schema \
-v ~/.npmrc:/root/.npmrc ${GRL_SDK_GENERATOR_IMAGE}

# prepare for git push
Expand Down
68 changes: 68 additions & 0 deletions apiserver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# apiserver

`apiserver` provides comprehensive apis to work with [portal](https://github.com/kubeagi/portal).

## Build

At the root dir of the project,run

```shell
make build-apiserver
```

## Run

```shell
(base) ➜ arcadia git:(main) ✗ ./bin/apiserver -h
Usage of ./bin/apiserver:
-kubeconfig string
Paths to a kubeconfig. Only required if out-of-cluster.
-enable-playground
enable the graphql playground
-playground-endpoint-prefix string
this parameter should also be configured when the service is forwarded via ingress and a path prefix is configured to avoid not finding the service, such as /apis
-host string
bind to the host, default is 0.0.0.0
-port int
service listening port (default 8081)
-enable-oidc
enable oidc authorization
-client-id string
oidc client id(required when enable odic)
-client-secret string
oidc client secret(required when enable odic)
-data-processing-url string
url to access data processing server (default "http://127.0.0.1:28888")
-issuer-url string
oidc issuer url(required when enable odic)
-add_dir_header
If true, adds the file directory to the header of the log messages
-alsologtostderr
log to standard error as well as files
-log_backtrace_at value
when logging hits line file:N, emit a stack trace
-log_dir string
If non-empty, write log files in this directory
-log_file string
If non-empty, use this log file
-log_file_max_size uint
Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
-logtostderr
log to standard error instead of files (default true)
-master-url string
k8s master url(required when enable odic)
-one_output
If true, only write logs to their native severity level (vs also writing to each lower severity level)
-skip_headers
If true, avoid header prefixes in the log messages
-skip_log_headers
If true, avoid headers when opening log files
-stderrthreshold value
logs at or above this threshold go to stderr (default 2)
-system-namespace string
system namespace where kubeagi has been installed
-v value
number for the log level verbosity
-vmodule value
comma-separated list of pattern=N settings for file-filtered logging
```
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"k8s.io/klog/v2"

"github.com/kubeagi/arcadia/graphql-server/go-server/pkg/dataprocessing"
"github.com/kubeagi/arcadia/apiserver/pkg/dataprocessing"
)

var s = &ServerConfig{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Usage of ./main:
-file string
if it's an uploaded file, then it's the path to the local file, if it's a downloaded file, it's the path in minio, remember, bucketPath+filename make up the full storage path in minio.
-host string
graphql-server address (default "http://localhost:8099")
apiserver address (default "http://localhost:8099")
```
- The `action` parameter specifies whether you want to upload or download a file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

var (
action = flag.String("action", "upload", "you can only choose download, upload.")
host = flag.String("host", "http://localhost:8099", "graphql-server address")
host = flag.String("host", "http://localhost:8099", "apiserver address")
fileName = flag.String("file", "", "if it's an uploaded file, then it's the path to the local file, if it's a downloaded file, it's the path in minio, remember, bucketPath+filename make up the full storage path in minio.")
bucket = flag.String("bucket", "abc", "")
bucketPath = flag.String("bucket-path", "dataset/ds1/v1", "")
Expand Down
Loading

0 comments on commit 62ea64b

Please sign in to comment.