Creating Knative services

    Knative Service Revisions are each backed by a deployment with 2 Kubernetes Services.
    For more information about Kubernetes Services, see the Kubernetes documentation.

    To create a Knative Service, you will need:

    • A Kubernetes cluster with .

    This guide uses the Hello World sample app in Go to demonstrate the structure of a Service YAML file and the basic workflow for deploying an app. These steps can be adapted for your own application if you have an image of it available on Docker Hub, Google Container Registry, or another container image registry.

    The Hello World sample app does the following:

    1. Reads an environment variable, , from the configuration .yaml file
    2. Prints Hello World: \${TARGET}!. If TARGET is not defined, it will print NOT SPECIFIED.
    1. Create a new file named service.yaml containing the following information.
    • apiVersion: The current Knative version.
    • (metadata): The name of the application.
    • namespace: The namespace that the application will use.
    • name(env): The environment variable printed out by the sample application.
    1. From the directory where the new service.yaml file was created, deploy the application by applying the service.yaml file.

    Now that your app has been deployed, 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.

    Any changes to specifications, metadata labels, or metadata annotations for a Service must be copied to the Route and Configuration owned by that Service. The serving.knative.dev/service label on the Route and Configuration must also be set to the name of the Service. Any additional labels or annotations on the Route and Configuration not specified above must be removed.

    • For more information about getting started with deploying a Knative application, see the documentation.