DevOps Classroomnotes 04/Dec/2022

Replication Controller

  • Replication Controller is the first gen replica workload for k8s objects.
  • Replication Controller labels can be matched only on equality not set based Refer Here

Replica Set

  • This is succesor to Replication Controller.
  • Replica Sets are used by Deployments.
  • Replica Sets changes can be tracked and that is what the deployment uses.
  • Refer Here for the official docs
  • Lets create a replicaset with 4 nginx Pods. Refer Here for the changes
  • k8s replica set will always try to maintain the desired count. Of the desired is not matching with actual state, a new Pods can be created or existing pods can be deleted to maintain the desired state
  • Scaling number of replicas

    • imperative way:
    • declartive way: Change the spec and apply the spec again.
  • Exercise: Create a replica set with Pod specification with jenkins Pod and ping -c 4 in alpine as init container with restart policy Never.
  • Refer Here for the changeset
  • top commands using kubectl (Need to fix metrics server)
    • metrics server needs to be added to k8s cluster Refer Here
  • kubernetes UI: Refer Here (Need to work with tokens and proxy)
  • Terms to understand

    • addons
    • users
    • service account
    • cluster role binding
  • Next Steps

    • Limits to containers
    • Expose applications to outside world
    • Kubernetes as a service (AKS, EKS)
    • Deployments & Other workloads
    • deal with storage
    • Authentication and Authorizations
  • Getting inside Containers
kubectl exec -it <pod-name> -- <shell /bin/bash /bin/sh>
kubectl exec <pod-name> -- <linux command>

Kubernetes Service

  • Refer Here for official docs
  • Overview
  • Lets use the replica set with 4 nginx replicas and create a cluster ip service which creates an internal ip accesssible within k8s cluster Refer Here
  • Create and verify replica set with pods
  • This svc can be verified only by some Pod in k8s cluster. Lets create an experiment pod. Refer Here for the changes
  • Check for accessing nginx svc using ip
  • We are able to access the nginx using svc ip with in cluster
  • Now verify with service name inside cluster and it will be working
  • K8s can expose the service to the external world
    • nodePort: Expose the service to the particular port on all the nodes of k8s cluster
    • loadBalancer: Exposes the service to the loadbalancer
    • external: Creates a DNS record which can be added to DNS servers maintaine by your org.
  • Expose the above service to the nodes. Refer Here for the changes
  • Lets solve this error by changing node port Refer Here

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner