Skip to content

Installing Knative Serving using YAML files

This topic describes how to install Knative Serving by applying YAML files. This installation requires the following prerequisites:

  • The CLI Tools are installed.
  • Sufficient hardware:

One node requires at least 6 CPUs, 6 GB of memory, and 30 GB of disk storage.

Multiple nodes require 2 CPUs, 4 GB of memory, and 20 GB of disk storage.

  • The existing Kubernetes is running a supported version.

For information on other Knative installs, see the Installation Roadmap.

Install the Knative Serving component

To install the Knative Serving component:

  1. Install the required custom resources by running the command:

    kubectl apply -f https://storage.googleapis.com/knative-nightly/serving/latest/serving-crds.yaml
    
  2. Install the core components of Knative Serving by running the command:

    kubectl apply -f https://storage.googleapis.com/knative-nightly/serving/latest/serving-core.yaml
    

    Info

    For information about the YAML files in Knative Serving, see Knative Serving installation files.

Install a networking layer

Expand the following tabs for instructions on installing network layers. For an overview of network layer options, architecture, and configurations see the ingress providers on the Configure Knative Networking page.

Use the following steps to install Kourier and set it as the ingress controller.

  1. Install the Knative Kourier controller:

        kubectl apply -f https://storage.googleapis.com/knative-nightly/net-kourier/latest/kourier.yaml
    
  2. 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"}}'
    
  3. Get the external IP address (FQDN) to later configure DNS:

    kubectl --namespace kourier-system get service kourier
    

Use the following steps to install and enable Contour and set it as the ingress controller.

  1. Install the Knative Contour configuration:

    kubectl apply -f https://storage.googleapis.com/knative-nightly/net-contour/latest/contour.yaml
    
  2. Install the Knative Contour integration controller:

    kubectl apply -f https://storage.googleapis.com/knative-nightly/net-contour/latest/net-contour.yaml
    
  3. Configure Knative Serving to use Contour:

        kubectl patch configmap/config-network \
        --namespace knative-serving \
        --type merge \
        --patch '{"data":{"ingress-class":"contour.ingress.networking.knative.dev"}}'
    
  4. Get the external IP address (FQDN) to later configure DNS:

    kubectl --namespace contour-external get service envoy
    

Use the following steps to install Istio and set it as the ingress controller.

  1. Install a properly configured Istio:

    kubectl apply -l knative.dev/crd-install=true -f https://storage.googleapis.com/knative-nightly/net-istio/latest/istio.yaml
    kubectl apply -f https://storage.googleapis.com/knative-nightly/net-istio/latest/istio.yaml
    
  2. Install the Knative Istio controller:

    kubectl apply -f https://storage.googleapis.com/knative-nightly/net-istio/latest/net-istio.yaml
    
  3. Configure the config-network ConfigMap to use Istio:

        kubectl patch configmap/config-network \
        --namespace knative-serving \
        --type merge \
        --patch '{"data":{"ingress-class":"istio.ingress.networking.knative.dev"}}'
    
  4. Get the external IP address (FQDN) to later configure DNS:

    kubectl --namespace istio-system get service istio-ingressgateway
    

This component is in beta. For the latest information including supported implementations, see the Knative net-gateway-api.

Use the following steps to install and configure the Knative Gateway API controller. Note that you need to have a Gateway API implementation installed in your cluster. The Knative team currently tests the Istio, Contour, and Envoy-Gateway implementations of Gateway API.

  1. Install the Knative Gateway API:

    kubectl apply -f https://storage.googleapis.com/knative-nightly/net-gateway-api/latest/net-gateway-api.yaml
    
  2. Configure Gateway resources for external ("north-south") and local ("east-west") Knative traffic. If you do not need separate routing for local traffic (or private Knative services), you can use the external Gateway for both.

    Knative verifies traffic settings according to the Kubernetes namespace, the name of the Gateways, and an underlying DNS name such as a Kubernetes service DNS name that corresponds to the Gateway.

    cat <<EOF | kubectl apply -f -
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: config-gateway
      namespace: knative-serving
    data:
      external-gateways: |
        - name: knative-ingress-gateway  # Name of the external Gateway resource
          namespace: knative-serving     # Namespace where the Gateway is deployed
          service: knative-ingress-service.knative-serving.svc.cluster.local  # backing Service FQDN
      local-gateways: |
        - name: knative-local-gateway    # Name of the local Gateway resource
          namespace: knative-serving     # Namespace where the Gateway is deployed
          service: knative-local-service.knative-serving.svc.cluster.local    # backing Service FQDN
    EOF
    
  3. Configure Knative Serving to use the Knative Gateway API ingress class:

    kubectl patch configmap/config-network \
      --namespace knative-serving \
      --type merge \
      --patch '{"data":{"ingress-class":"gateway-api.ingress.networking.knative.dev"}}'
    
  4. Verify the config-gateway ConfigMap:

    kubectl describe configmaps config-gateway -n knative-serving
    

    Examine the values for the externals-gateways and local-gateways keys.

  5. Get the external IP address (FQDN) to configure DNS records:

    kubectl get gateway --all-namespaces
    

    Look for the external Gateway (knative-ingress-gateway) to get status and address for DNS configurations.

Verify the installation

Success

Monitor the Knative components until all of the components show a STATUS of Running or Completed. You can do this by running the following command and inspecting the output:

kubectl get pods -n knative-serving

Example output:

NAME                                      READY   STATUS    RESTARTS   AGE
3scale-kourier-control-54cc54cc58-mmdgq   1/1     Running   0          81s
activator-67656dcbbb-8mftq                1/1     Running   0          97s
autoscaler-df6856b64-5h4lc                1/1     Running   0          97s
controller-788796f49d-4x6pm               1/1     Running   0          97s
webhook-859796bc7-8n5g2                   1/1     Running   0          96s

Configure DNS

You can configure DNS to avoid specifying the host header in curl commands, or to access the content with a web browser.

The following tabs show instructions for configuring DNS. Follow the procedure for the DNS of your choice.

Knative provides a Kubernetes Job called default-domain that configures Knative Serving to use sslip.io as the default DNS suffix.

kubectl apply -f https://storage.googleapis.com/knative-nightly/serving/latest/serving-default-domain.yaml

This configuration works only if the cluster LoadBalancer Service exposes an IPv4 address or hostname. It does not work with IPv6 clusters or local setups such as minikube unless the minikube tunnel is running.

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. In the following example, knative.example.com is the domain suffix for a cluster.

    *.knative.example.com == A 35.233.41.212
    
  • If the networking layer produced a CNAME, then configure a CNAME record for the domain. In the following example, knative.example.com is the domain suffix for a cluster.

    *.knative.example.com == CNAME a317a278525d111e89f272a164fd35fb-1510370581.eu-central-1.elb.amazonaws.com
    
  • After 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 (sslip.io)" or "Real DNS" methods, you can evaluate Knative without altering your DNS configuration. You might have this need if minikube locally or IPv6 clusters.

To access your application using curl using this method:

  1. Configure Knative to use a domain reachable from outside the cluster:
kubectl patch configmap/config-domain \
      --namespace knative-serving \
      --type merge \
      --patch '{"data":{"example.com":""}}'
  1. 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
  1. Instruct curl to connect to the External IP or CNAME defined by the networking layer mentioned in section 3, 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 be http://192.168.39.228:32198 and you wish to access the helloworld-go application mentioned earlier, 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, using the default configuration, the output is:

    Hello Go Sample v1!
    

    Refer to the "Real DNS" method for a permanent solution.

Install optional Serving extensions

The following tabs expand to show instructions for installing each Serving extension.

Knative also supports the use of the Kubernetes Horizontal Pod Autoscaler (HPA) for driving autoscaling decisions.

  • Install the components needed to support HPA-class autoscaling by running the command:

    kubectl apply -f https://storage.googleapis.com/knative-nightly/serving/latest/serving-hpa.yaml
    

Knative supports encryption features through cert-manager. Follow the documentation in Serving encryption for more information.

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