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}!
.
knYAML
Deploy the Service by running the command:
kn service create hello \
--image gcr.io/knative-samples/helloworld-go \
--port 8080 \
--env TARGET=World
Expected output
Service hello created to latest revision 'hello-world' 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.
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: gcr.io/knative-samples/helloworld-go
ports:
- containerPort: 8080
env:
- name: TARGET
value: "World"
Deploy the Knative Service by running the command:
kubectl apply -f hello.yaml
Expected output
service.serving.knative.dev/hello created