diff --git a/ui/01-is.yaml b/ui/01-is.yaml new file mode 100644 index 0000000..103f796 --- /dev/null +++ b/ui/01-is.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: + name: playground +spec: + lookupPolicy: + local: false +--- +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: + name: python-312 +spec: + lookupPolicy: + local: false + tags: + - annotations: + from: + kind: DockerImage + name: registry.redhat.io/ubi8/python-312 + generation: 1 + importPolicy: + importMode: Legacy + name: latest + referencePolicy: + type: Source diff --git a/ui/02-bc.yaml b/ui/02-bc.yaml new file mode 100644 index 0000000..b0bac84 --- /dev/null +++ b/ui/02-bc.yaml @@ -0,0 +1,29 @@ +--- +apiVersion: build.openshift.io/v1 +kind: BuildConfig +metadata: + name: playground +spec: + failedBuildsHistoryLimit: 5 + nodeSelector: + output: + to: + kind: ImageStreamTag + name: playground:latest + postCommit: {} + resources: {} + runPolicy: Serial + source: + contextDir: llama_stack/distribution/ui + git: + ref: main + uri: https://github.com/meta-llama/llama-stack.git + type: Git + strategy: + sourceStrategy: + from: + kind: ImageStreamTag + name: python-312:1-40.1747189120 + namespace: llamastack + type: Source + successfulBuildsHistoryLimit: 5 diff --git a/ui/03-dc.yaml b/ui/03-dc.yaml new file mode 100644 index 0000000..0fb8af2 --- /dev/null +++ b/ui/03-dc.yaml @@ -0,0 +1,49 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: playground +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + deployment: playground + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + annotations: + openshift.io/generated-by: OpenShiftNewApp + creationTimestamp: + labels: + deployment: playground + spec: + containers: + - command: + - streamlit + - run + - app.py + - "--server.port=8501" + - "--server.address=0.0.0.0" + env: + - name: LLAMA_STACK_ENDPOINT + value: http://llama-test-milvus-service-llamastack.apps.rosa.akram.vsil.p3.openshiftapps.com + image: image-registry.openshift-image-registry.svc:5000/llamastack/playground@sha256:00a3008aa70832bc679513b21cacc4e2ae5e875ee648dfbd60264a8b2b42d65b + imagePullPolicy: IfNotPresent + name: playground + ports: + - containerPort: 8501 + protocol: TCP + resources: {} + terminationMessagePath: "/dev/termination-log" + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 diff --git a/ui/04-svc.yaml b/ui/04-svc.yaml new file mode 100644 index 0000000..137d3d6 --- /dev/null +++ b/ui/04-svc.yaml @@ -0,0 +1,19 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: playground +spec: + internalTrafficPolicy: Cluster + ipFamilies: + - IPv4 + ipFamilyPolicy: SingleStack + ports: + - name: http + port: 8501 + protocol: TCP + targetPort: 8501 + selector: + deployment: playground + sessionAffinity: None + type: ClusterIP diff --git a/ui/05-route.yaml b/ui/05-route.yaml new file mode 100644 index 0000000..2f1c0ec --- /dev/null +++ b/ui/05-route.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + name: playground +spec: + port: + targetPort: http + to: + kind: Service + name: playground + weight: 100 + wildcardPolicy: None diff --git a/ui/README.md b/ui/README.md new file mode 100644 index 0000000..4f3a428 --- /dev/null +++ b/ui/README.md @@ -0,0 +1,55 @@ +# Deploying llamastack playground ui on OpenShift + +## Clone llamastack + +``` +git clone https://github.com/meta-llama/llama-stack.git +cd llama_stack/distribution/ui +``` + +## Building image + +``` +oc import-image ubi8/python-312 --from=registry.redhat.io/ubi8/python-312 --confirm +oc new-app --name=playground . --image-stream="python-312" --context-dir=llama_stack/distribution/ui +``` + +## Configuring, patching and deploying +Set llamastack endpoint route +``` +LS_ROUTE=$(oc get route llamastack -ojsonpath={.spec.host}) +oc set env deployment/playground LLAMA_STACK_ENDPOINT=http://$LS_ROUTE +``` + +Change: +- entrypoint to `streamlit` as openshift python image will use app.py only instead. +- port to 8501 as python image uses 8080 instead + +``` +oc patch deployment playground -p '{"spec":{"template":{"spec":{"containers":[{"name":"playground","command":["streamlit","run","app.py","--server.port=8501","--server.address=0.0.0.0"],"ports":[{"containerPort":8501,"protocol":"TCP"}]}]}}}}' +oc patch svc playground -p '{"spec":{"ports":[{"port":8501,"targetPort":8501,"protocol":"TCP","name":"http"}]}}' +``` + +Expose `service` through a route and patch it +``` +oc expose svc playground +oc patch route playground -p '{"spec":{"port":{"targetPort":"http"}}}' +``` + + +## Getting manifests + +``` +oc eksporter is > 01-is.yaml +oc eksporter bc playground --drop spec.triggers > 02-bc.yaml +oc eksporter deployment playground > 03-dc.yaml +oc eksporter svc playground --drop spec.clusterIPs > 04-svc.yaml +oc eksporter route playground --drop spec.host > 05-route.yaml +``` + +## Installing everything using manifests + +``` +oc create -f . +``` + diff --git a/ui/export-manifests.sh b/ui/export-manifests.sh new file mode 100755 index 0000000..8b696b0 --- /dev/null +++ b/ui/export-manifests.sh @@ -0,0 +1,7 @@ +oc eksporter is > 01-is.yaml +oc eksporter bc playground --drop spec.triggers > 02-bc.yaml +oc eksporter deployment playground > 03-dc.yaml +oc eksporter svc playground --drop spec.clusterIPs > 04-svc.yaml +oc eksporter route playground --drop spec.host > 05-route.yaml + +