In the previous chapter, we covered Kubernetes and why we need it and then discussed bootstrapping a Kubernetes cluster using MiniKube and KinD. We then looked at the Pod resource and discussed how to create and manage pods, how to troubleshoot them, and how to ensure your application’s reliability using probes, along with multi-container design patterns to appreciate why Kubernetes uses pods in the first place instead of containers. We also looked at Secrets and ConfigMaps.
Now, we will dive deep into the advanced aspects of Kubernetes and Kubernetes command-line best practices.
In this chapter, we’re going to cover the following main topics:
- The need for advanced Kubernetes resources
- Kubernetes Deployments
- Kubernetes Services and Ingresses
- Horizontal pod autoscaling
- Managing stateful applications
- Kubernetes command-line best practices, tips, and tricks
So, let’s dive in!
Technical requirements
For this chapter, we will spin up a cloud-based Kubernetes cluster, Google Kubernetes Engine (GKE), for the exercises. That is because you will not be able to spin up load balancers and PersistentVolumes within your local system, and therefore, we cannot use KinD and MiniKube in this chapter.
Currently, Google Cloud Platform (GCP) provides a free $300 trial for 90 days, so you can go ahead and sign up for one at https://cloud.google.com/free.
Spinning up GKE
Once you’ve signed up and logged in to your console, you can open the Google Cloud Shell CLI to run the commands.
You need to enable the GKE API first using the following command:
$ gcloud services enable container.googleapis.com
To create a three-node GKE cluster, run the following command:
$ gcloud container clusters create cluster-1 –zone us-central1-a
And that’s it! The cluster is up and running.
You will also need to clone the following GitHub repository for some exercises: https://github.
com/PacktPublishing/Modern-DevOps-Practices-2e.
Run the following command to clone the repository into your home directory and cd into the ch6 directory to access the required resources:
$ git clone https://github.com/PacktPublishing/Modern-DevOps-Practices-2e.git \ modern-devops
$ cd modern-devops/ch6
Now, let’s understand why we need advanced Kubernetes resources.