This article outlines how to run Vespa using Kubernetes. Find a quickstart for running Vespa in a single pod in singlenode quickstart with minikube.
Setting up a multi-pod Vespa cluster is a bit more complicated, and requires knowledge about how Vespa configures its services. Use the multinode-HA sample application as a basis for configuration.
$ kubectl get pods NAME READY STATUS RESTARTS AGE vespa-configserver-0 1/1 Running 0 2m45s vespa-configserver-1 1/1 Running 0 107s vespa-configserver-2 1/1 Running 0 62s
The list above is an overview of the config server -> application package -> service /state/v1/health dependency chain. This sequence of steps must be considered when building the Kubernetes cluster configuration.
A good next step is running the multinode-HA for Kubernetes - there you will also find useful troubleshooting tools.
This section 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" or $ podman info | grep "memTotal"
$ 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:
runAsUser: 1000
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
$ vespa deploy ${VESPA_SAMPLE_APPS}/album-recommendation
This normally takes a minute or so:
$ curl -s --head http://localhost:8080/state/v1/health
$ vespa feed sample-apps/album-recommendation/ext/documents.jsonl
Make a query:
$ vespa query 'select * from music where true'
$ vespa document get id:mynamespace:music::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
At any point during the procedure, dump logs for troubleshooting:
$ kubectl logs vespa-0