Addition of a Discovery Service#

Goal: Deploy the Auto Discovery Service so clients and services can find each other via a single entrypoint that returns a JSON catalog of services and endpoints (local MicroK8s deployment).

The Auto Discovery Service watches the Kubernetes Service objects in the namespace, and publishes the ones annotated discovery.omniverse.nvidia.com/enabled: "true". Clients request {hostname}:{port}/api/v2beta/services and receive a JSON object with service information. You do not list services in the Discovery configuration; you annotate them.

Service Ports#

Port

Protocol

Description

8080

HTTP/REST

Internal catalog (/api/v2beta/services)

8081

HTTP/REST

External catalog (/api/v2beta/services)

Pulling the Auto Discovery Service Helm Chart#

Pull the Auto Discovery Service Helm chart from the NGC catalog. Set NGC_API_KEY in the Bash session used for the deployment commands. Enter your NGC API key at the prompt; the input is hidden. Repeat this step if you open a new terminal.

read -r -s -p 'NGC API key: ' NGC_API_KEY
printf '\n'
export NGC_API_KEY
# pull the chart from NGC
# make sure you have enabled helm in microk8s
microk8s enable helm
# pull the chart from NGC
microk8s helm fetch https://helm.ngc.nvidia.com/nvidia/omniverse/charts/auto-discovery-service-1.2.0.tgz --username='$oauthtoken' --password="${NGC_API_KEY:?Set NGC_API_KEY in this Bash session}"

# unpack the chart and cd into the directory
tar -xvf auto-discovery-service-1.2.0.tgz
cd auto-discovery-service

Configure Overrides for the Discovery Service#

Override only the values you need. Create discovery-values.yaml in the same directory as the Helm chart.

# create and edit the local values file, we're using VS Code for this example
code discovery-values.yaml

If you removed the namespace after the storage service, recreate it.

# create the namespace
microk8s kubectl create namespace storage-apis-dev

# validate the namespace was created
microk8s kubectl get namespace storage-apis-dev

Pull Secrets#

Create a pull secret so the cluster can pull images from the registry. Use the NGC_API_KEY variable set earlier in this Bash session.

# create a Kubernetes secret with the pull secret
microk8s kubectl create secret docker-registry ngcpull-secret --docker-server=nvcr.io --docker-username='$oauthtoken' --docker-password="${NGC_API_KEY:?Set NGC_API_KEY in this Bash session}" -n storage-apis-dev

# validate the secret was created
microk8s kubectl get secret ngcpull-secret -n storage-apis-dev

Reference the secret in discovery-values.yaml so the cluster can pull the images.

image:
  pullSecrets:
    - name: ngcpull-secret

The chart’s default image-pull secret is regcred; the override above replaces it with ngcpull-secret.

discovery-values.yaml

Install the Discovery Service.

# validate the chart
microk8s helm template . -f discovery-values.yaml

# dry-run the install
microk8s helm upgrade --install auto-discovery-service . -f discovery-values.yaml --namespace storage-apis-dev --dry-run --debug

If everything looks good, you can install the Discovery Service.

# install the discovery service
microk8s helm upgrade --install auto-discovery-service . -f discovery-values.yaml --namespace storage-apis-dev

# validate the pod is running, this may take a few minutes to start up
microk8s kubectl get pods -n storage-apis-dev

Register the Storage Service#

Discovery publishes only services that opt in. Annotate the Storage Service so Discovery picks it up. The Storage Service must expose a gRPC port, identified here with the grpc-port annotation, and a REST port named rest or http.

# opt the storage service in to discovery
microk8s kubectl annotate service storage-service -n storage-apis-dev \
  discovery.omniverse.nvidia.com/enabled=true \
  discovery.omniverse.nvidia.com/grpc-port=50051

Discovery picks up the change on its next reconcile, within about 30 seconds.

Validate the Discovery Service is working#

Use port-forwarding to test the Discovery Service.

# set up port forwarding
microk8s kubectl port-forward -n storage-apis-dev service/auto-discovery-service 8080:8080

# test the discovery service
curl http://localhost:8080/api/v2beta/services

You should see a JSON response with "schema-version": 2 listing the services in the deployment. If services is empty, confirm the Storage Service carries the discovery.omniverse.nvidia.com/enabled annotation and wait for the next reconcile.

Cleanup#

To clean up: uninstall the Helm release and delete the namespace.

# uninstall the discovery service
microk8s helm uninstall auto-discovery-service -n storage-apis-dev

# delete the namespace
microk8s kubectl delete namespace storage-apis-dev

# validate the namespace was deleted
microk8s kubectl get namespace storage-apis-dev

Next Steps#

Next: create a Kubernetes deployment that uses the Discovery and Storage services together.