Getting to Production

This guide assumes you have deployed an application to the dev zone as detailed in getting started.

Prerequisites:

  • Vespa CLI or openssl
  • JDK 17, or higher
  • mvn 3.6, or higher

To get to production without custom Java code, see getting to production.

1. Understand prod deployments

While applications in the dev zone are deployed manually by a developer, deployments to prod zones should happen automatically on source changes. This is done by creating a build job in your preferred continuous build tool that builds the application and submits it to Vespa Cloud for production roll-out. See GitHub Actions example.

To make this safe, the application needs tests that validate it. These tests are executed automatically on each deployment. See automated deployments for more details.

2. Add tests to your application

The album recommendation Java sample application, used in getting started with Java, already contains some sample tests. Now it is time to review the Java testing reference, and update the tests in src/test/java to match your src/main/java.

Ensure you have set tenant, application and instance consistently with Vespa CLI and in pom.xml (instance will be specified as an argument to mvn test), as per the getting started guide. Then it is easy to build and deploy your application, and run tests against that deployment

$ mvn package && \
  vespa deploy --wait 600
$ mvn test -D test.categories=system -D instance=my-instance

3. Add a deployment descriptor to your application

The Vespa CLI can be used to initialize your application for deployment to production:

$ vespa prod init

To do it by hand, create a deployment.xml file in src/main/application containing

<deployment version="1.0">
    <prod>
        <region active="true">aws-us-east-1c</region>
    </prod>
</deployment>

4. Build and submit the application revision

Now you are ready to build and submit the application revision:

  1. Find a Vespa version to compile your custom Java code against, which is compatible with your current (and later) runtime in production:

    $ mvn vespa:compileVersion -DapiKeyFile=$HOME/Downloads/TENANTNAME.pem
    

    The API key is either the key generated in the getting-started guide with Vespa CLI, or one generated in the Vespa Cloud console. Prefer an application API key for CI jobs, as these have fewer privileges—see security model for details.

  2. Compile and build the application package and test bundle:

    $ mvn package -Dvespa.compile.version="$(cat target/vespa.compile.version)"
    
  3. Submit the application package to Vespa Cloud for deployment:

    $ mvn vespa:submit -DapiKeyFile=$HOME/Downloads/TENANTNAME.pem
    

The application revision is now being tested and (if successful) deployed to the production zones in deployment.xml.

Track deployment progress and view logs in the console.

With good tests, it is always safe to submit a new revision of your application. You should now configure a continuous build job in your preferred build service to run these three commands whenever a change to your application source is checked in and merged.

Next steps

The Vespa Cloud application is now running in a production zone. Congratulations! After this you can further enhance the production application:

  1. To have redundancy for business continuity, consider setting up multiple production zones in deployment.xml, and use a global endpoint for queries.

  2. To create more tests to protect your production deployments, see developing tests.

  3. Don't forget to set up a continuous build to initiate automatic deployment of changes to your application by running the three commands above. See an example using GitHub actions.

Removing a production instance

Follow the guide at deleting an application or deleting an instance / region to remove instances or applications from production.