Knative is a popular Kubernetes-based platform for managing serverless workloads. At KubeCon EU, a number of the Knative team demonstrated the integration of the Ambassador API gateway with Knative, replacing Istio and potentially reducing the operational overhead of running the framework. This blog post provides instructions for you to recreate this demo.

The demo was based on a POC by Ben Browning at Red Hat.

In this post, we’ll walk through how you can use Ambassador with Knative.

Prerequisites

Knative requires a Kubernetes cluster v1.11 or newer with the MutatingAdmissionWebhook admission controller enabled. kubectl v1.10 is also required. This guide assumes that you’ve already created a Kubernetes cluster which you’re comfortable installing alpha software on.

This guide assumes you are using bash in a Mac or Linux environment; some commands will need to be adjusted for use in a Windows environment.

Install Knative Serving

All of the resources for the latest version of Knative serving are published on GitHub:

By default, Knative uses Istio of all ingress traffic. After applying the above manifests, edit the config-network ConfigMap to use Ambassador:

kubectl patch configmap -n knative-serving config-network -p '{"data": {"clusteringress.class": "ambassador.ingress.networking.knative.dev"}}`

Install Ambassador

Install the latest version of Ambassador. Ambassador will need to be installed in the ambassador Namespace .



kubectl apply -n ambassador -f

kubectl apply -n ambassador -f kubectl create namespace ambassadorkubectl apply -n ambassador -f https://getambassador.io/yaml/ambassador/ambassador-rbac.yaml kubectl apply -n ambassador -f https://getambassador.io/yaml/ambassador/ambassador-service.yaml

Ambassador needs a way to consume Knative resources for configuration. For this we need to install the knative-ambassador-ingress .

Deploying an app in Knative

Now that you have Knative Serving installed in your cluster, let’s quickly get a demo application up and running. For this, we will use a hello-world application written in Go.

We will expose this application by creating a service.serving.knative.dev object:

cat << EOF | kubectl apply -f -

apiVersion: serving.knative.dev/v1alpha1

kind: Service

metadata:

name: helloworld-go

namespace: default

spec:

template:

spec:

containers:

— image: gcr.io/knative-samples/helloworld-go

env:

— name: TARGET

value: “Go Sample v1”

EOF

Wait for the helloworld-go Knative service to become Ready:

kubectl get ksvc helloworld-go -n default

Send a request to the sample application. Knative will assign a hostname to the service and ambassador will be configured to route based off this hostname. You will need to add this hostname to curl to the IP address of the Ambassador service.

First, get the Ambassador service IP address:

AMBASSADOR_IP=$(kubectl get svc -n ambassador ambassador -o jsonpath=’{.status.loadBalancer.ingress[0].ip}’)

Then, get the hostname of the helloworld-go Knative service:

kubectl get ksvc -n default helloworld-go -o jsonpath=’{.status.domain}’

Finally, send a curl using the values from above:

curl -H “Host: {{HELLOWORLD_HOSTNAME}}” {{AMBASSADOR_IP}}

That’s it! The Ambassador team is working with the Knative team, and we’re looking forward to further integrating Knative with Ambassador in the near future. Stay tuned!