DevOps Classroomnotes 10/Sep/2023

Controllers

  • Pod tries to keep containers running, but for us we need to keep Pods running according to some state, Lets understand first two categories
    • Replicas:
      • Here we have two resources ReplicationController, ReplicaSet
      • Here our desired state (spec) will be
        • number of replicas
        • pod spec
        • label selector
      • These objects try maintain the desired
    • Jobs:
      • These will run the Pods which have finite execution time period
      • Here we have two resources
        • Job
        • CronJob

ReplicaSet

  • This Resource is responsible for maintaing the desired state of number of replicase of pod
    Preview
  • Refer Here for official docs

Activity:

  • Create a replica set with 3 replicas of jenkins/jenkins
  • Refer Here for the manifests
    Preview
  • Lets try set based selectors Refer Here for the changes
  • Exercise: Write a Replication controller for creating 3 httpd pods

Jobs and Cron Jobs

  • Refer Here for Offical jobs documentation and Refer Here for Official CronJob Documentation
  • Lets write a Cron Job which runs alpine pod with some script for every 5 mins
  • Refer Here for the changes
    Preview

Namespace

  • Namespace in k8s is a logical space or logical cluster in which resources will be created
  • Any resource which has a value of Namespace = true belongs in a namespace and with Namespace=false is shared across namespaces.
  • Refer Here for official docs

Service in K8s

  • Every Pod when created gives a unique ip address and Name
  • When Pods are scaled
  • Lets create a replicaset with 3 nginx pods with label app:nginx
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: nginx-rs
  labels:
    app: nginx
    purpose: svcdemo
spec:
  replicas: 3
  minReadySeconds: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginxc
          image: nginx:1.25
          ports:
            - containerPort: 80
              protocol: TCP
  • We need to access nginx with in cluster, but pod ips are not reliable, so as shown in the below image, lets create a k8s service resource which gives a consistent ip and name to access all the pods matching labels (equality based selection)
    Preview
  • service in k8s is of 4 types
    • Cluster IP: This gives an ipaddress or name which can be accessed with in cluster
    • None: TBD
    • External: TBD
    • LoadBalancer: TBD
  • Refer Here for the changeset
  • Lets create nginx rs and and service and view endpoints. As discussed in the class when pods get update the endpoints are reflected. Service will forward the requests to endpoints
  • We will try correcting the access issue and external access in the next session

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
Floating Social Media Icons by Acurax Wordpress Designers

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