Book Image

Hands-On Kubernetes on Azure - Second Edition

By : Nills Franssens, Shivakumar Gopalakrishnan, Gunther Lenz
Book Image

Hands-On Kubernetes on Azure - Second Edition

By: Nills Franssens, Shivakumar Gopalakrishnan, Gunther Lenz

Overview of this book

From managing versioning efficiently to improving security and portability, technologies such as Kubernetes and Docker have greatly helped cloud deployments and application development. Starting with an introduction to Docker, Kubernetes, and Azure Kubernetes Service (AKS), this book will guide you through deploying an AKS cluster in different ways. You’ll then explore the Azure portal by deploying a sample guestbook application on AKS and installing complex Kubernetes apps using Helm. With the help of real-world examples, you'll also get to grips with scaling your application and cluster. As you advance, you'll understand how to overcome common challenges in AKS and secure your application with HTTPS and Azure AD (Active Directory). Finally, you’ll explore serverless functions such as HTTP triggered Azure functions and queue triggered functions. By the end of this Kubernetes book, you’ll be well-versed with the fundamentals of Azure Kubernetes Service and be able to deploy containerized workloads on Microsoft Azure with minimal management overhead.
Table of Contents (16 chapters)
1
Section 1: The Basics
4
Section 2: Deploying on AKS
10
Section 3: Leveraging advanced Azure PaaS services
15
Index

Creating an HTTP-triggered Azure function

In this first example, we will create an HTTP-triggered Azure function. This means that you can browse to the page hosting the actual function:

  1. To begin, we will create a new directory and navigate to that directory:
    mkdir http
    cd http
  2. Now, we will initialize a function using the following command. The --docker parameter specifies that we will build our function as a Docker container. This will result in a Dockerfile being created for us. We will select the Python language, option 3 in the following screenshot:
    func init --docker

    This will create the required files for our function to work:

    After running the funcinit --docker command,four options are provided: dotnet, node, python, and powershell. We select option 3.
    Figure 11.7: Creating a Python function
  3. Next, we will create the actual function. Enter the following code and select the fifth option, HTTP trigger, and name the function python-http:
    func new

    This should result in an output like Figure 11.8:

    The output of the func new command returns nine options. We select the option 5: HTTP trigger.
    Figure 11.8: Creating an HTTP-triggered function
  4. The code of the function is stored in the directory...