Skip to content

Commit

Permalink
Integrate GUI into API Server.
Browse files Browse the repository at this point in the history
  • Loading branch information
akuangkkk committed Jan 3, 2024
1 parent 7c22dca commit 1b2952b
Show file tree
Hide file tree
Showing 34 changed files with 353 additions and 24 deletions.
Binary file modified .DS_Store
Binary file not shown.
10 changes: 7 additions & 3 deletions Documentation/devhandbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ Build dokcer image by running `docker build -t <docker username>/alluxio-operato

* Example:
```shell
docker buildx build --platform linux/amd64 -t kshou433/alluxio-operator:withAPIServer_v5.1 -f dev/build/Dockerfile .
docker buildx build --platform linux/amd64 -t kshou433/alluxio-operator:withAPIServer_v6.0 -f dev/build/Dockerfile .
```

### Step 3
Push image to docker hub : `docker push <docker username>/alluxio-operator:<tag>`.

* Example:
```shell
docker push kshou433/alluxio-operator:withAPIServer_v5.1
docker push kshou433/alluxio-operator:withAPIServer_v6.0
```

### Step 4
Expand All @@ -67,4 +67,8 @@ Update image url and tage in ```operator-config.yaml```
### Access API Server Port
`kubectl port-forward -n alluxio-operator <api-server-controller Pod Name> 5220:5220`

Then use `curl` to do REST API Request.
Then use `curl` to do REST API Request.


# User Interface
### Copy files under `build` folder in React to `gui` folder under `api_server'
Binary file added cmd/api_server/.DS_Store
Binary file not shown.
Binary file modified cmd/api_server/api_server/.DS_Store
Binary file not shown.
3 changes: 1 addition & 2 deletions cmd/api_server/api_server/endpoints/alluxio_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func (alluxioClusterEndpoint *AlluxioClusterEndpoint) show(request *restful.Requ
})
}
}
logger.Infof("Get Alluxio Clusters Successfully")
}

func (alluxioClusterEndpoint *AlluxioClusterEndpoint) create(request *restful.Request, response *restful.Response) {
Expand Down Expand Up @@ -132,7 +131,7 @@ func (alluxioClusterEndpoint *AlluxioClusterEndpoint) delete(request *restful.Re
Details: fmt.Sprintf("Could not Delete dataset: %s", err),
})
}
logger.Infof("DELETE Dataset: %s Successfully", alluxioClusterObj.ObjectMeta.Name)
logger.Infof("DELETE Alluxio Cluster: %s Successfully", alluxioClusterObj.ObjectMeta.Name)
}

func (alluxioClusterEndpoint *AlluxioClusterEndpoint) update(request *restful.Request, response *restful.Response) {
Expand Down
13 changes: 13 additions & 0 deletions cmd/api_server/api_server/gui/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"files": {
"main.css": "/static/css/main.15468a32.css",
"main.js": "/static/js/main.0e4f4206.js",
"index.html": "/index.html",
"main.15468a32.css.map": "/static/css/main.15468a32.css.map",
"main.0e4f4206.js.map": "/static/js/main.0e4f4206.js.map"
},
"entrypoints": [
"static/css/main.15468a32.css",
"static/js/main.0e4f4206.js"
]
}
Binary file added cmd/api_server/api_server/gui/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions cmd/api_server/api_server/gui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.0e4f4206.js"></script><link href="/static/css/main.15468a32.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
Binary file added cmd/api_server/api_server/gui/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cmd/api_server/api_server/gui/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions cmd/api_server/api_server/gui/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions cmd/api_server/api_server/gui/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
2 changes: 2 additions & 0 deletions cmd/api_server/api_server/gui/static/css/main.15468a32.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cmd/api_server/api_server/gui/static/js/main.0e4f4206.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions cmd/api_server/api_server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package api_server

import (
"bytes"
"embed"
"fmt"
"github.com/Alluxio/k8s-operator/cmd/api_server/api_server/endpoints"
"github.com/emicklei/go-restful"
"io/fs"
"log"
"net/http"
"sigs.k8s.io/controller-runtime/pkg/client"
kubelog "sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -34,8 +37,19 @@ func init() {
}
}

//go:embed gui
var embeddedFiles embed.FS

func newApiServer(port int, allowedDomains []string, client client.Client) (*apiServer, error) {
container := restful.NewContainer()
// Add Web UI
guiFS, err := fs.Sub(embeddedFiles, "gui")
if err != nil {
log.Fatal(err)
}
// Declare Main Page for webui.
container.ServeMux.Handle("/", http.FileServer(http.FS(guiFS)))

srv := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Handler: container.ServeMux,
Expand All @@ -47,9 +61,10 @@ func newApiServer(port int, allowedDomains []string, client client.Client) (*api
Container: container,
}

// RESTFUL API start at `/api`
ws := new(restful.WebService)
ws.
Path("/").
Path("/api").
Consumes(restful.MIME_JSON).
Produces(restful.MIME_JSON)

Expand All @@ -61,12 +76,10 @@ func newApiServer(port int, allowedDomains []string, client client.Client) (*api
}, nil
}

// TODO Add more endpoints here
func addEndpoints(ws *restful.WebService, client client.Client) {
resources := []endpoints.Endpoint{
endpoints.NewAlluxioClusterEndpoint(client),
endpoints.NewDataSetEndpoint(client),
// More here ....
}
for _, ep := range resources {
ep.SetupWithWS(ws)
Expand Down
Binary file added cmd/api_server/gui/.DS_Store
Binary file not shown.
13 changes: 13 additions & 0 deletions cmd/api_server/gui/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"files": {
"main.css": "/static/css/main.e6c13ad2.css",
"main.js": "/static/js/main.c32d2a80.js",
"index.html": "/index.html",
"main.e6c13ad2.css.map": "/static/css/main.e6c13ad2.css.map",
"main.c32d2a80.js.map": "/static/js/main.c32d2a80.js.map"
},
"entrypoints": [
"static/css/main.e6c13ad2.css",
"static/js/main.c32d2a80.js"
]
}
Binary file added cmd/api_server/gui/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions cmd/api_server/gui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.c32d2a80.js"></script><link href="/static/css/main.e6c13ad2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
Binary file added cmd/api_server/gui/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cmd/api_server/gui/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions cmd/api_server/gui/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions cmd/api_server/gui/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
2 changes: 2 additions & 0 deletions cmd/api_server/gui/static/css/main.e6c13ad2.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/api_server/gui/static/css/main.e6c13ad2.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cmd/api_server/gui/static/js/main.c32d2a80.js

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions cmd/api_server/gui/static/js/main.c32d2a80.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @remix-run/router v1.14.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* React Router DOM v6.21.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* React Router v6.21.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
1 change: 1 addition & 0 deletions cmd/api_server/gui/static/js/main.c32d2a80.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 1b2952b

Please sign in to comment.