Deploy to Vespa Cloud
This notebook deploys a Vespa.ai sample application to Vespa Cloud using pyvespa. The Vespa CLI is used for managing security credentials.
See pyvespa, and jupyter notebooks requirements to run this notebook.
Refer to the sample apps site for more applications.
Install pyvespa and the Vespa CLI
[ ]:
!pip install pyvespa
If homebrew is installed, install the Vespa CLI:
[ ]:
!brew install vespa-cli
Alternatively, when running in Colab, install the Vespa CLI:
[ ]:
import os
import requests
res = requests.get(url="https://api.github.com/repos/vespa-engine/vespa/releases/latest").json()
os.environ["VERSION"] = res["tag_name"].replace("v", "")
!curl -fsSL https://github.com/vespa-engine/vespa/releases/download/v${VERSION}/vespa-cli_${VERSION}_linux_amd64.tar.gz | tar -zxf -
!ln -sf /content/vespa-cli_${VERSION}_linux_amd64/bin/vespa /usr/local/bin/vespa
Create a Vespa Cloud tenant
Sign up and create a tenant: Run steps 1 and 2 in getting started, then replace the tenant name below:
[5]:
os.environ["TENANT_NAME"] = "tenant_name_here"
Set up security credentials
[ ]:
!vespa config set target cloud
!vespa config set application ${TENANT_NAME}.myapp.default
!vespa auth cert -N
!vespa auth api-key
Set API key location. The vespa
command stores the credentials in ~/.vespa, like:
/Users/me/.vespa/mytenant.api-key.pem
/Users/me/.vespa/mytenant.myapp.default/data-plane-public-cert.pem
/Users/me/.vespa/mytenant.myapp.default/data-plane-private-key.pem
Enter full path to the api key (like /Users/me/.vespa/mytenant.api-key.pem
):
[7]:
api_key_path = "path_here"
Create an application package
An application package is the application’s configuration, like schema. Here, using a basic question answering app from the app gallery.
[8]:
from vespa.gallery import QuestionAnswering
app = QuestionAnswering()
Create a VespaCloud instance
Refer to the VespaCloud reference.
[9]:
from vespa.deployment import VespaCloud
vespa_cloud = VespaCloud(
tenant=os.getenv("TENANT_NAME"),
application="myapp",
key_location=api_key_path,
application_package=app)
Deploy to Vespa Cloud
Refer to tenants, applications and instances for details - here creating an instance named default
:
[ ]:
app = vespa_cloud.deploy(instance="default")
That is it, you can now interact with your deployed application through the app
instance.