Book Image

Effortless Cloud-Native App Development Using Skaffold

By : Ashish Choudhary
Book Image

Effortless Cloud-Native App Development Using Skaffold

By: Ashish Choudhary

Overview of this book

Kubernetes has become the de facto standard for container orchestration, drastically improving how we deploy and manage cloud-native apps. Although it has simplified the lives of support professionals, we cannot say the same for developers who need to be equipped with better tools to increase productivity. An automated workflow that solves a wide variety of problems that every developer faces can make all the difference! Enter Skaffold – a command-line tool that automates the build, push, and deploy steps for Kubernetes applications. This book is divided into three parts, starting with common challenges encountered by developers in building apps with Kubernetes. The second part covers Skaffold features, its architecture, supported container image builders, and more. In the last part, you'll focus on practical implementation, learning how to deploy Spring Boot apps to cloud platforms such as Google Cloud Platform (GCP) using Skaffold. You'll also create CI/CD pipelines for your cloud-native apps with Skaffold. Although the examples covered in this book are written in Java and Spring Boot, the techniques can be applied to apps built using other technologies too. By the end of this Skaffold book, you'll develop skills that will help accelerate your inner development loop and be able to build and deploy your apps to the Kubernetes cluster with Skaffold.
Table of Contents (15 chapters)
1
Section 1: The Kubernetes Nightmare – Skaffold to the Rescue
5
Section 2: Getting Started with Skaffold
9
Section 3: Building and Deploying Cloud-Native Spring Boot Applications with Skaffold

Checking out the container-native application development inner loop

Kubernetes and containers have introduced a new set of challenges and complexities to the inner development loop. Now there are an additional set of steps added to the inner loop while developing applications, which is time-consuming. A developer would prefer to spend time solving business problems rather than waiting for the build process to complete.

It involves steps such as the following:

  1. A developer making code changes in an IDE
  2. Building and packaging the application
  3. Creating a container image
  4. Pushing the image to a container registry
  5. Kubernetes pulling the image from the registry
  6. Kubernetes creating and deploying the pod
  7. Finally, testing and repeating

Engineers at Google call this an infinite loop of pain and suffering. Here is a visualization of the container-native application development inner loop:

Figure 1.9 – Container-native application development inner loop

Figure 1.9 – Container-native application development inner loop

As you can see, we now have three more steps added to the inner development loop, that is, creating a container image of your application, pushing it to a container registry, and finally, pulling the image while deploying to a container orchestration tool such as Kubernetes.

The container image could be a Docker or OCI format image, depending on the tool you use to build your images. You have options such as Docker Hub, AWS Container Registry, Google Container Registry, or Azure Container Registry for the container registry. Then, finally, in deployment, for your container orchestration, you have tools such as Kubernetes, which will first pull the image from the container registry and deploy your application.

There are many manual steps involved here. It also depends on what tools you have used for the local development workflow. For instance, you will use commands such as the following:

docker build 
docker tag
docker push 
kubectl apply

The following are the detailed steps that a developer has to go through while developing container-native applications:

  1. Defining how to configure the OS for your container with a Dockerfile
  2. Defining the packaging of your application into a container image by adding instructions to the Dockerfile
  3. Creating a container image with Docker commands such as docker build and docker tag
  4. Uploading the container image to a container registry with a command such as docker push
  5. Writing one or more Kubernetes resource files in YAML
  6. Deploying your application to the cluster with commands such as kubectl apply -f myapp.yaml
  7. Deploying services to the cluster with commands such as kubectl apply -f mysvc.yaml
  8. Writing the config so that apps can work together with commands such as kubectl create configmap
  9. Configuring apps to work together correctly with commands such as kubectl apply -f myappconfigmap.yaml

Wooh!!! That's a lot of steps and a time-consuming process. You can use scripting or docker compose to automate it to some extent, but soon you will realize that it cannot be fully automated without a tool such as Skaffold, which can abstract away many things related to building and deployment.

In Chapter 3, Skaffold – Easy-Peasy Cloud-Native Kubernetes Application Development, we will cover Skaffold, which simplifies the process we have covered here with a single command. My only intention here was to give you an idea of the steps involved. We will cover these steps with some hands-on examples in the next chapter.