DevOps Classroomnotes 29/Apr/2023

Kubernetes as a Service (Managed K8s)

  • Every Cloud provider offers k8s as a service
    • Azure = AKS
    • AWS = EKS
    • GCP = GKE
  • K8s as a service basically means the master nodes will be managed by cloud provider
    • Typical k8s cluster
      Preview
    • K8s as a Service
      Preview
  • Advantages:

    • less administration
    • nodes can be scaled
    • inbuilt support for cloud integrations
  • In this course we will be using

    • AKS
    • EKS

Setting up basic k8s cluster in Azure (AKS)

  • In this setups we configure kubectl on
    • dev systems
    • build servers
      Preview
  • install kubectl Refer Here or we can use azure cli to set it up
  • Install azure cli: Refer Here
  • Execute az login
  • Refer Here for azure aks
  • Create a resource group and continue according to docs Refer Here

Exposing Applications running in cluster to externally as well as internally when scaled

  • Every pod gets a unique ip and name.
  • Connecting from one pod to other on the basis of name/ip might not be a good idea as pods are controlled by replicasets or other controllers
  • K8s has a service which helps us in connecting to pods with similar behaviour but by using labels.
  • Each service gets a ip address and this is virtual ip which helps in forwarding traffic to one of the pod based on labels. This ip is called as cluster ip
  • Services can be exposed to external world
    Preview
  • Service is similar to layer 4 load balancer
  • Refer Here for official docs

Internal Communication using k8s service

  • Consider the following
    • We have an alpine pod which needs to consume nginx
    • but nginx is a replica set and there can be n replicas
  • Lets create a nginx-rs
    Preview
    Preview
  • Create an alpine pod and login into that
    Preview
  • ping nginx-svc by its ip address and try accessing the web page using curl
    Preview
  • access nginx-svc by using name
    Preview
  • now do nslookup based on name
    Preview
  • Look into environment variables in alpine pod (Alpine was created post nginx service creation)
    Preview
  • Look into environment variables in nginx pods (These were created prior to nginx service)
    Preview
  • Refer Here for internal communication manifests

External Communication using k8s service

  • Some user external to k8s cluster wants to access nginx
    Preview
  • Kubernetes has the service publishing types Refer Here
    • Cluster ip: internal communication
    • Node Port: k8s will expose the application on a port on every node in k8s cluster.
      Preview
    • LoadBalancer: This is generally used with managed k8s clusters
      Preview
    • ExternalName: Creates a CNAME record that can be used in your DNS Servers
  • We have created a manifest with loadBalancer
    Preview
  • Refer Here for the spec

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Wordpress Development Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube