DevOps Classroomnotes 13/Feb/2022

Exercise 1: Create a Pod Manifest to run alpine with sleep 1d

  • Refer Here for the changes made
    Preview
  • Now lets look at describing out kubectl describe <resource-name> <object-name>
    Preview

Using Port forwarding

  • Lets launch the pod from activity1
    Preview

Getting More Information With Logs

Preview

Activity 3: Create a Pod with container which has CMD to get container to exited state

  • Refer Here for the changes
  • As the container gets into the exited state pod tries to restart the container and this happens continuously
  • To deal with these kind of continuous restarts we will be learning probes.

Activity 4: Start activity 1

  • create a pod with spec activity1.yaml
  • Now shutdown the node where activity1 is running. (Simulating some error on the node)
    Preview
  • Node is shutdown, Pod is not accesible, but k8s is not scheduling this pod to run on other node
    Preview

Workload Resources

  • Kubernetes Provides different workload resources
  • Replicaset:
    • This is used to create multiple replications of your Pod which is running your application
  • Deployment
  • Statefulset
  • DaemonSet
  • Job and CronJob
  • If we try to use the above workloads then the desired state is maintained
  • Since Pod cannot maintain its own state i.e. if the Pod is Down, schedule the Pod on a new node
    Preview
  • Running our application in the Workload resources which maintain some kind of desired state is what we want.
  • Before we understand workload resources, we need to understand the concept of labels and annotations in kubernetes

Labels

  • Labels are key/value pairs that can be attached to k8s objects such as Pods, replicasets etc.
  • They are arbitrary and are useful for identifying information about k8s objects
  • They provide the foundation for grouping objects
  • Labels have very simple syntax.
  • Keys can be broken down into two parts an optional prefix and a name seperated by slahs (dots, underscores, dashes(hypens)) can be used in names
  • Values are strings with maximum of 63 characters
  • Examples:

| key | value |
| — | ——|
| qt.com/app-version | 1.0.0 |
| appVersion | 1.0.0 |
| app.version | 1.0.0 |
| project | qtidentitiy |
* Lets try to apply labels
Preview
* Now lets get labels
Preview
* Label Selectors: These are used to filter k8s objects based on set of labels
Preview
Preview
* Lets create labels in the declarative approach. Refer Here for the Pod manifest
Preview
Preview
Preview
* Selectors in the Yaml will be in the format of

selector:
  app: web
  env: prod

Annotations

  • Annotations are also key value pairs like labels which provide a place to store additional metadata for k8s objects with the sole purpose of assisting tools and libraries
metadata:
  annotations:
    qt.com/icons-url: "https://qt.com/icon-main.png"

ReplicaSets

  • If we want multiple replicas of the application in Pod running and maintaing the state of number of replicas we use replica sets
    Preview

Activity 5: Lets create a replicaset to create 2 replicas of jenkins (Pod)

  • Refer Here for api reference
  • Refer Here for Replicaset Spec
  • Refer Here for the ReplicaSet Manifest created
    Preview
    Preview
  • Now delete one pod manually to see what replica set does
    Preview
    Preview

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 Responsive Web Designing 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