Book Image

Hands-on Kubernetes on Azure, Third Edition - Third Edition

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

Hands-on Kubernetes on Azure, Third Edition - Third Edition

By: Nills Franssens, Shivakumar Gopalakrishnan, Gunther Lenz

Overview of this book

Containers and Kubernetes containers facilitate cloud deployments and application development by enabling efficient versioning with improved security and portability. With updated chapters on role-based access control, pod identity, storing secrets, and network security in AKS, this third edition begins by introducing you to containers, Kubernetes, and Azure Kubernetes Service (AKS), and guides you through deploying an AKS cluster in different ways. You will then delve into the specifics of Kubernetes 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 applications and clusters. As you advance, you'll learn how to overcome common challenges in AKS and secure your applications with HTTPS. You will also learn how to secure your clusters and applications in a dedicated section on security. In the final section, you’ll learn about advanced integrations, which give you the ability to create Azure databases and run serverless functions on AKS as well as the ability to integrate AKS with a continuous integration and continuous delivery (CI/CD) pipeline using GitHub Actions. By the end of this Kubernetes book, you will be proficient in deploying containerized workloads on Microsoft Azure with minimal management overhead.
Table of Contents (22 chapters)
1
Foreword
Free Chapter
2
Section 1: The Basics
5
Section 2: Deploying on AKS
11
Section 3: Securing your AKS cluster and workloads
16
Section 4: Integrating with Azure managed services
21
Index

Creating secrets in Kubernetes

In Kubernetes, there are three different ways to create secrets: from files, from YAML or JSON definitions, or directly from the command line. Let's start the exploration of how to create secrets by creating them from files.

Creating Secrets from files

The first way to create secrets in Kubernetes is to create them from a file. In this way, the contents of the file will become the value of the secret, and the filename will be the identifier of each value within the secret.

Let's say that you need to store a URL and a secure token for accessing an API. To achieve this, follow these steps:

  1. Store the URL in secreturl.txt, as follows:
    echo https://my-url-location.topsecret.com \
      > secreturl.txt
  2. Store the token in another file, as follows:
    echo 'superSecretToken' > secrettoken.txt
  3. Let Kubernetes create the secret from the files, as follows:
    kubectl create secret generic myapi-url-token ...