From 708910e0c367e966f109d3bddbd137278e79dc92 Mon Sep 17 00:00:00 2001 From: lucferbux Date: Mon, 13 Jan 2025 18:20:12 +0100 Subject: [PATCH] Revamp deployment files to get UI in one container Signed-off-by: lucferbux --- .../workflows/build-and-push-ui-images.yml | 18 +++--- clients/ui/.env | 5 +- clients/ui/.env.production | 2 + clients/ui/Dockerfile | 59 +++++++++++++++++++ clients/ui/Makefile | 51 ++++++++++------ clients/ui/README.md | 40 +++---------- clients/ui/bff/.gitignore | 1 + clients/ui/bff/Dockerfile | 33 ----------- clients/ui/bff/Makefile | 5 -- 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 | 17 ++---- clients/ui/frontend/.env.development | 2 - clients/ui/frontend/Dockerfile | 17 ------ clients/ui/frontend/Makefile | 13 ---- 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 | 25 +++++++- .../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 | 16 ++--- 40 files changed, 259 insertions(+), 376 deletions(-) create mode 100644 clients/ui/Dockerfile delete mode 100644 clients/ui/bff/Dockerfile 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..98c0d4690 100644 --- a/.github/workflows/build-and-push-ui-images.yml +++ b/.github/workflows/build-and-push-ui-images.yml @@ -10,7 +10,7 @@ on: env: IMG_ORG: kubeflow IMG_UI_REPO: model-registry-ui - IMG_BFF_REPO: model-registry-bff + IMG_UI_REPO_STANDALONE: model-registry-ui-standalone DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }} DOCKER_PWD: ${{ secrets.DOCKERHUB_TOKEN }} PUSH_IMAGE: true @@ -36,11 +36,11 @@ jobs: env: IMG_REPO: ${{ env.IMG_UI_REPO }} run: ./scripts/build_deploy.sh - - name: Build and Push BFF Image + - name: Build and Push Standalone UI Image shell: bash env: - IMG_REPO: ${{ env.IMG_BFF_REPO }} - run: ./scripts/build_deploy.sh + IMG_REPO: ${{ env.IMG_UI_REPO_STANDALONE }} + run: MOCK_AUTH=true DEPLOYMENT_MODE=standalone ./scripts/build_deploy.sh - name: Tag Latest UI Image if: env.BUILD_CONTEXT == 'main' shell: bash @@ -52,14 +52,14 @@ 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 + - name: Tag Latest UI 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 + IMG_REPO: ${{ env.IMG_UI_REPO_STANDALONE }} + IMG: ${{ env.IMG_ORG }}/${{ env.IMG_UI_REPO_STANDALONE }} + BUILD_IMAGE: false # image is already built in "Build and Push UI 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 + VERSION=latest ./scripts/build_deploy.sh 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..daf6bd263 100644 --- a/clients/ui/Makefile +++ b/clients/ui/Makefile @@ -44,29 +44,27 @@ 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 - -############ Push ############ +.PHONY: docker-buildx +docker-buildx: + docker buildx build --platform ${PLATFORM} -t ${IMG_UI} --push . -.PHONY: push-bff -push-bff: - ${CONTAINER_TOOL} push ${IMG_BFF} +.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-frontend -push-frontend: - ${CONTAINER_TOOL} push ${IMG_FRONTEND} +############ Push ############ -.PHONY: push -push: push-bff push-frontend +.PHONY: docker-push +docker-push: + ${CONTAINER_TOOL} push ${IMG_UI} ############ Deployment ############ @@ -77,3 +75,20 @@ docker-compose: .PHONY: kind-deployment kind-deployment: ./scripts/deploy_kind_cluster.sh + +############ Build ############ +.PHONY: frontend-build +frontend-build: + 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-mocked +run-mocked: + cp -r ./frontend/dist/ ./bff/static-local-run/ && cd bff && make run STATIC_ASSETS_DIR=./static-local-run \ No newline at end of file diff --git a/clients/ui/README.md b/clients/ui/README.md index 287b62450..3a942bc42 100644 --- a/clients/ui/README.md +++ b/clients/ui/README.md @@ -58,17 +58,11 @@ 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` - -### `IMG_FRONTEND` - -* **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). +* **Default Value**: `model-registry-ui:latest` +* **Example**: `IMG_UI=model-registry-bff:latest` ### Example `.env.local` File @@ -76,8 +70,7 @@ 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=kubeflow/model-registry-ui:latest ``` ## Build and Push Commands @@ -86,28 +79,11 @@ The following Makefile targets are used to build and push the Docker images for ### 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. - -* **`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. - -* **`build`**: Builds the Docker images for both the BFF and frontend services. +* **`build`**: Builds the Docker image for both UI service. * Command: `make build` - * This command runs both `build-bff` and `build-frontend` targets. ### Push Commands -* **`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-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. - -* **`push`**: Pushes the Docker images for both the BFF and frontend services to the container registry. +* **`push`**: Pushes the Docker image for the UI service to the container registry. * Command: `make push` - * This command runs both `push-bff` and `push-frontend` targets. + * This command uses the `CONTAINER_TOOL` and `IMG_UI` 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/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 index 7fbc2c8ca..40d404fb0 100644 --- a/clients/ui/docker-compose.yaml +++ b/clients/ui/docker-compose.yaml @@ -1,21 +1,12 @@ services: - frontend: - build: ./frontend + ui: + build: . 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" + - "--dev-mode=true" + - "--standalone-mode=true" networks: - model_registry 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/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/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..c1379021b 100644 --- a/clients/ui/manifests/base/model-registry-ui-deployment.yaml +++ b/clients/ui/manifests/base/model-registry-ui-deployment.yaml @@ -14,9 +14,29 @@ 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 + # initialDelaySeconds: 30 + # timeoutSeconds: 15 + # periodSeconds: 30 + # successThreshold: 1 + # failureThreshold: 3 resources: limits: cpu: 500m @@ -26,6 +46,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..87eab48c7 100755 --- a/clients/ui/scripts/deploy_kind_cluster.sh +++ b/clients/ui/scripts/deploy_kind_cluster.sh @@ -33,28 +33,20 @@ else kubectl get pods -n kubeflow fi +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"