Deploying your first Knative Service
In this tutorial, you will deploy a “Hello world” service.
This service will accept an environment variable,
TARGET, and print “
Since our “Hello world” Service is being deployed as a Knative Service, not a Kubernetes Service, it gets some super powers out of the box 🚀.
Knative Service: “Hello world!”
kn service create hello \
Service hello created to latest revision 'hello-world' is available at URL:
Why did I pass in
Note the name “world” which you passed in as “revision-name,” naming your Revisions will help you to more easily identify them, but don’t worry, you’ll learn more about Revisions later.
Once you’ve created your YAML file (named something like “hello.yaml”):
kubectl apply -f hello.yaml
To see the URL where your Knative Service is hosted, leverage the
kubectl get ksvc
NAME URL LATESTCREATED LATESTREADY READY REASON
kn service list
NAME URL LATEST AGE CONDITIONS READY REASON
Ping your Knative Service
Ping your Knative Service by opening
http://hello.default.127.0.0.1.nip.io in your browser of choice or by running the command:
Are you seeing
curl: (6) Could not resolve host:
In some cases your DNS server may be set up not to resolve
*.nip.io addresses. If you encounter this problem, it can be fixed by using a different nameserver to resolve these addresses.
The exact steps will differ according to your distribution. For example, with Ubuntu derived systems which use systemd-resolved, you can add the following entry to the
Then simply restart the service with
sudo service systemd-resolved restart.
For MacOS users, you can add the DNS and domain using the network settings as explained here - https://support.apple.com/en-gb/guide/mac-help/mh14127/mac.
Congratulations 🎉, you’ve just created your first Knative Service. Up next, Autoscaling!