From 24d1e7ff11aa6d5ba9cebe3c6f39a8c6cab0f21b Mon Sep 17 00:00:00 2001 From: lucferbux Date: Mon, 13 Jan 2025 18:20:12 +0100 Subject: [PATCH 1/3] Revamp deployment files to get UI in one container Signed-off-by: lucferbux --- .../workflows/build-and-push-ui-images.yml | 17 ---- Makefile | 8 +- clients/ui/.env | 5 +- clients/ui/.env.production | 2 + clients/ui/Dockerfile | 59 ++++++++++++ clients/ui/Makefile | 64 +++++++++---- clients/ui/README.md | 95 +++++++++++-------- clients/ui/bff/.gitignore | 1 + clients/ui/bff/Dockerfile | 33 ------- clients/ui/bff/Makefile | 5 - clients/ui/bff/README.md | 21 +--- clients/ui/bff/cmd/main.go | 2 +- clients/ui/bff/internal/api/app_test.go | 7 +- clients/ui/bff/static/index.html | 2 +- clients/ui/bff/static/sub/test.html | 2 +- clients/ui/docker-compose.yaml | 24 ----- .../local-deployment-guide.md} | 4 +- clients/ui/frontend/.env.development | 2 - clients/ui/frontend/CONTRIBUTING.md | 24 +++-- clients/ui/frontend/Dockerfile | 17 ---- clients/ui/frontend/Makefile | 13 --- clients/ui/frontend/docs/README.md | 4 +- clients/ui/frontend/docs/architecture.md | 2 +- clients/ui/frontend/docs/dev-setup.md | 2 - clients/ui/frontend/nginx.conf | 22 ----- clients/ui/frontend/src/app/App.tsx | 5 +- clients/ui/manifests/base/kustomization.yaml | 9 +- .../base/model-registry-bff-deployment.yaml | 29 ------ .../base/model-registry-bff-role.yaml | 23 ----- .../base/model-registry-bff-service.yaml | 15 --- .../base/model-registry-ui-deployment.yaml | 28 +++++- .../model-registry-ui-role.yaml} | 33 ++++++- ...=> model-registry-ui-service-account.yaml} | 2 +- .../ui/manifests/kubeflow/kustomization.yaml | 20 ---- .../model-registry-ui-deployment.yaml | 9 -- .../overlays/integrated/kustomization.yaml | 13 +++ .../model-registry-ui-deployment.yaml} | 1 + .../istio/authorization-policy-bff.yaml | 13 --- .../overlays/istio/destination-rule-bff.yaml | 11 --- .../overlays/istio/kustomization.yaml | 10 +- .../standalone/kubeflow-dashboard-rbac.yaml | 39 ++++++++ .../overlays/standalone/kustomization.yaml | 14 +++ .../model-registry-ui-deployment.yaml} | 1 + .../standalone/kubeflow-dashboard-rbac.yaml | 21 ---- .../manifests/standalone/kustomization.yaml | 19 ---- .../model-registry-ui-deployment.yaml | 9 -- clients/ui/scripts/deploy_kind_cluster.sh | 21 ++-- 47 files changed, 339 insertions(+), 443 deletions(-) create mode 100644 clients/ui/Dockerfile delete mode 100644 clients/ui/bff/Dockerfile delete mode 100644 clients/ui/docker-compose.yaml rename clients/ui/{bff/docs/dev-guide.md => docs/local-deployment-guide.md} (97%) delete mode 100644 clients/ui/frontend/Dockerfile delete mode 100644 clients/ui/frontend/Makefile delete mode 100644 clients/ui/frontend/nginx.conf delete mode 100644 clients/ui/manifests/base/model-registry-bff-deployment.yaml delete mode 100644 clients/ui/manifests/base/model-registry-bff-role.yaml delete mode 100644 clients/ui/manifests/base/model-registry-bff-service.yaml rename clients/ui/manifests/{kubeflow/kubeflow-dashboard-rbac.yaml => base/model-registry-ui-role.yaml} (63%) rename clients/ui/manifests/base/{model-registry-bff-service-account.yaml => model-registry-ui-service-account.yaml} (64%) delete mode 100644 clients/ui/manifests/kubeflow/kustomization.yaml delete mode 100644 clients/ui/manifests/kubeflow/model-registry-ui-deployment.yaml create mode 100644 clients/ui/manifests/overlays/integrated/kustomization.yaml rename clients/ui/manifests/{kubeflow/model-registry-bff-deployment.yaml => overlays/integrated/model-registry-ui-deployment.yaml} (83%) delete mode 100644 clients/ui/manifests/overlays/istio/authorization-policy-bff.yaml delete mode 100644 clients/ui/manifests/overlays/istio/destination-rule-bff.yaml create mode 100644 clients/ui/manifests/overlays/standalone/kubeflow-dashboard-rbac.yaml create mode 100644 clients/ui/manifests/overlays/standalone/kustomization.yaml rename clients/ui/manifests/{standalone/model-registry-bff-deployment.yaml => overlays/standalone/model-registry-ui-deployment.yaml} (82%) delete mode 100644 clients/ui/manifests/standalone/kubeflow-dashboard-rbac.yaml delete mode 100644 clients/ui/manifests/standalone/kustomization.yaml delete mode 100644 clients/ui/manifests/standalone/model-registry-ui-deployment.yaml diff --git a/.github/workflows/build-and-push-ui-images.yml b/.github/workflows/build-and-push-ui-images.yml index b8c0d9727..0b98c127f 100644 --- a/.github/workflows/build-and-push-ui-images.yml +++ b/.github/workflows/build-and-push-ui-images.yml @@ -10,7 +10,6 @@ on: env: IMG_ORG: kubeflow IMG_UI_REPO: model-registry-ui - IMG_BFF_REPO: model-registry-bff DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_PWD: ${{ secrets.DOCKERHUB_TOKEN }} PUSH_IMAGE: true @@ -36,11 +35,6 @@ jobs: env: IMG_REPO: ${{ env.IMG_UI_REPO }} run: ./scripts/build_deploy.sh - - name: Build and Push BFF Image - shell: bash - env: - IMG_REPO: ${{ env.IMG_BFF_REPO }} - run: ./scripts/build_deploy.sh - name: Tag Latest UI Image if: env.BUILD_CONTEXT == 'main' shell: bash @@ -52,14 +46,3 @@ jobs: docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:latest # BUILD_IMAGE=false skip the build, just push the tag made above VERSION=latest ./scripts/build_deploy.sh - - name: Tag Latest BFF Image - if: env.BUILD_CONTEXT == 'main' - shell: bash - env: - IMG_REPO: ${{ env.IMG_BFF_REPO }} - IMG: ${{ env.IMG_ORG }}/${{ env.IMG_BFF_REPO }} - BUILD_IMAGE: false # image is already built in "Build and Push BFF Image" step - run: | - docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:latest - # BUILD_IMAGE=false skip the build, just push the tag made above - VERSION=latest ./scripts/build_deploy.sh \ No newline at end of file diff --git a/Makefile b/Makefile index 15e783cf1..ce7723725 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,7 @@ MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH))) PROJECT_BIN := $(PROJECT_PATH)/bin GO ?= "$(shell which go)" -BFF_PATH := $(PROJECT_PATH)/clients/ui/bff -UI_PATH := $(PROJECT_PATH)/clients/ui/frontend +UI_PATH := $(PROJECT_PATH)/clients/ui CSI_PATH := $(PROJECT_PATH)/cmd/csi # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. @@ -43,11 +42,6 @@ ifeq ($(IMG_REPO),model-registry-ui) BUILD_PATH := $(UI_PATH) endif -ifeq ($(IMG_REPO),model-registry-bff) - DOCKERFILE := $(BFF_PATH)/Dockerfile - BUILD_PATH := $(BFF_PATH) -endif - # The BUILD_PATH is still the root ifeq ($(IMG_REPO),model-registry-storage-initializer) DOCKERFILE := $(CSI_PATH)/Dockerfile.csi diff --git a/clients/ui/.env b/clients/ui/.env index 5e5fe0d8f..d2d6c7367 100644 --- a/clients/ui/.env +++ b/clients/ui/.env @@ -1,5 +1,6 @@ ############### Default settings ############### CONTAINER_TOOL=docker -IMG_BFF=kubeflow/model-registry-bff:latest -IMG_FRONTEND=kubeflow/model-registry-ui:latest +IMG_UI=kubeflow/model-registry-ui:latest +IMG_UI_STANDALONE=kubeflow/model-registry-ui-standalone:latest +PLATFORM=linux/amd64 diff --git a/clients/ui/.env.production b/clients/ui/.env.production index a904f4a9f..553a0fc78 100644 --- a/clients/ui/.env.production +++ b/clients/ui/.env.production @@ -1 +1,3 @@ APP_ENV=production +MOCK_AUTH=false +DEPLOYMENT_MODE=integrated diff --git a/clients/ui/Dockerfile b/clients/ui/Dockerfile new file mode 100644 index 000000000..21a9af3b3 --- /dev/null +++ b/clients/ui/Dockerfile @@ -0,0 +1,59 @@ +# Source code for the repos +ARG UI_SOURCE_CODE=./frontend +ARG BFF_SOURCE_CODE=./bff + +# Set the base images for the build stages +ARG NODE_BASE_IMAGE=node:20 +ARG GOLANG_BASE_IMAGE=golang:1.22.2 +ARG DISTROLESS_BASE_IMAGE=gcr.io/distroless/static:nonroot + +# UI build stage +FROM ${NODE_BASE_IMAGE} AS ui-builder + +ARG UI_SOURCE_CODE + +WORKDIR /usr/src/app + +# Copy the source code to the container +COPY ${UI_SOURCE_CODE} /usr/src/app + +# Install the dependencies and build +RUN npm cache clean --force +RUN npm ci --omit=optional +RUN npm run build:prod + +# BFF build stage +FROM ${GOLANG_BASE_IMAGE} AS bff-builder + +ARG BFF_SOURCE_CODE + +ARG TARGETOS +ARG TARGETARCH + +WORKDIR /usr/src/app + +# Copy the Go Modules manifests +COPY ${BFF_SOURCE_CODE}/go.mod ${BFF_SOURCE_CODE}/go.sum ./ + +# Download dependencies +RUN go mod download + +# Copy the go source files +COPY ${BFF_SOURCE_CODE}/cmd/main.go cmd/main.go +COPY ${BFF_SOURCE_CODE}/internal/ internal/ + +# Build the Go application +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o bff ./cmd/main.go + +# Final stage +# Use distroless as minimal base image to package the application binary +FROM ${DISTROLESS_BASE_IMAGE} +WORKDIR / +COPY --from=bff-builder /usr/src/app/bff ./ +COPY --from=ui-builder /usr/src/app/dist ./static/ +USER 65532:65532 + +# Expose port 8080 +EXPOSE 8080 + +ENTRYPOINT ["/bff"] diff --git a/clients/ui/Makefile b/clients/ui/Makefile index cf3dbc4db..06498fb53 100644 --- a/clients/ui/Makefile +++ b/clients/ui/Makefile @@ -44,36 +44,58 @@ dev-start: ############ Build ############ -.PHONY: build-bff -build-bff: - $(CONTAINER_TOOL) build -t ${IMG_BFF} ./bff +.PHONY: docker-build +docker-build: + $(CONTAINER_TOOL) build -t ${IMG_UI} . -.PHONY: build-frontend -build-frontend: - $(CONTAINER_TOOL) build -t ${IMG_FRONTEND} ./frontend +.PHONY: docker-build-standalone +docker-build-standalone: + MOCK_AUTH=true DEPLOYMENT_MODE=standalone $(CONTAINER_TOOL) build -t ${IMG_UI_STANDALONE} . -.PHONY: build -build: build-bff build-frontend +.PHONY: docker-buildx +docker-buildx: + docker buildx build --platform ${PLATFORM} -t ${IMG_UI} --push . -############ Push ############ +.PHONY: docker-buildx-standalone +docker-buildx-standalone: + MOCK_AUTH=true DEPLOYMENT_MODE=standalone docker buildx build --platform ${PLATFORM} -t ${IMG_UI_STANDALONE} --push . -.PHONY: push-bff -push-bff: - ${CONTAINER_TOOL} push ${IMG_BFF} +############ Push ############ -.PHONY: push-frontend -push-frontend: - ${CONTAINER_TOOL} push ${IMG_FRONTEND} +.PHONY: docker-push +docker-push: + ${CONTAINER_TOOL} push ${IMG_UI} -.PHONY: push -push: push-bff push-frontend +.PHONY: docker-push-standalone +docker-push-standalone: + ${CONTAINER_TOOL} push ${IMG_UI_STANDALONE} ############ Deployment ############ -.PHONY: docker-compose -docker-compose: - $(CONTAINER_TOOL) compose -f docker-compose.yaml up - .PHONY: kind-deployment kind-deployment: ./scripts/deploy_kind_cluster.sh + +############ Build ############ +.PHONY: frontend-build +frontend-build: + cd frontend && npm run build:prod + +.PHONY: frontend-build-standalone +frontend-build-standalone: + MOCK_AUTH=true DEPLOYMENT_MODE=standalone cd frontend && npm run build:prod + +.PHONY: bff-build +bff-build: + cd bff && make build + +.PHONY: build +build: frontend-build bff-build + +############ Run mocked ######## +.PHONY: run-local-mocked +run-local-mocked: frontend-build-standalone bff-build + rm -r ./bff/static-local-run && cp -r ./frontend/dist/ ./bff/static-local-run/ && cd bff && make run STATIC_ASSETS_DIR=./static-local-run MOCK_K8S_CLIENT=true DEV_MODE=true + + + \ No newline at end of file diff --git a/clients/ui/README.md b/clients/ui/README.md index 287b62450..775e01fed 100644 --- a/clients/ui/README.md +++ b/clients/ui/README.md @@ -24,14 +24,6 @@ To run the a mocked dev environment you can either: * Or follow the [frontend dev setup] and [BFF dev setup]. -### Docker deployment - -To build the Model Registry UI container, run the following command: - -```shell -make docker-compose -``` - ### Kubernetes Deployment For a in-depth guide on how to deploy the Model Registry UI, please refer to the [local kubernetes deployment](./bff/docs/dev-guide.md) documentation. @@ -47,6 +39,14 @@ make kind-deployment You can find the OpenAPI specification for the Model Registry UI in the [openapi](./api/openapi) directory. A live version of the OpenAPI specification can be found [here](https://editor.swagger.io/?url=https://raw.githubusercontent.com/kubeflow/model-registry/main/clients/ui/api/openapi/mod-arch.yaml). +## Targeted environments + +There's two main environments that the Model Registry UI is targeted for: + +1. **Standalone**: This is the default environment for local development. The UI is served by the BFF and the BFF is responsible for serving the API requests. The BFF exposes a `/namespace` endpoint that returns all the namespaces in the cluster and the UI sends a user header `kubeflow-user` to authenticate the calls. + +2. **Integrated**: This is the environment where the UI is served by the Kubeflow Ingress and the BFF is served by the Kubeflow API Gateway. The BFF is responsible for serving the API requests and namespace selection is leveraged from Kubeflow. + ## Environment Variables The following environment variables are used to configure the deployment and development environment for the Model Registry UI. These variables should be defined in a `.env.local` file in the `clients/ui` directory of the project. **This values will affect the build and push commands**. @@ -58,17 +58,35 @@ The following environment variables are used to configure the deployment and dev * **Possible Values**: `docker`, `podman`, etc. * **Example**: `CONTAINER_TOOL=docker` -### `IMG_BFF` +### `IMG_UI` -* **Description**: Specifies the image name and tag for the Backend For Frontend (BFF) service. -* **Default Value**: `model-registry-bff:latest` -* **Example**: `IMG_BFF=model-registry-bff:latest` +* **Description**: Specifies the image name and tag for the UI (with BFF). +* **Default Value**: `model-registry-ui:latest` +* **Example**: `IMG_UI=model-registry-bff:latest` -### `IMG_FRONTEND` +### `IMG_UI_STANDALONE` -* **Description**: Specifies the image name and tag for the frontend service. -* **Default Value**: `model-registry-frontend:latest` -* **Example**: `IMG_FRONTEND=model-registry-frontend:latest` +* **Description**: Specifies the image name and tag for the UI (with BFF) in **standalone mode**, used for local kind deployment. +* **Default Value**: `model-registry-ui-standalone:latest` +* **Example**: `IMG_UI_STANDALONE=model-registry-bff:latest` + +### `PLATFORM` + +* **Description**: Specifies the platform for a **docker buildx** build. +* **Default Value**: `linux/amd64` +* **Example**: `PLATFORM=linux/amd64` + +### `MOCK_AUTH` + +* **Description**: Specifies whether to mock authentication in the UI. +* **Default Value**: `true` (in dev mode) / `false` (in production mode) +* **Possible Values**: `true`, `false` + +### `DEPLOYMENT_MODE` + +* **Description**: Specifies the deployment mode for the UI. +* **Default Value**: `standalone` (in dev mode) / `integrated` (in production mode) +* **Possible Values**: `standalone`, `integrated` ### Example `.env.local` File @@ -76,38 +94,39 @@ Here is an example of what your `.env.local` file might look like: ```shell CONTAINER_TOOL=docker -IMG_BFF=model-registry-bff:latest -IMG_FRONTEND=model-registry-frontend:latest +IMG_UI=quay.io//model-registry-ui:latest +IMG_UI_STANDALONE=quay.io//model-registry-ui-standalone:latest +PLATFORM=linux/amd64 ``` ## Build and Push Commands -The following Makefile targets are used to build and push the Docker images for the Backend For Frontend (BFF) and frontend services. These targets utilize the environment variables defined in the `.env.local` file. +The following Makefile targets are used to build and push the Docker images the UI images. These targets utilize the environment variables defined in the `.env.local` file. ### Build Commands -* **`build-bff`**: Builds the Docker image for the BFF service. - * Command: `make build-bff` - * This command uses the `CONTAINER_TOOL` and `IMG_BFF` environment variables to build the image. +* **`docker-build`**: Builds the Docker image for the UI platform. + * Command: `make docker-build` + * This command uses the `CONTAINER_TOOL` and `IMG_UI` environment variables to push the image. -* **`build-frontend`**: Builds the Docker image for the frontend service. - * Command: `make build-frontend` - * This command uses the `CONTAINER_TOOL` and `IMG_FRONTEND` environment variables to build the image. +* **`docker-buildx`**: Builds the Docker image with buildX for multiarch support. + * Command: `make docker-buildx` + * This command uses the `CONTAINER_TOOL` and `IMG_UI` environment variables to push the image. -* **`build`**: Builds the Docker images for both the BFF and frontend services. - * Command: `make build` - * This command runs both `build-bff` and `build-frontend` targets. +* **`docker-build-standalone`**: Builds the Docker image for the UI platform **in standalone mode**. + * Command: `make docker-build-standalone` + * This command uses the `CONTAINER_TOOL` and `IMG_UI_STANDALONE` environment variables to push the image. -### Push Commands +* **`docker-buildx-standalone`**: Builds the Docker image with buildX for multiarch support **in standalone mode**. + * Command: `make docker-buildx-standalone` + * This command uses the `CONTAINER_TOOL` and `IMG_UI_STANDALONE` environment variables to push the image. -* **`push-bff`**: Pushes the Docker image for the BFF service to the container registry. - * Command: `make push-bff` - * This command uses the `CONTAINER_TOOL` and `IMG_BFF` environment variables to push the image. +### Push Commands -* **`push-frontend`**: Pushes the Docker image for the frontend service to the container registry. - * Command: `make push-frontend` - * This command uses the `CONTAINER_TOOL` and `IMG_FRONTEND` environment variables to push the image. +* **`docker-push`**: Pushes the Docker image for the UI service to the container registry. + * Command: `make docker-push` + * This command uses the `CONTAINER_TOOL` and `IMG_UI` environment variables to push the image. -* **`push`**: Pushes the Docker images for both the BFF and frontend services to the container registry. - * Command: `make push` - * This command runs both `push-bff` and `push-frontend` targets. +* **`docker-push-standalone`**: Pushes the Docker image for the UI service to the container registry **in standalone mode**. + * Command: `make docker-push-standalone` + * This command uses the `CONTAINER_TOOL` and `IMG_UI_STANDALONE` environment variables to push the image. diff --git a/clients/ui/bff/.gitignore b/clients/ui/bff/.gitignore index 5e56e040e..ee5236afe 100644 --- a/clients/ui/bff/.gitignore +++ b/clients/ui/bff/.gitignore @@ -1 +1,2 @@ /bin +/static-local-run \ No newline at end of file diff --git a/clients/ui/bff/Dockerfile b/clients/ui/bff/Dockerfile deleted file mode 100644 index b8625294c..000000000 --- a/clients/ui/bff/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# Use the golang image to build the application -FROM golang:1.22.2 AS builder -ARG TARGETOS -ARG TARGETARCH - -WORKDIR /ui - -# Copy the Go Modules manifests -COPY go.mod go.sum ./ - -# Download dependencies -RUN go mod download - -# Copy the go source files -COPY cmd/main.go cmd/main.go -COPY internal/ internal/ - -# Copy the static assets -COPY $STATIC_ASSETS_DIR static/ - -# Build the Go application -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o bff ./cmd/main.go - -# Use distroless as minimal base image to package the application binary -FROM gcr.io/distroless/static:nonroot -WORKDIR / -COPY --from=builder ui/bff ./ -USER 65532:65532 - -# Expose port 4000 -EXPOSE 4000 - -ENTRYPOINT ["/bff", "--static-assets-dir=/static"] diff --git a/clients/ui/bff/Makefile b/clients/ui/bff/Makefile index 4d8660bab..a7da3932a 100644 --- a/clients/ui/bff/Makefile +++ b/clients/ui/bff/Makefile @@ -1,4 +1,3 @@ -CONTAINER_TOOL ?= docker IMG ?= model-registry-bff:latest PORT ?= 4000 MOCK_K8S_CLIENT ?= false @@ -52,10 +51,6 @@ run: fmt vet envtest ## Runs the project. ENVTEST_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \ go run ./cmd/main.go --port=$(PORT) --static-assets-dir=$(STATIC_ASSETS_DIR) --mock-k8s-client=$(MOCK_K8S_CLIENT) --mock-mr-client=$(MOCK_MR_CLIENT) --dev-mode=$(DEV_MODE) --dev-mode-port=$(DEV_MODE_PORT) --standalone-mode=$(STANDALONE_MODE) -.PHONY: docker-build -docker-build: ## Builds a container for the project. - $(CONTAINER_TOOL) build -t ${IMG} . - ##@ Dependencies ## Location to install dependencies to diff --git a/clients/ui/bff/README.md b/clients/ui/bff/README.md index 0befdc450..3886245e1 100644 --- a/clients/ui/bff/README.md +++ b/clients/ui/bff/README.md @@ -54,26 +54,7 @@ make docker-build ### Endpoints -| URL Pattern | Handler | Action | -|----------------------------------------------------------------------------------------------|----------------------------------------------|-------------------------------------------------------------| -| GET /v1/healthcheck | HealthcheckHandler | Show application information. | -| GET /v1/user | UserHandler | Show "kubeflow-user-id" from header information. | -| GET /v1/namespaces | NamespacesHandler | Get all user namespaces. (only enabled in devmode) | -| GET /v1/model_registry | ModelRegistryHandler | Get all model registries, | -| GET /v1/model_registry/{model_registry_id}/registered_models | GetAllRegisteredModelsHandler | Gets a list of all RegisteredModel entities. | -| POST /v1/model_registry/{model_registry_id}/registered_models | CreateRegisteredModelHandler | Create a RegisteredModel entity. | -| GET /v1/model_registry/{model_registry_id}/registered_models/{registered_model_id} | GetRegisteredModelHandler | Get a RegisteredModel entity by ID | -| PATCH /v1/model_registry/{model_registry_id}/registered_models/{registered_model_id} | UpdateRegisteredModelHandler | Update a RegisteredModel entity by ID | -| GET /api/v1/model_registry/{model_registry_id}/model_versions/{model_version_id} | GetModelVersionHandler | Get a ModelVersion by ID | -| POST /api/v1/model_registry/{model_registry_id}/model_versions | CreateModelVersionHandler | Create a ModelVersion entity | -| PATCH /api/v1/model_registry/{model_registry_id}/model_versions/{model_version_id} | UpdateModelVersionHandler | Update a ModelVersion entity by ID | -| GET /v1/model_registry/{model_registry_id}/registered_models/{registered_model_id}/versions | GetAllModelVersionsForRegisteredModelHandler | Get all ModelVersion entities by RegisteredModel ID | -| POST /v1/model_registry/{model_registry_id}/registered_models/{registered_model_id}/versions | CreateModelVersionForRegisteredModelHandler | Create a ModelVersion entity for a specific RegisteredModel | -| GET /api/v1/model_registry/{model_registry_id}/model_versions/{model_version_id}/artifacts | GetAllModelArtifactsByModelVersionHandler | Get all ModelArtifact entities by ModelVersion ID | -| POST /api/v1/model_registry/{model_registry_id}/model_versions/{model_version_id}/artifacts | CreateModelArtifactByModelVersion | Create a ModelArtifact entity for a specific ModelVersion | - -Note: Most API paths require the namespace parameter to be passed as a query parameter. -The only exceptions are the health check (/v1/healthcheck) and user (/v1/user) paths, which do not require the namespace parameter. +See the [OpenAPI specification](../api/openapi/mod-arch.yaml) for a complete list of endpoints. ### Sample local calls diff --git a/clients/ui/bff/cmd/main.go b/clients/ui/bff/cmd/main.go index e767515da..a38ae341c 100644 --- a/clients/ui/bff/cmd/main.go +++ b/clients/ui/bff/cmd/main.go @@ -19,7 +19,7 @@ import ( func main() { var cfg config.EnvConfig - flag.IntVar(&cfg.Port, "port", getEnvAsInt("PORT", 4000), "API server port") + flag.IntVar(&cfg.Port, "port", getEnvAsInt("PORT", 8080), "API server port") flag.BoolVar(&cfg.MockK8Client, "mock-k8s-client", false, "Use mock Kubernetes client") flag.BoolVar(&cfg.MockMRClient, "mock-mr-client", false, "Use mock Model Registry client") flag.BoolVar(&cfg.DevMode, "dev-mode", false, "Use development mode for access to local K8s cluster") diff --git a/clients/ui/bff/internal/api/app_test.go b/clients/ui/bff/internal/api/app_test.go index e7cd23f81..c03afb0b5 100644 --- a/clients/ui/bff/internal/api/app_test.go +++ b/clients/ui/bff/internal/api/app_test.go @@ -1,13 +1,14 @@ package api import ( + "io" + "net/http" + httptest "net/http/httptest" + "github.com/kubeflow/model-registry/ui/bff/internal/config" "github.com/kubeflow/model-registry/ui/bff/internal/repositories" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "io" - "net/http" - httptest "net/http/httptest" ) var _ = Describe("Static File serving Test", func() { diff --git a/clients/ui/bff/static/index.html b/clients/ui/bff/static/index.html index 41c73cf02..d335bc73a 100644 --- a/clients/ui/bff/static/index.html +++ b/clients/ui/bff/static/index.html @@ -7,4 +7,4 @@

Welcome to the BFF Stub Page

This is a placeholder page for the serving frontend.

- + \ No newline at end of file diff --git a/clients/ui/bff/static/sub/test.html b/clients/ui/bff/static/sub/test.html index a28fa30f2..9c7be1706 100644 --- a/clients/ui/bff/static/sub/test.html +++ b/clients/ui/bff/static/sub/test.html @@ -7,4 +7,4 @@

Welcome to the BFF Stub Subfolder Page

This is a placeholder page for the serving frontend.

- + \ No newline at end of file diff --git a/clients/ui/docker-compose.yaml b/clients/ui/docker-compose.yaml deleted file mode 100644 index 7fbc2c8ca..000000000 --- a/clients/ui/docker-compose.yaml +++ /dev/null @@ -1,24 +0,0 @@ -services: - frontend: - build: ./frontend - container_name: model-registry-ui - ports: - - 8080:8080 - environment: - API_URL: http://model-registry-bff:4000 - networks: - - model_registry - depends_on: - - bff - bff: - build: ./bff - container_name: model-registry-bff - command: - - "--mock-k8s-client=true" - - "--mock-mr-client=true" - networks: - - model_registry - -networks: - model_registry: - name: model_registry diff --git a/clients/ui/bff/docs/dev-guide.md b/clients/ui/docs/local-deployment-guide.md similarity index 97% rename from clients/ui/bff/docs/dev-guide.md rename to clients/ui/docs/local-deployment-guide.md index 582c72896..e90d8105c 100644 --- a/clients/ui/bff/docs/dev-guide.md +++ b/clients/ui/docs/local-deployment-guide.md @@ -1,11 +1,11 @@ -# Development Guide +# Local Deployment Guide ## Local kubernetes deployment of Model Registry To test the BFF locally without mocking the k8s calls the Model Registry backend can be deployed locally using kind. ### Prerequisites The following tools need to be installed in your local environment: -* Podman (Docker should also work) - [Podman Desktop Instructions](https://podman-desktop.io) +* Docker - [Docker Instructions](https://www.docker.com) * kubectl - [Instructions](https://kubernetes.io/docs/tasks/tools/#kubectl) * kind - [Instructions](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) diff --git a/clients/ui/frontend/.env.development b/clients/ui/frontend/.env.development index 7d7cc8e82..005a0c6ca 100644 --- a/clients/ui/frontend/.env.development +++ b/clients/ui/frontend/.env.development @@ -1,3 +1 @@ APP_ENV=development -MOCK_AUTH=true -DEPLOYMENT_MODE=standalone \ No newline at end of file diff --git a/clients/ui/frontend/CONTRIBUTING.md b/clients/ui/frontend/CONTRIBUTING.md index 93bf6a1a0..c7901a0c7 100644 --- a/clients/ui/frontend/CONTRIBUTING.md +++ b/clients/ui/frontend/CONTRIBUTING.md @@ -22,20 +22,32 @@ And one for the "backend": ```bash cd ../bff -docker compose -f docker-compose.yaml up +go run ./cmd/main.go --port=4000 --static-assets-dir=./static --mock-k8s-client=true --mock-mr-client=true --dev-mode=true --dev-mode-port=8080 --standalone-mode=true ``` Once you have both services ready, you can open the dashboard locally at: `http://localhost:4010`. The dev server will reload automatically when you make changes. +You can also run an automated command to run both services: + +```bash +cd .. && make dev-start +``` ## Debugging and Testing See [frontend testing guidelines](docs/testing.md) for more information. -## Environment variables - -[TBD] +### Environment Variables -### Building your image +The following environment variables are used to configure the deployment and development environment for the Model Registry UI. These variables should be defined in a `.env.local` file in the `clients/ui` directory of the project. **These values will affect the build and push commands**. -[TBD] \ No newline at end of file +- `LOGO=logo-light-theme.svg` + - The file name for the logo used in the light theme. +- `LOGO_DARK=logo-dark-theme.svg` + - The file name for the logo used in the dark theme. +- `FAVICON=favicon.ico` + - The file name for the favicon of the application. +- `PRODUCT_NAME="Model Registry"` + - The name of the product displayed in the UI. +- `STYLE_THEME=mui-theme` + - The style theme used for the UI, in this case, Material-UI theme. diff --git a/clients/ui/frontend/Dockerfile b/clients/ui/frontend/Dockerfile deleted file mode 100644 index 448f724b9..000000000 --- a/clients/ui/frontend/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:20 AS build-stage - -WORKDIR /usr/src/app - -COPY . /usr/src/app - -RUN npm cache clean --force -RUN npm ci --omit=optional -RUN npm run build:prod - -FROM nginxinc/nginx-unprivileged - -ENV API_URL="http://localhost:4000" -ENV NGINX_ENVSUBST_FILTER="API_URL" - -COPY --from=build-stage /usr/src/app/dist/ "/usr/share/nginx/html" -COPY --from=build-stage /usr/src/app/nginx.conf "/etc/nginx/templates/default.conf.template" diff --git a/clients/ui/frontend/Makefile b/clients/ui/frontend/Makefile deleted file mode 100644 index f11445091..000000000 --- a/clients/ui/frontend/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -CONTAINER_TOOL ?= docker -IMG ?= model-registry-ui:latest - -.PHONY: all -all: docker-build - -.PHONY: help -help: ## Display this help. - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) - -.PHONY: docker-build -docker-build: - $(CONTAINER_TOOL) build -t ${IMG} . diff --git a/clients/ui/frontend/docs/README.md b/clients/ui/frontend/docs/README.md index 7a18ac343..48ecca522 100644 --- a/clients/ui/frontend/docs/README.md +++ b/clients/ui/frontend/docs/README.md @@ -1,5 +1,6 @@ [Dev setup & Requirements]: dev-setup.md [Architecture]: architecture.md +[Testing]: testing.md # Model Registry UI Documentation @@ -9,4 +10,5 @@ This is the general documentation of the Model Registry UI. ## Developer Readmes * [Dev setup & Requirements] -* [Architecture] \ No newline at end of file +* [Architecture] +* [Testing] \ No newline at end of file diff --git a/clients/ui/frontend/docs/architecture.md b/clients/ui/frontend/docs/architecture.md index 5ad39411b..f2a9f0383 100644 --- a/clients/ui/frontend/docs/architecture.md +++ b/clients/ui/frontend/docs/architecture.md @@ -4,4 +4,4 @@ ![Overview](./meta/arch-overview.png) -[TBD] +The Model Registry UI is a web application that provides a user interface for interacting with the Model Registry API. The UI is built using React and communicates with the Model Registry API using RESTful HTTP requests. The UI is designed to be responsive and accessible, providing a user-friendly experience for users interacting with the Model Registry. diff --git a/clients/ui/frontend/docs/dev-setup.md b/clients/ui/frontend/docs/dev-setup.md index 76981767c..2fe6e9653 100644 --- a/clients/ui/frontend/docs/dev-setup.md +++ b/clients/ui/frontend/docs/dev-setup.md @@ -32,8 +32,6 @@ npm run build This is the default context for running a local UI. Make sure you build the project using the instructions above prior to running the command below. -You will need to inject your requests with a kubeflow-userid header for authorization purposes. For example, you can use the [Header Editor](https://chromewebstore.google.com/detail/eningockdidmgiojffjmkdblpjocbhgh) extension in Chrome to set the kubeflow-userid header to user@example.com. - ```bash npm run start:dev ``` diff --git a/clients/ui/frontend/nginx.conf b/clients/ui/frontend/nginx.conf deleted file mode 100644 index becbbfd8c..000000000 --- a/clients/ui/frontend/nginx.conf +++ /dev/null @@ -1,22 +0,0 @@ -server { - listen 8080 default_server; - listen [::]:8080 default_server; - server_name _; - root /usr/share/nginx/html; - gzip on; - access_log /dev/stdout main; - - location / { - try_files $uri $uri/ /index.html; - } - - location /api/ { - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_pass ${API_URL}; - proxy_http_version 1.1; - } - } - diff --git a/clients/ui/frontend/src/app/App.tsx b/clients/ui/frontend/src/app/App.tsx index 9dd18f386..625ae2c04 100644 --- a/clients/ui/frontend/src/app/App.tsx +++ b/clients/ui/frontend/src/app/App.tsx @@ -74,12 +74,11 @@ const App: React.FC = () => {

- {String(error)} {configError?.message || namespacesLoadError?.message || - 'Unknown error occurred during startup!!!!!!'} + 'Unknown error occurred during startup'}

-

Logging out and logging back in may solve the issue!!!!!c.

+

Logging out and logging back in may solve the issue

diff --git a/clients/ui/manifests/base/kustomization.yaml b/clients/ui/manifests/base/kustomization.yaml index 0ab619941..03230eb6c 100644 --- a/clients/ui/manifests/base/kustomization.yaml +++ b/clients/ui/manifests/base/kustomization.yaml @@ -2,17 +2,12 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- model-registry-bff-role.yaml -- model-registry-bff-service.yaml -- model-registry-bff-deployment.yaml -- model-registry-bff-service-account.yaml +- model-registry-ui-role.yaml - model-registry-ui-service.yaml - model-registry-ui-deployment.yaml +- model-registry-ui-service-account.yaml images: - name: model-registry-ui-image newName: docker.io/kubeflow/model-registry-ui newTag: latest -- name: model-registry-bff-image - newName: docker.io/kubeflow/model-registry-bff - newTag: latest diff --git a/clients/ui/manifests/base/model-registry-bff-deployment.yaml b/clients/ui/manifests/base/model-registry-bff-deployment.yaml deleted file mode 100644 index 27a2b5998..000000000 --- a/clients/ui/manifests/base/model-registry-bff-deployment.yaml +++ /dev/null @@ -1,29 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: model-registry-bff - labels: - app: model-registry-bff -spec: - replicas: 1 - selector: - matchLabels: - app: model-registry-bff - template: - metadata: - labels: - app: model-registry-bff - spec: - serviceAccountName: model-registry-bff - containers: - - name: model-registry-bff - image: model-registry-bff-image - resources: - limits: - cpu: 500m - memory: 2Gi - requests: - cpu: 500m - memory: 2Gi - ports: - - containerPort: 4000 diff --git a/clients/ui/manifests/base/model-registry-bff-role.yaml b/clients/ui/manifests/base/model-registry-bff-role.yaml deleted file mode 100644 index 82a210855..000000000 --- a/clients/ui/manifests/base/model-registry-bff-role.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: bff-service-reader -rules: -- apiGroups: [""] - resources: ["services"] - verbs: ["get", "watch", "list"] - ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: bff-read-services -subjects: -- kind: ServiceAccount - name: model-registry-bff - namespace: kubeflow -roleRef: - kind: ClusterRole - name: bff-service-reader - apiGroup: rbac.authorization.k8s.io diff --git a/clients/ui/manifests/base/model-registry-bff-service.yaml b/clients/ui/manifests/base/model-registry-bff-service.yaml deleted file mode 100644 index 929022cdb..000000000 --- a/clients/ui/manifests/base/model-registry-bff-service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: model-registry-bff-service - labels: - app: model-registry-bff - run: model-registry-bff -spec: - selector: - app: model-registry-bff - ports: - - protocol: TCP - port: 4000 - targetPort: 4000 - name: http \ No newline at end of file diff --git a/clients/ui/manifests/base/model-registry-ui-deployment.yaml b/clients/ui/manifests/base/model-registry-ui-deployment.yaml index 0ef0cd6c2..41e1aa456 100644 --- a/clients/ui/manifests/base/model-registry-ui-deployment.yaml +++ b/clients/ui/manifests/base/model-registry-ui-deployment.yaml @@ -14,9 +14,32 @@ spec: labels: app: model-registry-ui spec: + serviceAccountName: model-registry-ui containers: - name: model-registry-ui image: model-registry-ui-image + imagePullPolicy: Always + livenessProbe: + tcpSocket: + port: 8080 + initialDelaySeconds: 30 + timeoutSeconds: 15 + periodSeconds: 30 + successThreshold: 1 + failureThreshold: 3 + readinessProbe: + httpGet: + path: /api/v1/healthcheck + port: 8080 + scheme: HTTP + httpHeaders: + - name: kubeflow-userid + value: user@example.com + initialDelaySeconds: 15 + timeoutSeconds: 15 + periodSeconds: 30 + successThreshold: 1 + failureThreshold: 3 resources: limits: cpu: 500m @@ -26,6 +49,5 @@ spec: memory: 2Gi ports: - containerPort: 8080 - env: - - name: API_URL - value: "http://model-registry-bff-service:4000" + args: + - "--port=8080" diff --git a/clients/ui/manifests/kubeflow/kubeflow-dashboard-rbac.yaml b/clients/ui/manifests/base/model-registry-ui-role.yaml similarity index 63% rename from clients/ui/manifests/kubeflow/kubeflow-dashboard-rbac.yaml rename to clients/ui/manifests/base/model-registry-ui-role.yaml index 0b5896d6d..d1dfef45d 100644 --- a/clients/ui/manifests/kubeflow/kubeflow-dashboard-rbac.yaml +++ b/clients/ui/manifests/base/model-registry-ui-role.yaml @@ -1,4 +1,30 @@ --- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: model-registry-ui-services-reader +rules: +- apiGroups: + - '' + resources: + - services + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: model-registry-ui-services-reader-binding +subjects: +- kind: ServiceAccount + name: model-registry-ui +roleRef: + kind: ClusterRole + name: model-registry-ui-services-reader + apiGroup: rbac.authorization.k8s.io +--- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: @@ -11,6 +37,7 @@ rules: verbs: - get - list + - watch --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding @@ -22,8 +49,7 @@ roleRef: name: model-registry-retrieve-clusterrolebindings subjects: - kind: ServiceAccount - name: model-registry-bff - namespace: kubeflow + name: model-registry-ui --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole @@ -47,5 +73,4 @@ roleRef: name: model-registry-create-sars subjects: - kind: ServiceAccount - name: model-registry-bff - namespace: kubeflow + name: model-registry-ui diff --git a/clients/ui/manifests/base/model-registry-bff-service-account.yaml b/clients/ui/manifests/base/model-registry-ui-service-account.yaml similarity index 64% rename from clients/ui/manifests/base/model-registry-bff-service-account.yaml rename to clients/ui/manifests/base/model-registry-ui-service-account.yaml index 5cbafe203..a35ae35c0 100644 --- a/clients/ui/manifests/base/model-registry-bff-service-account.yaml +++ b/clients/ui/manifests/base/model-registry-ui-service-account.yaml @@ -2,4 +2,4 @@ kind: ServiceAccount apiVersion: v1 metadata: - name: model-registry-bff + name: model-registry-ui diff --git a/clients/ui/manifests/kubeflow/kustomization.yaml b/clients/ui/manifests/kubeflow/kustomization.yaml deleted file mode 100644 index 64ebb3d52..000000000 --- a/clients/ui/manifests/kubeflow/kustomization.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: - - ../overlays/istio - - kubeflow-dashboard-rbac.yaml - -patchesJson6902: - - path: model-registry-ui-deployment.yaml - target: - group: apps - version: v1 - kind: Deployment - name: model-registry-ui-deployment - - path: model-registry-bff-deployment.yaml - target: - group: apps - version: v1 - kind: Deployment - name: model-registry-bff-deployment \ No newline at end of file diff --git a/clients/ui/manifests/kubeflow/model-registry-ui-deployment.yaml b/clients/ui/manifests/kubeflow/model-registry-ui-deployment.yaml deleted file mode 100644 index ee036eea0..000000000 --- a/clients/ui/manifests/kubeflow/model-registry-ui-deployment.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/env - value: - - name: API_URL - value: "http://model-registry-bff-service.kubeflow.svc.cluster.local:4000" - - name: MOCK_AUTH - value: "false" - - name: DEPLOYMENT_MODE - value: "integrated" \ No newline at end of file diff --git a/clients/ui/manifests/overlays/integrated/kustomization.yaml b/clients/ui/manifests/overlays/integrated/kustomization.yaml new file mode 100644 index 000000000..95429edd7 --- /dev/null +++ b/clients/ui/manifests/overlays/integrated/kustomization.yaml @@ -0,0 +1,13 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../../base + +patches: + - path: model-registry-ui-deployment.yaml + target: + group: apps + version: v1 + kind: Deployment + name: model-registry-ui diff --git a/clients/ui/manifests/kubeflow/model-registry-bff-deployment.yaml b/clients/ui/manifests/overlays/integrated/model-registry-ui-deployment.yaml similarity index 83% rename from clients/ui/manifests/kubeflow/model-registry-bff-deployment.yaml rename to clients/ui/manifests/overlays/integrated/model-registry-ui-deployment.yaml index b7216756d..cb2fc6832 100644 --- a/clients/ui/manifests/kubeflow/model-registry-bff-deployment.yaml +++ b/clients/ui/manifests/overlays/integrated/model-registry-ui-deployment.yaml @@ -2,3 +2,4 @@ path: /spec/template/spec/containers/0/args value: - "--standalone-mode=false" + - "--port=8080" diff --git a/clients/ui/manifests/overlays/istio/authorization-policy-bff.yaml b/clients/ui/manifests/overlays/istio/authorization-policy-bff.yaml deleted file mode 100644 index eed8522dd..000000000 --- a/clients/ui/manifests/overlays/istio/authorization-policy-bff.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: security.istio.io/v1beta1 -kind: AuthorizationPolicy -metadata: - name: model-registry-bff - labels: - app: model-registry-bff -spec: - action: ALLOW - rules: - - {} - selector: - matchLabels: - app: model-registry-bff diff --git a/clients/ui/manifests/overlays/istio/destination-rule-bff.yaml b/clients/ui/manifests/overlays/istio/destination-rule-bff.yaml deleted file mode 100644 index e149dc133..000000000 --- a/clients/ui/manifests/overlays/istio/destination-rule-bff.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: networking.istio.io/v1alpha3 -kind: DestinationRule -metadata: - name: model-registry-bff - labels: - app: model-registry-bff -spec: - host: model-registry-bff-service.kubeflow.svc.cluster.local - trafficPolicy: - tls: - mode: ISTIO_MUTUAL diff --git a/clients/ui/manifests/overlays/istio/kustomization.yaml b/clients/ui/manifests/overlays/istio/kustomization.yaml index d40a96bdd..c0f6f8fed 100644 --- a/clients/ui/manifests/overlays/istio/kustomization.yaml +++ b/clients/ui/manifests/overlays/istio/kustomization.yaml @@ -2,16 +2,16 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- ../../base +- ../integrated - virtual-service.yaml - destination-rule-ui.yaml -- destination-rule-bff.yaml - authorization-policy-ui.yaml -- authorization-policy-bff.yaml -patchesJson6902: +patches: - path: model-registry-ui-service.yaml target: version: v1 kind: Service - name: model-registry-ui-service \ No newline at end of file + name: model-registry-ui-service + +namespace: kubeflow \ No newline at end of file diff --git a/clients/ui/manifests/overlays/standalone/kubeflow-dashboard-rbac.yaml b/clients/ui/manifests/overlays/standalone/kubeflow-dashboard-rbac.yaml new file mode 100644 index 000000000..9bfca02c7 --- /dev/null +++ b/clients/ui/manifests/overlays/standalone/kubeflow-dashboard-rbac.yaml @@ -0,0 +1,39 @@ +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: model-registry-ui-namespaces-reader +rules: +- apiGroups: + - '' + resources: + - namespaces + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: model-registry-ui-namespaces-reader-binding +subjects: +- kind: ServiceAccount + name: model-registry-ui +roleRef: + kind: ClusterRole + name: model-registry-ui-namespaces-reader + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: service-access-cluster-binding +subjects: + - kind: User + name: user@example.com + apiGroup: rbac.authorization.k8s.io +roleRef: + kind: ClusterRole + name: cluster-admin + apiGroup: rbac.authorization.k8s.io diff --git a/clients/ui/manifests/overlays/standalone/kustomization.yaml b/clients/ui/manifests/overlays/standalone/kustomization.yaml new file mode 100644 index 000000000..c32312d1b --- /dev/null +++ b/clients/ui/manifests/overlays/standalone/kustomization.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../../base +- kubeflow-dashboard-rbac.yaml + +patches: +- path: model-registry-ui-deployment.yaml + target: + group: apps + kind: Deployment + name: model-registry-ui + version: v1 diff --git a/clients/ui/manifests/standalone/model-registry-bff-deployment.yaml b/clients/ui/manifests/overlays/standalone/model-registry-ui-deployment.yaml similarity index 82% rename from clients/ui/manifests/standalone/model-registry-bff-deployment.yaml rename to clients/ui/manifests/overlays/standalone/model-registry-ui-deployment.yaml index 38b5569a8..0d41529c8 100644 --- a/clients/ui/manifests/standalone/model-registry-bff-deployment.yaml +++ b/clients/ui/manifests/overlays/standalone/model-registry-ui-deployment.yaml @@ -2,3 +2,4 @@ path: /spec/template/spec/containers/0/args value: - "--standalone-mode=true" + - "--port=8080" diff --git a/clients/ui/manifests/standalone/kubeflow-dashboard-rbac.yaml b/clients/ui/manifests/standalone/kubeflow-dashboard-rbac.yaml deleted file mode 100644 index e81048d8e..000000000 --- a/clients/ui/manifests/standalone/kubeflow-dashboard-rbac.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: service-access-cluster-role -rules: - - apiGroups: [""] - resources: ["services"] - verbs: ["get", "list"] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: service-access-cluster-binding -subjects: - - kind: User - name: user@example.com - apiGroup: rbac.authorization.k8s.io -roleRef: - kind: ClusterRole - name: service-access-cluster-role - apiGroup: rbac.authorization.k8s.io diff --git a/clients/ui/manifests/standalone/kustomization.yaml b/clients/ui/manifests/standalone/kustomization.yaml deleted file mode 100644 index f60c1fa46..000000000 --- a/clients/ui/manifests/standalone/kustomization.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: - - kubeflow-dashboard-rbac.yaml - -patchesJson6902: - - path: model-registry-ui-deployment.yaml - target: - group: apps - version: v1 - kind: Deployment - name: model-registry-bff-deployment - - path: model-registry-bff-deployment.yaml - target: - group: apps - version: v1 - kind: Deployment - name: model-registry-bff-deployment \ No newline at end of file diff --git a/clients/ui/manifests/standalone/model-registry-ui-deployment.yaml b/clients/ui/manifests/standalone/model-registry-ui-deployment.yaml deleted file mode 100644 index 5211d0b05..000000000 --- a/clients/ui/manifests/standalone/model-registry-ui-deployment.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- op: add - path: /spec/template/spec/containers/0/env - value: - - name: API_URL - value: "http://model-registry-bff-service:4000" - - name: MOCK_AUTH - value: "true" - - name: DEPLOYMENT_MODE - value: "standalone" \ No newline at end of file diff --git a/clients/ui/scripts/deploy_kind_cluster.sh b/clients/ui/scripts/deploy_kind_cluster.sh index 57f365cf5..aa6205b7a 100755 --- a/clients/ui/scripts/deploy_kind_cluster.sh +++ b/clients/ui/scripts/deploy_kind_cluster.sh @@ -33,28 +33,25 @@ else kubectl get pods -n kubeflow fi +# Step 4: Build Model Registry and push in standalone mode +echo "Building Model Registry UI..." +make docker-build-standalone +make docker-push-standalone + +echo "Editing kustomize image..." pushd ./manifests/base -kustomize edit set namespace kubeflow -kustomize edit set image model-registry-ui-image=${IMG_FRONTEND} -kustomize edit set image model-registry-bff-image=${IMG_BFF} +kustomize edit set image model-registry-ui-image=${IMG_UI_STANDALONE} +pushd ../overlays/standalone # Step 4: Deploy model registry UI echo "Deploying Model Registry UI..." +kustomize edit set namespace kubeflow kubectl apply -n kubeflow -k . # Wait for deployment to be available echo "Waiting Model Registry UI to be available..." kubectl wait --for=condition=available -n kubeflow deployment/model-registry-ui --timeout=1m -pushd ../user-rbac -# Step 5: Apply admin user service account in the cluster -echo "Applying admin user service account and rolebinding..." -kubectl apply -k . - -# Step 6: Generate token for admin user and display it -echo "In your browser, you will need to inject your requests with a kubeflow-userid header for authorization purposes." -echo "For example, you can use the Header Editor - https://chromewebstore.google.com/detail/eningockdidmgiojffjmkdblpjocbhgh extension in Chrome to set the kubeflow-userid header to user@example.com." - # Step 5: Port-forward the service echo "Port-forwarding Model Registry UI..." echo -e "\033[32mDashboard available in http://localhost:8080\033[0m" From b4ce1ba945b5d9bbb274d4c9918a45270e25d5af Mon Sep 17 00:00:00 2001 From: lucferbux Date: Tue, 14 Jan 2025 23:43:39 +0100 Subject: [PATCH 2/3] Test github action --- clients/ui/manifests/base/kustomization.yaml | 2 +- clients/ui/manifests/overlays/standalone/kustomization.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/clients/ui/manifests/base/kustomization.yaml b/clients/ui/manifests/base/kustomization.yaml index 03230eb6c..0a8ca8144 100644 --- a/clients/ui/manifests/base/kustomization.yaml +++ b/clients/ui/manifests/base/kustomization.yaml @@ -9,5 +9,5 @@ resources: images: - name: model-registry-ui-image - newName: docker.io/kubeflow/model-registry-ui + newName: quay.io/lferrnan/model-registry-ui newTag: latest diff --git a/clients/ui/manifests/overlays/standalone/kustomization.yaml b/clients/ui/manifests/overlays/standalone/kustomization.yaml index c32312d1b..e6084a643 100644 --- a/clients/ui/manifests/overlays/standalone/kustomization.yaml +++ b/clients/ui/manifests/overlays/standalone/kustomization.yaml @@ -12,3 +12,5 @@ patches: kind: Deployment name: model-registry-ui version: v1 + +namespace: kubeflow \ No newline at end of file From b371e2d1ccc9532719af995283de11f526fa4727 Mon Sep 17 00:00:00 2001 From: lucferbux Date: Tue, 14 Jan 2025 23:43:55 +0100 Subject: [PATCH 3/3] Test github action --- .github/workflows/build-and-push-ui-images.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-push-ui-images.yml b/.github/workflows/build-and-push-ui-images.yml index 0b98c127f..c8b1bf165 100644 --- a/.github/workflows/build-and-push-ui-images.yml +++ b/.github/workflows/build-and-push-ui-images.yml @@ -1,5 +1,6 @@ name: Build and Push UI and BFF Images on: + workflow_dispatch: push: branches: - 'main'