DevOps Classroom notes 12/Feb/2025

Primary Workload of K8s = Pod

  • Pod is an atomic unit of k8s which contains Containers
  • Pod will have containers
  • In k8s every resource which we create needs a name

Writing Pod Manifests

  • Most of the k8s manifests have 4 sections (apiVersion, kind, metadata, spec) which will represent resource and desired state and there will a 5 section (status) which represents status (generated)
  • Navigate to Apireference
  • Lets create an nginx pod i.e. pod with nginx container in it
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
spec:
  containers:
    - name: nginx
      image: nginx:latest

Preview

  • Lets create an pod i.e. pod with httpd container in it
apiVersion: v1
kind: Pod
metadata:
  name: httpd-pod
spec:
  containers:
    - name: httpd
      image: httpd:latest
  • Now lets look at some useful kubectl commands
# Watch
kubectl get pods -w
# get more info
kubectl get pods -o wide
# describe resource
kubectl describe pod nginx-pod
# Get the the output in yaml format
kubectl get pod nginx-pod -o yaml
  • I want to run the following containers give me docker commands
    • alpine container with runs for 1 day docker run -d --name alptest alpine sleep 1d
    • mysql with root password, user , password and database docker run -d --name mysqltest -e MYSQL_ROOT_PASSWORD=test123 mysql:9
  • Manifest for alpine
---
apiVersion: v1
kind: Pod
metadata:
  name: alptest-pod
spec:
  containers:
    - name: alptest
      image: alpine
      args:
        - sleep
        - 1d
  • Manifest for mysql
apiVersion: v1
kind: Pod
metadata:
  name: mysql-test
spec:
  containers:
    - name: mysql
      image: mysql:9
      env:
        - name: MYSQL_ROOT_PASSWORD
          value: admin123
        - name: MYSQL_USER
          value: ltdevops
        - name: MYSQL_PASSWORD
          value: ltdevops
        - name: MYSQL_DATABASE
          value: ltapps
  • Running commands in the container belonging to a Pod
kubectl exec <pod-name> -- <command>
kubectl exec -it <pod-name> -- <shell>

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