Serverless Media Function on Amazon EKS

Jonas Rydholm Birmé, Streaming Video Specialist, Eyevinn Technology

What is Amazon EKS?

Kubernetes is an open-source system for automated orchestration of deployments, scaling and management of containers running on a cluster of servers. Instead of running and managing the Kubernetes system yourself, Amazon EKS provides the Kubernetes control plane across multiple zones to ensure high availability and automatically replaces unhealthy control plane instances. To simplify a bit, Kubernetes ensures high-availability and scaling of containerized applications and Amazon EKS ensures high-availability and scaling of the Kubernetes system itself. In addition it utilizes some other services from AWS such as the Elastic Load Balancing for load distribution and Amazon ECR for container images. In this example we will use Docker Hub as this media function image is available to the public.

Creating Cluster and Control Plane

We will create a cluster for our media functions and for the sake of this demonstration it is a small cluster of 2 nodes of t3.micro instances. In practice for these type of functions we might want more performant instances and perhaps even GPU instances.

eksctl create cluster --name mediafunctions --version 1.14 --region eu-north-1 --nodegroup-name standard-workers --node-type t3.micro --nodes 2 --nodes-min 1 --nodes-max 3 –managed
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 53m

Deploying the Media Function

To deploy the media function we use the same configuration that we created in the previous article with a slight modification.

apiVersion: apps/v1
kind: Deployment
metadata:
name: function-probe-deployment
labels:
app: function-probe
spec:
replicas: 2
strategy:
rollingUpdate:
maxUnavailable: 50%
selector:
matchLabels:
app: function-probe
template:
metadata:
labels:
app: function-probe
spec:
containers:
- name: function-probe
image: eyevinntechnology/function-probe:0.1.1
ports:
- containerPort: 8080
protocol: TCP
$ kubectl apply -f deployment.yaml
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
function-probe-deployment-5694694c6d-cmkbk 1/1 Running 0 48m
function-probe-deployment-5694694c6d-s6lwd 1/1 Running 0 48m

Creating the Service

Now that we have the containers up and running we need to make it available by creating a service. We will define a Service using a load balancer to manage the load and availability with the following configuration:

apiVersion: v1
kind: Service
metadata:
name: media-function-probe
spec:
type: LoadBalancer
selector:
app: function-probe
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: http
$ kubectl apply -f service.yaml
$ kubectl get svc media-function-probe
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
media-function-probe LoadBalancer 10.100.196.112 adcd05e822edf11ea9cc70e90f0aadc6-1657283786.eu-north-1.elb.amazonaws.com 80:32230/TCP 53m

Creating an API Gateway for our Services

The default domain name for the load balancer is not that convenient to use and we could simply create a DNS alias for it. However, as we intend to add more media functions we might want to group them under one domain. For example have all functions under the domain functions.eyevinn.technology and each service as path. We want this media function probe that we have created to be accessed from http://functions.eyevinn.technology/probe/api.

$ curl -X POST "https://pm9mspzd7c.execute-api.eu-north-1.amazonaws.com/prod/probe/api" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"medialocator\":\"https://testcontent.eyevinn.technology/stswe19/Fraunhofer_updated_v2.mp4\"}"
curl -X POST "https://functions.eyevinn.technology/probe/api" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"medialocator\":\"https://testcontent.eyevinn.technology/stswe19/Fraunhofer_updated_v2.mp4\"}"

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eyevinn Technology

Eyevinn Technology

We are consultants sharing the passion for the technology for a media consumer of the future.