Installing Knative on Amazon Web Services EKS

Sebastien Goasguen

Sebastien Goasguen

Apr 10, 2019
Installing Knative on Amazon Web Services EKS
Installing Knative on Amazon Web Services EKS

Knative is a Kubernetes API extension which provides a set of API objects that Cloud providers can use to build serverless solutions. Since Knative runs on top of Kubernetes, it can be installed on any Kubernetes clusters. The current documentation does not explain how to do it on Amazon Web Services EKS service yet, so let’s do it in this post.

We will do two things:

  • Create an EKS cluster.
  • Deploy Knative in that cluster.

> The initial version of this post is available on the AWS Open Source blog where we show how to combine our Knative Lambda Runtimes with AWS EKS.

Create an Amazon EKS Cluster

The official EKS getting started guide is very complete. It guides you through configuring your CLI, and creating the Cloud Formation stacks necessary to provision your Kubernetes cluster. However there is a great CLI that can be used which simplifies some of the steps shown in the startup guide. That CLI is called eksctl, it was developed by folks at Weaveworks, the website has the entire documentation. Let’s use eksctl to create our EKS cluster.

Install eksctl CLI

You can install eksctl on your local machine. For instance, if you are using OSX and brew do:

brew tap weaveworks/tap
brew install weaveworks/tap/eksctl

Once the install is finished you can verify that eksctl is now in your $PATH:

which eksctl
/usr/local/bin/eksctl

You are now ready to use this CLI to create an EKS cluster quickly.

Create an EKS cluster

You can use the CLI and some of the optional arguments. However, a very declarative way to do it is to define your cluster options in a manifest and “apply” this manifest in a very Kubernetes like manner.

Let’s use this method and declare a cluster called knative, which will run in us-east-1 zone and contain 3 nodes of the instance type m5.large. The following command will create such manifest and save it in a file named cluster.yaml

cat <<EOF >>cluster.yaml
apiVersion: eksctl.io/v1alpha4
kind: ClusterConfig

metadata:
name: knative
region: us-east-1

nodeGroups:
- name: knodes
instanceType: m5.large
desiredCapacity: 3
EOF

To launch the provisioning do:

eksctl create cluster --kubeconfig eksknative.yaml -f cluster.yaml

The above command will create a CloudFormation stack and take care of provisioning the security group, subnet and VPC that are described in the official getting started guide. The provisioning of the Kubernetes control plane and the nodes will take approximately 10 to 15 minutes.

Since we ran eksctl with the --kubeconfig option. The credentials used to access our Kubernetes cluster are stored in the file eksknative.yaml in the directory where we ran the command from. This has the advantage of keeping our main kubeconfig file clean, but it has the disadvantage that we now need to specify this file on every kubectl command.

For convenience, let’s just set up an alias that will specify our configuration file when we use kubectl:

alias knative='kubectl --kubeconfig=eksknative.yaml'

To verify that access to your cluster is working properly issue the following commands which should list the three nodes in your cluster:

knative get nodes

With a working EKS cluster on hand, we are now ready to install Knative in it.

Install Knative in your EKS cluster

Installing Knative can be done in a few kubectl apply commands. A default Knative installation will use the Istio service mesh.

Install Istio

To install Istio use the following two commands, note the use of our alias to kubectl --kubeconfig=eksknative.yaml which uses the proper cluster configuration file

knative apply --filename https://github.com/knative/serving/releases/download/v0.5.0/istio-crds.yaml && \
knative apply --filename https://github.com/knative/serving/releases/download/v0.5.0/istio.yaml

Install Knative Serving and Knative Build

Once this completes you can move on to installing the Knative components: Build and Serving. In this post, we will skip the installation of the Eventing component since we are not making use of it here.

knative apply --filename https://github.com/knative/serving/releases/download/v0.5.0/serving.yaml \
--filename https://github.com/knative/build/releases/download/v0.5.0/build.yaml \
--filename https://github.com/knative/serving/releases/download/v0.5.0/monitoring.yaml \
--filename https://raw.githubusercontent.com/knative/serving/v0.5.0/third_party/config/build/clusterrole.yaml

> If the installation above fails, apply the manifest again. The declarative aspect of Kubernetes will make sure that all the objects get created.

After a few minutes you should be able to list the Pods in the several namespaces that the previous commands have created, namely:

  • istio-system for the Istio components and the Ingress gateway that will receive Internet traffic
  • knative-serving for the Serving controller and autoscale
  • knative-build for the Build controller
knative get pods -n knative-serving
NAME                         READY STATUS  RESTARTS AGE
activator-6f7d494f55-57r9k   2/2   Running 1        2m
autoscaler-5cb4d56d69-mj4lm  2/2   Running 1        2m
controller-6d65444c78-tlpmm  1/1   Running 0        2m
webhook-55f88654fb-ppczx     1/1   Running 0        2m
knative get pods -n knative-build
NAME                              READY STATUS  RESTARTS AGE
build-controller-68dfb74954-5d68l 1/1   Running 0        2m
build-webhook-866fd64885-95sq4    1/1   Running 0        2m

Once all the Pods are in running state, congratulations you have installed Knative on your EKS cluster.

Using Knative

You can now start studying the Knative examples, like the basic Hello World example.

Create your first event flow in under 5 minutes