This guide describes how to install and run Vespa on a single machine using Kubernetes, K8s. See Getting Started for troubleshooting, next steps and other guides. Also see Vespa example on GKE.
Prerequisites:
NO_SPACE
- the vespaengine/vespa container image + headroom for data requires disk space.
Read more.Refer to Docker memory for details and troubleshooting:
$ docker info | grep "Total Memory"
$ minikube start --driver docker --memory 4096
$ git clone --depth 1 https://github.com/vespa-engine/sample-apps.git $ export VESPA_SAMPLE_APPS=`pwd`/sample-apps
$ cat << EOF > service.yml apiVersion: v1 kind: Service metadata: name: vespa labels: app: vespa spec: selector: app: vespa type: NodePort ports: - name: container port: 8080 targetPort: 8080 protocol: TCP - name: config port: 19071 targetPort: 19071 protocol: TCP EOF
$ cat << EOF > statefulset.yml apiVersion: apps/v1 kind: StatefulSet metadata: name: vespa labels: app: vespa spec: replicas: 1 serviceName: vespa selector: matchLabels: app: vespa template: metadata: labels: app: vespa spec: containers: - name: vespa image: vespaengine/vespa imagePullPolicy: Always env: - name: VESPA_CONFIGSERVERS value: vespa-0.vespa.default.svc.cluster.local securityContext: privileged: true runAsUser: 0 ports: - containerPort: 8080 protocol: TCP readinessProbe: httpGet: path: /state/v1/health port: 19071 scheme: HTTP EOF
$ kubectl apply -f service.yml -f statefulset.yml
$ kubectl get pods --watch
NAME READY STATUS RESTARTS AGE vespa-0 0/1 ContainerCreating 0 8s vespa-0 0/1 Running 0 2m4s
$ kubectl port-forward vespa-0 19071 8080 &
$ curl -s --head http://localhost:19071/state/v1/health
$ (cd ${VESPA_SAMPLE_APPS}/album-recommendation && \ zip -r ../../application.zip .)
$ curl --header Content-Type:application/zip --data-binary @application.zip \ localhost:19071/application/v2/tenant/default/prepareandactivate
This normally takes a minute or so:
$ curl -s --head http://localhost:8080/state/v1/health
$ curl -s -H "Content-Type:application/json" \ --data-binary @${VESPA_SAMPLE_APPS}/album-recommendation/ext/A-Head-Full-of-Dreams.json \ http://localhost:8080/document/v1/mynamespace/music/docid/a-head-full-of-dreams $ curl -s -H "Content-Type:application/json" \ --data-binary @${VESPA_SAMPLE_APPS}/album-recommendation/ext/Love-Is-Here-To-Stay.json \ http://localhost:8080/document/v1/mynamespace/music/docid/love-is-here-to-stay $ curl -s -H "Content-Type:application/json" \ --data-binary @${VESPA_SAMPLE_APPS}/album-recommendation/ext/Hardwired...To-Self-Destruct.json \ http://localhost:8080/document/v1/mynamespace/music/docid/hardwired-to-self-destruct
Make a query:
$ curl -X POST -H "Content-Type: application/json" --data ' { "yql": "select * from sources * where true", "input.query(user_profile)": "{{cat:pop}:0.8,{cat:rock}:0.2,{cat:jazz}:0.1}" }' \ http://localhost:8080/search/
Read more in the Query API.
$ curl -s http://localhost:8080/document/v1/mynamespace/music/docid/love-is-here-to-stay
Clean up:
Stop the running container:
$ kubectl delete service,statefulsets vespa
Stop port forwarding:
$ killall kubectl
Stop minikube:
$ minikube stop