Installing Knative Serving using YAML files
This topic describes how to install Knative Serving by applying YAML files using the kubectl
CLI.
Prerequisites
Before installation, you must meet the prerequisites. See Knative Prerequisites.
Install the Serving component
To install the serving component:
Install the required custom resources:
kubectl apply -f https://github.com/knative/serving/releases/download/v0.22.0/serving-crds.yaml
Install the core components of Knative Serving:
kubectl apply -f https://github.com/knative/serving/releases/download/v0.22.0/serving-core.yaml
For information about the YAML files in the Knative Serving and Eventing releases, see Installation files.
Install a networking layer
The tabs below expand to show instructions for installing a networking layer. Follow the procedure for the networking layer of your choice:
The following commands install Ambassador and enable its Knative integration.
Create a namespace to install Ambassador in:
kubectl create namespace ambassador
Install Ambassador:
kubectl apply --namespace ambassador \
-f https://getambassador.io/yaml/ambassador/ambassador-crds.yaml \
-f https://getambassador.io/yaml/ambassador/ambassador-rbac.yaml \
-f https://getambassador.io/yaml/ambassador/ambassador-service.yaml
Give Ambassador the required permissions:
kubectl patch clusterrolebinding ambassador -p '{"subjects":[{"kind": "ServiceAccount", "name": "ambassador", "namespace": "ambassador"}]}'
Enable Knative support in Ambassador:
kubectl set env --namespace ambassador deployments/ambassador AMBASSADOR_KNATIVE_SUPPORT=true
To configure Knative Serving to use Ambassador by default:
kubectl patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress.class":"ambassador.ingress.networking.knative.dev"}}'
Fetch the External IP or CNAME:
kubectl --namespace ambassador get service ambassador
Save this for configuring DNS below.
The following commands install Contour and enable its Knative integration.
Install a properly configured Contour:
kubectl apply -f https://github.com/knative/net-contour/releases/download/v0.22.0/contour.yaml
Install the Knative Contour controller:
kubectl apply -f https://github.com/knative/net-contour/releases/download/v0.22.0/net-contour.yaml
To configure Knative Serving to use Contour by default:
kubectl patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress.class":"contour.ingress.networking.knative.dev"}}'
Fetch the External IP or CNAME:
kubectl --namespace contour-external get service envoy
Save this for configuring DNS below.
For a detailed guide on Gloo integration, see Installing Gloo for Knative in the Gloo documentation.
The following commands install Gloo and enable its Knative integration.
Make sure
glooctl
is installed (version 1.3.x and higher recommended):glooctl version
If it is not installed, you can install the latest version using:
curl -sL https://run.solo.io/gloo/install | sh
export PATH=$HOME/.gloo/bin:$PATH
Or following the Gloo CLI install instructions.
Install Gloo and the Knative integration:
glooctl install knative --install-knative=false
Fetch the External IP or CNAME:
glooctl proxy url --name knative-external-proxy
Save this for configuring DNS below.
The following commands install Istio and enable its Knative integration.
Install a properly configured Istio (Advanced installation)
kubectl apply -f https://github.com/knative/net-istio/releases/download/v0.22.0/istio.yaml
Install the Knative Istio controller:
kubectl apply -f https://github.com/knative/net-istio/releases/download/v0.22.0/net-istio.yaml
Fetch the External IP or CNAME:
kubectl --namespace istio-system get service istio-ingressgateway
Save this for configuring DNS below.
The following commands install Kong and enable its Knative integration.
Install Kong Ingress Controller:
kubectl apply -f https://raw.githubusercontent.com/Kong/kubernetes-ingress-controller/0.9.x/deploy/single/all-in-one-dbless.yaml
To configure Knative Serving to use Kong by default:
kubectl patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress.class":"kong"}}'
Fetch the External IP or CNAME:
kubectl --namespace kong get service kong-proxy
Save this for configuring DNS below.
The following commands install Kourier and enable its Knative integration.
Install the Knative Kourier controller:
kubectl apply -f https://github.com/knative/net-kourier/releases/download/v0.22.0/kourier.yaml
To configure Knative Serving to use Kourier by default:
kubectl patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}'
Fetch the External IP or CNAME:
kubectl --namespace kourier-system get service kourier
Save this for configuring DNS below.
Verify the installation
Monitor the Knative components until all of the components show a STATUS
of Running
or Completed
:
kubectl get pods --namespace knative-serving
Configure DNS
You can configure DNS to prevent the need to run curl commands with a host header.
The tabs below expand to show instructions for configuring DNS. Follow the procedure for the DNS of your choice:
We ship a simple Kubernetes Job called “default domain” that will (see caveats) configure Knative Serving to use xip.io as the default DNS suffix.
kubectl apply -f https://github.com/knative/serving/releases/download/v0.22.0/serving-default-domain.yaml
Caveat: This will only work if the cluster LoadBalancer service exposes an IPv4 address or hostname, so it will not work with IPv6 clusters or local setups like Minikube. For these, see “Real DNS” or “Temporary DNS”.
To configure DNS for Knative, take the External IP or CNAME from setting up networking, and configure it with your DNS provider as follows:
If the networking layer produced an External IP address, then configure a wildcard
A
record for the domain:# Here knative.example.com is the domain suffix for your cluster
*.knative.example.com == A 35.233.41.212
If the networking layer produced a CNAME, then configure a CNAME record for the domain:
# Here knative.example.com is the domain suffix for your cluster
*.knative.example.com == CNAME a317a278525d111e89f272a164fd35fb-1510370581.eu-central-1.elb.amazonaws.com
Once your DNS provider has been configured, direct Knative to use that domain:
# Replace knative.example.com with your domain suffix
kubectl patch configmap/config-domain \
--namespace knative-serving \
--type merge \
--patch '{"data":{"knative.example.com":""}}'
If you are using curl
to access the sample applications, or your own Knative app, and are unable to use the “Magic DNS (xip.io)” or “Real DNS” methods, there is a temporary approach. This is useful for those who wish to evaluate Knative without altering their DNS configuration, as per the “Real DNS” method, or cannot use the “Magic DNS” method due to using, for example, minikube locally or IPv6 clusters.
To access your application using curl
using this method:
After starting your application, get the URL of your application:
kubectl get ksvc
The output should be similar to:
NAME URL LATESTCREATED LATESTREADY READY REASON
helloworld-go http://helloworld-go.default.example.com helloworld-go-vqjlf helloworld-go-vqjlf True
Instruct
curl
to connect to the External IP or CNAME defined by the networking layer in section 3 above, and use the-H "Host:"
command-line option to specify the Knative application’s host name. For example, if the networking layer defines your External IP and port to behttp://192.168.39.228:32198
and you wish to access the abovehelloworld-go
application, use:curl -H "Host: helloworld-go.default.example.com" http://192.168.39.228:32198
In the case of the provided
helloworld-go
sample application, the output should, using the default configuration, be:Hello Go Sample v1!
Refer to the “Real DNS” method for a permanent solution.
Next steps
After installing Knative Serving:
To add optional enhancements to your installation, see Installing optional extensions.
To easily interact with Knative services, install the
kn
CLI.