Getting Started with App Deployment

    You need:

    • A Kubernetes cluster with Knative installed.
    • An image of the app that you’d like to deploy available on a container registry. The image of the sample app used in this guide is available on Google Container Registry.

    This guide demonstrates the basic workflow for deploying the from the Google Container Registry. You can use these steps as a guide for deploying your own container images from other registries like .

    To deploy a local container image, you need to disable image tag resolution by running the following command:

    Learn more about image tag resolution.

    The Hello World sample app reads in an variable, TARGET, from the configuration .yaml file, then prints “Hello World: ${TARGET}!”. If TARGET isn’t defined, it will print “NOT SPECIFIED”.

    To deploy an app using Knative, you need a configuration .yaml file that defines a Service. For more information about the Service object, see the .

    This configuration file specifies metadata about the application, points to the hosted image of the app for deployment, and allows the deployment to be configured. For more information about what configuration options are available, see the Serving spec documentation.

    1. apiVersion: serving.knative.dev/v1 # Current version of Knative
    2. metadata:
    3. name: helloworld-go # The name of the app
    4. spec:
    5. template:
    6. spec:
    7. containers:
    8. - image: gcr.io/knative-samples/helloworld-go # The URL to the image of the app
    9. env:
    10. value: "Go Sample v1"

    If you want to deploy the sample app, leave the config file as-is. If you’re deploying an image of your own app, update the name of the app and the URL of the image accordingly.

    From the directory where the new service.yaml file was created, apply the configuration:

    Now that your service is created, Knative will perform the following steps:

    • Create a new immutable revision for this version of the app.
    • Perform network programming to create a route, ingress, service, and load balancer for your app.
    • Automatically scale your pods up and down based on traffic, including to zero active pods.

    To see if your app has been deployed successfully, you need the URL created by Knative.

    1. To find the URL for your service, enter:

      The command will return the following:

    2. Now you can make a request to your app and see the results. Replace the URL with the one returned by the command in the previous step.

      1. # curl http://helloworld-go.default.34.83.80.117.xip.io
      2. Hello World: Go Sample v1!

      If you deployed your own app, you might want to customize this cURL request to interact with your application.

      It can take a few seconds for Knative to scale up your application and return a response.

      Note: Add -v option to get more detail if the curl command failed.

    You’ve successfully deployed your first application using Knative!

    To remove the sample app from your cluster, delete the service record:

    Alternatively, delete the service by name: