"helmsman" or "pilot" or "Orchestrator".
We use Kubernetes to achieve resiliency for our application.
Verb
Perform the act of doing Kubernetes. When done using TKG it is easy but can be super hard if the right tool is not used.
Do you even Kubernetes?
If I were to survey about how many people in IT industry (regardless of role) knows or at least heard about Kubernetes I would be very surprised if the percentage came out any less than at least 80%.
I am curious though,
- How many people have actually deployed on Kubernetes?
- How many people have created a Kubernetes cluster?
- How?
The answer could go either way of "Yeah, it's easy" OR "Dude!! it's hard".
This is because, in my opinion, it all depends on choosing the right toolset that are fit for purpose.
In this post I will create a Kubernetes cluster and deploy a microservice application End-To-End, the easy way (really, if you follow along you will have your own cluster provisioned and app running in just under 20 mins).
If you would like to jump straight into the codes then check out my GitHub repo containing all the codes I used to create the below:
- 2 Kubernetes cluster (1 for app, 1 for CICD tool Jenkins) in a fully private environment
- Provisioned private container registry
- Deploy 3 micro-services on the application cluster
- Deploy Jenkins on a separate cluster and deploying using automated CICD pipeline.
Github: https://github.com/alinahid477/VMW/tree/main/calcgithub
Before I start let me state 1 thing:
"There is no way I will ever (ever, ever, ever) create a Kubernetes cluster from scratch" (unless someone pays me a billion dollars).
Why:
- First of all, no one does it.
- Second, it's really not worth the effort.
- Third, I tried and failed to create from scratch and then discovered tools and services for managing Kubernetes. Trust me, you should too.
WHY should you Kubernetes?
- Consistent Environment: Regardless of whichever environment the containerised application are deployed to eg> DEV, UAT, PROD etc it runs and behaves the same way.
- Run anywhere: Does not matter whichever host OS eg> Windows, Linux etc OR whichever cloud eg> public or private cloud, a containerised application just works and runs, giving it much needed portability in todays world.
- Isolation: As containers virtualize resources at the OS level, a containerised application runs logically isolated from other applications. This leads to efficient usage of resources and significant reduction of running cost.
- High availability
- Fault tolerance
- Resiliency
- Streamlined and simplified operation
- Open source & Community: Kubernetes is open source and it is backed by a massive community and support and contribution from organization like Google, VMware.
- Extensibility: Kubernetes is very extensible. Hence, there are literally thousands of plugins available. On top you can build your own.
- Multi-cloud flexibility: Kubernetes makes it easy to run application on Hybrid and/or Multi-cloud. This allows to put the right workloads on the right cloud and to help avoid vendor lock-in.
- Future: With the adoption rate growing exponentially as companies embark on digital transformation journey and backed by data from IDC's research, it is safe to say that Kubernetes is here to stay.
Backstory to my usecase:
The problem:
Solution evaluation:
- Through Kubernetes it is possible to maintain a desired state and scale the app through pods and when needed VMs. This efficiently make use of allocated resources, thus cost effective.
- Through containerisation deployment process will become portable and installation of dependencies on VMs can be avoided. Thus operation will become smoother and simpler.
- Although, it does add some initial effort to modernize the application (eg> make it containerised) and setting up Kubernetes cluster but this is well justified effort by scoring the benefits it brings to the table.
WHAT to Kubernetes?
What is What in Kubernetes:
Choosing the right toolset:
- The most impressive thing is on vSphere 7 (when Tanzu is enabled) the Kubernetes is treated as first class citizen;
- Meaning I do NOT need to go through the hassle for creating VMs and adding Kubernetes on it. I would only need to tell TKG to create a cluster and it will provision the underlying VMs and Networking for me.
- More to it, impressively, the networking, compute and storage are provisioned adhering to policy setup by the IT Governance team.
- AND TKG comes as an embedded service in vSphere 7.
- Calculator interface (which is original application written in ReactJS but with 2 features decoupled.).
- Sum service (Decoupled sum functionality now written in Java Spring Boot)
- Substract service (Decoupled sum functionality now written in Java Spring Boot)
HOW to Kubernetes?
- Create Kubernetes cluster using TKG
- Deploy Jenkins on Kubernetes (there are some stuffs you may want to record).
- Deploy microservice application on Kubernetes.
Create Kubernetes cluster using TKG
Here's a sample yaml:
apiVersion: run.tanzu.vmware.com/v1alpha1 #TKG API endpoint
kind: TanzuKubernetesCluster #required parameter
metadata:
name: calc-k8-cluster #cluster name, user defined
namespace: calc #supervisor namespace
spec:
distribution:
version: v1.18 #resolved kubernetes version
topology:
controlPlane:
count: 1 #number of control plane nodes
class: best-effort-small #vmclass for control plane nodes
storageClass: pacific-gold-storage-policy #storageclass for control plane
workers:
count: 4 #number of worker nodes
class: best-effort-small #vmclass for worker nodes
storageClass: pacific-gold-storage-policy #storageclass for worker nodes
What I am doing here are:
- Creating a cluster name "calc-k8-cluster" in the vSphere Namespace called "calc"
- The cluster will be created using Kubernetes version 1.18
- 1 VM will be created and assigned/allocated by TKG for control plane node
- 4 VMs will will be created and assigned/allocated by TKG for worker nodes
- best-effort-small machine type will be used in both cases master and workers. See more details about machine types here: https://docs.vmware.com/en/VMware-vSphere/7.0/vmware-vsphere-with-tanzu/GUID-7351EEFF-4EF0-468F-A19B-6CEA40983D3D.html
Deploy Jenkins on Kubernetes:
Deploy microservice application on Kubernetes
- Give Jenkins (our CICD tool) permissions to deploy to our cluster (as Jenkins is running on a different cluster.) through the usage of K8's Service Account. (See Step#4)
- Integrating private container registry to kubernetes (so that kubernetes knows how to pull the images for the apps when spinning up pods). (See Step#5)
- POD template defined in the Jenkins file. Pay special attention to service account used, volumes mounted and harbor integration. (Explained Step#5, Section: "Configmap for private registry with self signed ssl")
How long did it take?
What's next:
- Use TKG to deploy to public cloud
- Use Tanzu Mission Control to bring all the k8 cluster into one single management place.
Why not use Tekton for CI/CD, which is more native to k8s and more importantly to save you a separate cluster for CI/CD. More specifically I would use Tekton automate my builds and ArgoCD to automate the deployment of manifests into Kubernetes.
ReplyDelete