Deploying Your First Service

Let’s deploy a simple Hello World service to verify that Knative is working correctly.

Creating a Simple Service

Create a file named service.yaml:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: hello
spec:
template:
spec:
containers:
- image: gcr.io/knative-samples/helloworld-go
env:
- name: TARGET
value: "Knative"

Deploy the service:

Terminal window
kubectl apply -f service.yaml

Verifying the Deployment

Check the service status:

Terminal window
kubectl get ksvc hello

You should see output similar to:

NAME URL READY REASON
hello http://hello.default.example.com True

Testing the Service

Get the service URL and test it:

Terminal window
export SERVICE_URL=$(kubectl get ksvc hello -o jsonpath='{.status.url}')
curl $SERVICE_URL

You should see: Hello Knative!

Congratulations! You’ve deployed your first Knative service.