Skip to content

Deploying a Knative Service

In this tutorial, you will deploy a "Hello world" Knative Service that accepts the environment variable TARGET and prints Hello ${TARGET}!.

Deploy the Service by running the command:

kn service create hello \
--image ghcr.io/knative/helloworld-go:latest \
--port 8080 \
--env TARGET=World

Expected output

Service hello created to latest revision 'hello-0001' is available at URL:
http://hello.default.${LOADBALANCER_IP}.sslip.io
The value of ${LOADBALANCER_IP} above depends on your type of cluster, for kind it will be 127.0.0.1 for minikube depends on the local tunnel.

  1. Copy the following YAML into a file named hello.yaml:

    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: hello
    spec:
      template:
        spec:
          containers:
            - image: ghcr.io/knative/helloworld-go:latest
              ports:
                - containerPort: 8080
              env:
                - name: TARGET
                  value: "World"
    
  2. Deploy the Knative Service by running the command:

    kubectl apply -f hello.yaml
    

    Expected output

    service.serving.knative.dev/hello created
    

We use analytics and cookies to understand site traffic. Information about your use of our site is shared with Google for that purpose. Learn more.

× OK