Having fun with Kubernetes - Chapter 3
Martin Pham
Posted on December 23, 2019
Okey, from previous chapter you had built your first Docker image – it’s everything you need to run the application everywhere: A PHP-FPM 7.4 installation, a codebase contains the PHP files. Let’s continue with the k8s chapter – where we’re gonna setup our first k8s to deliver our application to 1 million people!
Before getting your hands dirty, let’s talk a bit about our infrastructure – aka our k8s cluster
- We need to have a Master server to manage our k8s stuffs behind.
- We will use our 2 servers as 2 Nodes, to host our containers which run the application.
- Inside each node, we will make several Pods – the minions which contain our containers.
- Inside each Pod, we will run 2 containers: one is a nginx (from an official nginx image), one is php-fpm (from our application image we've created before). nginx serves incoming HTTP request, passes to PHP-FPM container, and returns response to client.
- To config nginx, we’re gonna use a ConfigMap, so our Pod can run with decoupled configurations.
- To deploy our Pods, we’re gonna use a Deployment to keep our deployment easily, ensures zero-downtime rolling out/rolling back.
- To balance the requests, we will use a LoadBalancer Service
- Finally, to allocate our Pods depends on traffic, we will use a HorizontalPodAutoscaler
In this way, our Deployment controller will creating & managing Pods, based on Rolling Update strategy and Horizonal Pod Autoscaler’s requirements.
Inside every Pod, an nginx container will take configuration from Config Map, handles incoming request, passes to the php-fpm container (in the same Pod).
And in front of all, a Load Balancer will take requests from client, and balances them to our minions.
In the next chapter, we're gonna setup our own k8s cluster. Don't miss it!
Posted on December 23, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.