The Time for Serverless Is Now!
Total Page:16
File Type:pdf, Size:1020Kb
The time for serverless is now! Serverless Architecture Whitepaper Up in the Cloud: Step by step towards serverless applications, platforms and a cloud-native ecosystem @ServerlessCon # SLA_con www.serverless-architecture.io Content Serverless Development First things first 3 Your first step towards serverless application development Quarkus: Modernizing Java to keep pace in a cloud-native world 7 Scaling the modern app world Serverless Architecture & Design Why platform as a service is such a great model 9 Looking into the future of PaaS The time for serverless is now – tips for getting started 11 If not now, when? Building a data platform on Google Cloud Platform 13 Laying the groundwork for big data Migrating big data workloads to Azure HDInsight – Smoothing the path to the cloud with a plan 17 Strategies for big data migration Serverless Engineering & Operations Cloud-Native DevOps 20 The driving force behind the digital transformation of modern enterprises Serverless Security 25 Basic considerations on the subject of serverless architecture security www.serverless-architecture.io @ServerlessCon # SLA_con 2 WHITEPAPER Serverless Development Your first step towards serverless application development First things first In this article, Kamesh Sampath shows us how to master the first steps on the journey towards a serverless application. He shows how to set up the right environment and takes us through its deployment. by Kamesh Sampath RAM, 6 CPUs and 50 GB hard disk space. The boot command also contains a few additional configurations In the first part of this article, we will deal with setting for the Kubernetes cluster that are necessary to get Kna- up a development environment that is suitable for Kna- tive up and running. It is also important that the used tive in version 0.6.0. The second part deals with the Kubernetes version is not older than version 1.12.0, deployment of your first serverless microservice. The otherwise Knative will not work. If Minikube doesn’t basic requirement for using Knative to create serverless start immediately, it’s completely normal; it can take a applications is a solid knowledge of Kubernetes. If you few minutes until the initial startup is complete, so you are still inexperienced, you should complete the official should be a little patient when setting it up. basic Kubernetes tutorial [1]. Before we get down to the proverbial “can do”, a few Setting up an Istio Ingress Gateway tools and utilities have to be installed: Knative requires an Ingress Gateway to route requests to Knative Services. In addition to Istio [6], Gloo [7] is also • Minikube [2] supported as an Ingress Gateway. For our example, we • kubectl [3] will use Istio, though. The following steps show how to • kubens [4] perform a lightweight installation of Istio that contains only the Ingress Gateway: For Windows users, WSL [5] has proven to be quite use- ful, so I recommend installing that as well. curl -L https://raw.githubusercontent.com/knative/serving/release-0.6/ third_party/istio-1.1.3/istio-lean.yaml \ Setting up Minikube | sed ‘s/LoadBalancer/NodePort/’ \ Minikube is a single node Kubernetes cluster that is ide- | kubectl apply --filename – al for everyday development with Kubernetes. After the setup, the following steps must be performed to make Like the setup of Minikube, the deployment of the Istio Minikube ready for deployment with Knative Serving. Pod takes a few minutes. With the command kubectl Listing 1 shows what this looks like in the code. —namespace istio-system get pods –watch you can see First, a Minikube profile must be created, which is the status; the overview is finished with Ctrl + C. Whe- what the first line achieves. The second command is then ther the deployment was successful or not can be easi- used to set up a Minikube instance that contains 8 GB ly determined with the command kubectl –namespace www.serverless-architecture.io @ServerlessCon # SLA_con 3 WHITEPAPER Serverless Development istio-system get pods. If everything went well, the output Create the deployment and service should look like Listing 2. By applying the previously created YAML file, we can create the deployment and service. This is done using Installing Knative Serving the kubectl apply –filename app.yaml command. Also, The installation of Knative Serving [8] allows us to run at this point, the command kubectl get pods –watch serverless workloads on Kubernetes. It also provides au- can be used to get information about the status of the tomatic scaling and tracking of revisions. You can ins- application, while CTRL + C terminates the whole tall Knative Serving with the following commands: thing. If all went well, we should now have a deploy- ment called greeter and a service called greeter-svc (Lis- kubectl apply --selector knative.dev/crd-install=true \ ting 5). --filename https://github.com/knative/serving/releases/download/v0.6.0/ To activate a service, you can also use a Minikube serving.yaml shortcut like minikube service greeter-svc, which opens the service URL in your browser. If you prefer to use kubectl apply --filename https://github.com/knative/serving/releases/ curl to open the same URL, you have to use the com- download/v0.6.0/serving.yaml --selector networking.knative.dev/certificate- mand curl $(minikube service greeter-svc –url). Now provider!=cert-manager you should see a text that looks something like this: Hi greeter => ‘9861675f8845’ : 1 Again, it will probably take a few minutes until the Knati- ve Pods are deployed; with the command kubectl –name- Migrating the traditional Kubernetes space knative-serving get pods –watch you can check the deployment to serverless with Knative status. As before, the check can be aborted with Ctrl + C. The migration starts by simply copying the app.yaml With the command kubectl –namespace knative-serving file, naming it serverless-app-yaml and updating it to the get pods you can check if everything is running. If this is lines shown in Listing 6. the case, an output like in Listing 3 should be displayed. If we compare the traditional Kubernetes application (app.yaml) with the serverless application (serverless- Deploy demo application The application we want to create for demonst- ration is a simple greeting machine that outputs Listing1 “Hi”. For this we use an existing Linux container image, which can be found on the Quay website [9]. minikube profile knative The first step is to create a traditional Kubernetes de- ployment that can then be modified to use serverless minikube start -p knative --memory=8192 --cpus=6 \ functionality. This will make clear where the actual dif- --kubernetes-version=v1.12.0 \ ferences lie and how to make existing deployments using --disk-size=50g \ Knative serverless. --extra-config=apiserver.enable-admission-plugins=”LimitRanger,Namesp aceExists,NamespaceLifecycle,ResourceQuota,ServiceAccount,DefaultStora Create a Kubernetes resource file geClass,MutatingAdmissionWebhook” The following steps show how to create a Kubernetes resource file. To do this, you must first create a new file called app.yaml, into which the code in Listing 4 must be copied. Listing 2 NAME READY STATUS RESTARTS AGE cluster-local-gateway-7989595989-9ng8l 1/1 Running 0 Session: From Monolith to Serverless: 2m14s Rethinking your Architecture istio-ingressgateway-6877d77579-fw97q 2/2 Running 0 2m14s Michael Dowden istio-pilot-5499866859-vtkb8 1/1 Running 0 2m14s It’s easy to understand the benefits of serverless but it’s not always easy to un- derstand how this will impact our software architecture. In this talk we will deconst- Listing 3 ruct a set of requirements and walk through the architecture of both a traditional service-oriented NAME READY STATUS RESTARTS AGE architecture and a modern serverless architecture. activator-54f7c49d5f-trr82 1/1 Running 0 27m You’ll leave with a better understanding of how to autoscaler-5bcd65c848-2cpv8 1/1 Running 0 27m design event-driven systems and serverless APIs, controller-c795f6fb-r7bmz 1/1 Running 0 27m along with some alternatives to the traditional networking-istio-888848b88-bkxqr 1/1 Running 0 27m RESTful API layer. webhook-796c5dd94f-phkxw 1/1 Running 0 27m www.serverless-architecture.io @ServerlessCon # SLA_con 4 WHITEPAPER Serverless Development Listing 4 --- - name: greeter path: /healthz apiVersion: apps/v1 image: quay.io/rhdevelopers/knative- port: 8080 kind: Deployment tutorial-greeter:quarkus --- metadata: resources: apiVersion: v1 name: greeter limits: kind: Service spec: memory: “32Mi” metadata: selector: cpu: “100m” name: greeter-svc matchLabels: ports: spec: app: greeter - containerPort: 8080 selector: template: livenessProbe: app: greeter metadata: httpGet: type: NodePort labels: path: /healthz ports: app: greeter port: 8080 - port: 8080 spec: readinessProbe: targetPort: 8080 containers: httpGet: Listing 5 Listing 7 $ kubectl get deployments $ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE greeter 1 1 1 1 16s greeter 1 1 1 1 30m greeter-bn8cm-deployment 1 1 1 1 59s $ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE greeter-svc NodePort 10.110.164.179 8080:31633/TCP 50s Listing 8 $ kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE Listing 6 greeter ExternalName istio-ingressgateway.istio- --- system.svc.cluster.local 114s apiVersion: serving.knative.dev/v1alpha1 greeter-bn8cm ClusterIP 10.110.208.72 kind: Service 80/TCP 2m21s metadata: greeter-bn8cm-metrics ClusterIP 10.100.237.125 name: greeter 9090/TCP 2m21s spec: greeter-bn8cm-priv ClusterIP 10.107.104.53 template: 80/TCP 2m21s metadata: labels: app: greeter spec: containers: Listing 9 - image: quay.io/rhdevelopers/knative-tutorial-greeter:quarkus resources: kubectl get services.serving.knative.dev limits: NAME URL LATESTCREATED LATESTREADY memory: “32Mi” READY REASON cpu: “100m” greeter http://greeter.default.example.com greeter-bn8cm greeter- ports: bn8cm True - containerPort: 8080 livenessProbe: Attention httpGet: In a Minikube deployment we will have neither LoadBalancer nor DNS to path: /healthz resolve anything to *.example.com or a service URL like http://greeter.