Tuesday 14 May 2024

Kubernetes on Cloud

This article extends my notes from an Udemy course "Kubernetes for the Absolute Beginners - Hands-on". All course content rights belong to course creators. 

Deploying a Kubernetes cluster in production in the cloud can be done in cloud environments that can be:
  • private
  • public 
In any environment we have two types of solutions:
  • self-hosted or turnkey solution
    • we provision the required VMs
    • we use some kind of tools or scripts to configure the Kubernetes cluster on them
    • we are responsible for maintaining those VMs, patching and upgrading them
    • provisioning the cluster itself and managing the lifecycle of the cluster are mostly made easy using certain tools and scripts
      • for example, deploying a Kubernetes cluster on AWS can be made easy using tools like kops, KubeOne or KubeAdmin
  • hosted or managed solutions
    • more like Kubernetes-as-a-Service solution
    • provider:
      • provisions VMs
      • installs Kubernetes
      • deploys the cluster. Kubernetes cluster is (in the context of the hosted solution) a managed group of VM instances for running containerized applications.
      • configures Kubernetes
      • maintains VMs
    • For example, the Google Kubernetes Engine (GKE, formerly known as Google Container Engine) lets us provision a Kubernetes cluster in a matter of minutes with just a few clicks without having to perform any kind of configuration by ourself.
    • In these environments, we most likely won't have access to the master nodes or VMs to perform any kind of configuration changes on them
    • The version of Kubernetes and the master nodes are all managed by the by the provider
    • Most popular solutions:
      • Google Kubernetes Engine (GKE)
      • Azure Kubernetes Service (AKS)
      • Amazon Elastic Kubernetes Service (EKS)
    • When provisioning and managing Kubernetes cluster here we can still reuse the deployment and service definition files that were mentioned in previous articles

Generic Process of deploying Microservices Application to Managed Cloud 

The following steps are the common steps in process of deploying a Microservices Application to GKE, AKS and EKS:

  • Create Kubernetes cluster
    • in Web Console, we can select:
      • cluster size - how many VMs we want to have
      • VM spec - number of cores, memory 
  • Connect to cluster via Terminal
    • Open a Cloud Shell Terminal or local Terminal
    • Configure kubectl access by running the cloud provider's CLI tool (gcloud, aws, az) which configure ~/.kube/config so kubectl command line tool (installed and available in cloud shell by default) talks to the right cluster
  •  Clone our repo with Microservices App Kubernetes project (a bunch of Kubernetes objects definition files)
  • For each Kubernetes object in the repo, execute kubectl create -f path/to/definition_file.yaml
  • Use kubectl commands for checking the state of created Kubernetes objects as usual

No comments: