To test the BFF locally without mocking the k8s calls the Model Registry backend can be deployed locally using kind.
The following tools need to be installed in your local environment:
- Docker - Docker Instructions
- kubectl - Instructions
- kind - Instructions
Note: all of the above tools can be installed using your OS package manager, this is the preferred method.
Create a local cluster for running the MR backend using the following command:
kind create clusterKind will start creating a new local cluster for you to deploy, once it has completed verify you can access the cluster using kubectl by running:
kubectl cluster-infoIf everything is working correctly you should see output similar to:
Kubernetes control plane is running at https://127.0.0.1:58635
CoreDNS is running at https://127.0.0.1:58635/api/v1/namespaces/kube-system/services/kube-dns:dns/proxyCreate a namespace for model registry to run in, by default this is kubeflow, run:
kubectl create namespace kubeflowthen, switch to that kubeflow namespace
kubectl config set-context --current --namespace=kubeflowYou can now deploy the MR backend to your newly created cluster using the kustomize configs in the MR repository by running:
kubectl apply -k "https://github.com/kubeflow/model-registry/manifests/kustomize/overlays/db"Wait for the model registry deployment to spin up, alternatively run:
kubectl wait --for=condition=available -n kubeflow deployment/model-registry-deployment --timeout=1mThis command will return when the cluster is ready. To verify this now run:
kubectl get pods -n kubeflowTwo pods should be listed, model-registry-db-xxx and model-registry-deployment-yyy both should have a status of Running.
There is currently an issue deploying to an arm64 device such as a Mac with an M-series chip. This is because the MySql image tag deployed by the manifests does not have an arm64 compatible image. To work around this you can use a modified manifest deployed in a fork of the repo - you can use this by running the below command instead of the first command in section 3 of this guide.
kubectl apply -k "https://github.com/alexcreasy/model-registry/manifests/kustomize/overlays/db?ref=kind"Note: an issue has been filed regarding this ticket here:
In order to access the MR REST API locally you need to forward a local port to 8080 on the MR service. Run the following command: (Note: this command starts a long-running service and will not exit the shell)
kubectl port-forward svc/model-registry-service -n kubeflow 8080:8080Note: you can change the local forwarded port by changing the first port value, e.g. 4000:8080 will forward port 4000
to the MR service.
In a separate terminal window to the previous step, test the service by querying one of the rest endpoints, for example:
curl http://localhost:8080/api/model_registry/v1alpha3/registered_modelsYou should receive a 200 response if everything is working correctly, the body should look like:
{"items":[],"nextPageToken":"","pageSize":0,"size":0}To access your local kind cluster when running the BFF locally, you can use the DEV_MODE option. This is useful for when
you want to test live changes on real cluster. To do so, simply run:
make run DEV_MODE=trueYou can also specify the port you are forwarding to if it is something other than 8080:
make run DEV_MODE=true DEV_MODE_MODEL_REGISTRY_PORT=8081