We'll start the hands-on walk-through by cloning the vfarcic/k8s-specs repository that contains all the example definitions we'll use throughout the book.
Please run all the examples from GitBash (installed through Git). That way the commands you'll see throughout the book will be same as those executed on MacOS or any Linux distribution. If you're using Hyper-V instead of VirtualBox, you may need to run the GitBash window as an Administrator.
1 git clone \
2 https://github.com/vfarcic/k8s-specs.git
3
4 cd k8s-specs
Now that you have a repository with the examples we'll use throughout the book, we should create a cluster unless you already have one.
For this chapter, I'll assume that you are running a cluster with Kubernetes version 1.9 or higher. Further on, I'll assume that you already have an nginx Ingress Controller deployed, that RBAC is set up, and that your cluster has a default StorageClass. If you are unsure about some of the requirements, I prepared a few Gists with the commands I used to create different clusters. Feel free to choose whichever suits you the best, or be brave and roll with your own. Ideally, you'll run the commands from every chapter on each of the Kubernetes flavors. That way, you'll not only learn the main subject but also gain experience in running Kubernetes in different combinations and, hopefully, make a more informed decision which flavor to use for your local development as well as for production.
The Gists with the commands I used to create different variations of Kubernetes clusters are as follows.
- docker4mac.sh: Docker for Mac with 2 CPUs, 2 GB RAM, and with nginx Ingress controller (https://gist.github.com/vfarcic/06e313db2957e92b1df09fe39c249a14).
- minikube.sh: minikube with 2 CPUs, 2 GB RAM, and with ingress, storage-provisioner, and default-storageclass addons enabled (https://gist.github.com/vfarcic/536e6329e750b795a882900c09feb13b).
- kops.sh: kops in AWS with 3 t2.small masters and 2 t2.medium nodes spread in three availability zones, and with nginx Ingress controller(assumes that the prerequisites are set through Appendix B) (https://gist.github.com/vfarcic/2a3e4ee9cb86d4a5a65cd3e4397f48fd).
- minishift.sh: minishift with 2 CPUs, 2 GB RAM, and version 1.16+ (https://gist.github.com/vfarcic/c9968f23ecb1f7b2ec40c6bcc0e03e4f).
- gke.sh: Google Kubernetes Engine (GKE) with 3 n1-standard-1 (1 CPU, 3.75 GB RAM) nodes (one in each zone), and with nginx Ingress controller running on top of the "standard" one that comes with GKE. We'll use nginx Ingress for compatibility with other platforms. Feel free to modify the YAML files if you prefer NOT to install nginx Ingress (https://gist.github.com/vfarcic/5c52c165bf9c5002fedb61f8a5d6a6d1).
- eks.sh: Elastic Kubernetes Service (EKS) with 2 t2.medium nodes, with nginx Ingress controller, and with a default StorageClass (https://gist.github.com/vfarcic/5496f79a3886be794cc317c6f8dd7083).