From eeb020e9e690b729d99b694c456f197daf6da07a Mon Sep 17 00:00:00 2001 From: Griffin Sullivan <48397354+Griffin-Sullivan@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:55:20 -0400 Subject: [PATCH] Add manifests dir to define K8s resources for the UI (#356) Signed-off-by: Griffin-Sullivan --- clients/ui/bff/Dockerfile | 4 -- clients/ui/manifests/base/README.md | 63 +++++++++++++++++++ clients/ui/manifests/base/kustomization.yaml | 15 +++++ .../base/model-registry-bff-deployment.yaml | 28 +++++++++ .../base/model-registry-bff-role.yaml | 23 +++++++ .../base/model-registry-bff-service.yaml | 11 ++++ .../base/model-registry-ui-deployment.yaml | 28 +++++++++ .../base/model-registry-ui-service.yaml | 12 ++++ 8 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 clients/ui/manifests/base/README.md create mode 100644 clients/ui/manifests/base/kustomization.yaml create mode 100644 clients/ui/manifests/base/model-registry-bff-deployment.yaml create mode 100644 clients/ui/manifests/base/model-registry-bff-role.yaml create mode 100644 clients/ui/manifests/base/model-registry-bff-service.yaml create mode 100644 clients/ui/manifests/base/model-registry-ui-deployment.yaml create mode 100644 clients/ui/manifests/base/model-registry-ui-service.yaml diff --git a/clients/ui/bff/Dockerfile b/clients/ui/bff/Dockerfile index 248c4665..ac3e2a68 100644 --- a/clients/ui/bff/Dockerfile +++ b/clients/ui/bff/Dockerfile @@ -34,8 +34,4 @@ USER 65532:65532 # Expose port 4000 EXPOSE 4000 -# Define environment variables -ENV PORT 4001 -ENV ENV development - ENTRYPOINT ["/bff"] diff --git a/clients/ui/manifests/base/README.md b/clients/ui/manifests/base/README.md new file mode 100644 index 00000000..5ed1314e --- /dev/null +++ b/clients/ui/manifests/base/README.md @@ -0,0 +1,63 @@ +[Model registry server set up]: ../../bff/docs/dev-guide.md + +## Deploying the Model Registry UI in a local cluster + +For this guide, we will be using kind for locally deploying our cluster. See +the [Model registry server set up] guide for prerequisites on setting up kind +and deploying the model registry server. + +### Setup +#### 1. Create a kind cluster +Create a local cluster for running the MR UI using the following command: +```shell +kind create cluster +``` + +#### 2. Create kubeflow namespace +Create a namespace for model registry to run in, by default this is kubeflow, run: +```shell +kubectl create namespace kubeflow +``` + +#### 3. Deploy Model Registry UI to cluster +You can now deploy the UI and BFF to your newly created cluster using the kustomize configs in this directory: +```shell +cd clients/ui + +kubectl apply -k manifests/base/ -n kubeflow +``` + +After a few seconds you should see 2 pods running (1 for BFF and 1 for UI): +```shell +kubectl get pods -n kubeflow +``` +``` +NAME READY STATUS RESTARTS AGE +model-registry-bff-746f674b99-bfvgs 1/1 Running 0 11s +model-registry-ui-58755c4754-zdrnr 1/1 Running 0 11s +``` + +#### 4. Access the Model Registry UI running in the cluster +Now that the pods are up and running you can access the UI. + +First you will need to port-forward the UI service by running the following in it's own terminal: +```shell +kubectl port-forward service/model-registry-ui-service 8080:8080 -n kubeflow +``` + +You can then access the UI running in your cluster locally at http://localhost:8080/ + +To test the BFF separately you can also port-forward that service by running: +```shell +kubectl port-forward service/model-registry-bff-service 4000:4000 -n kubeflow +``` + +You can now make API requests to the BFF endpoints like: +```shell +curl http://localhost:4000/api/v1/model-registry +``` +``` +{ + "model_registry": null +} +``` diff --git a/clients/ui/manifests/base/kustomization.yaml b/clients/ui/manifests/base/kustomization.yaml new file mode 100644 index 00000000..7a3e3676 --- /dev/null +++ b/clients/ui/manifests/base/kustomization.yaml @@ -0,0 +1,15 @@ +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-ui-service.yaml + - model-registry-ui-deployment.yaml + +images: + - name: model-registry-ui-image + newName: quay.io/gsulliva/mr-ui:latest + - name: model-registry-bff-image + newName: quay.io/gsulliva/mr-bff:latest diff --git a/clients/ui/manifests/base/model-registry-bff-deployment.yaml b/clients/ui/manifests/base/model-registry-bff-deployment.yaml new file mode 100644 index 00000000..311aaebd --- /dev/null +++ b/clients/ui/manifests/base/model-registry-bff-deployment.yaml @@ -0,0 +1,28 @@ +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: + 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 new file mode 100644 index 00000000..6b5ea195 --- /dev/null +++ b/clients/ui/manifests/base/model-registry-bff-role.yaml @@ -0,0 +1,23 @@ +--- +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: default + 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 new file mode 100644 index 00000000..20c1e0df --- /dev/null +++ b/clients/ui/manifests/base/model-registry-bff-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: model-registry-bff-service +spec: + selector: + app: model-registry-bff + ports: + - protocol: TCP + port: 4000 + targetPort: 4000 \ 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 new file mode 100644 index 00000000..3e0e9a05 --- /dev/null +++ b/clients/ui/manifests/base/model-registry-ui-deployment.yaml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: model-registry-ui + labels: + app: model-registry-ui +spec: + replicas: 1 + selector: + matchLabels: + app: model-registry-ui + template: + metadata: + labels: + app: model-registry-ui + spec: + containers: + - name: model-registry-ui + image: model-registry-ui-image + resources: + limits: + cpu: 500m + memory: 2Gi + requests: + cpu: 500m + memory: 2Gi + ports: + - containerPort: 8080 diff --git a/clients/ui/manifests/base/model-registry-ui-service.yaml b/clients/ui/manifests/base/model-registry-ui-service.yaml new file mode 100644 index 00000000..10211cd1 --- /dev/null +++ b/clients/ui/manifests/base/model-registry-ui-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: model-registry-ui-service +spec: + selector: + app: model-registry-ui + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 + name: http