DevOps Classroomnotes 02/Dec/2022

Writing K8s Manifests

  • The only workload which we know is Pod.
  • Pod has container(s)
  • Refer Here for kubernetes api reference
  • K8s 1.25 api reference Refer Here
  • Since we are working with Pod Refer Here
  • Api Version: <group>/<version>
  • Kind: Ensure you follow casing
  • Activity 1 : Let me write a simple pod with one nginx container
---
apiVersion: v1
kind: Pod
metadata:
  name: hello-pod
spec:
  containers:
    - image: nginx:1.23
      name: nginx-container
      ports:
        - containerPort: 80
  • Activity 2: Lets write a simple pod spec/manifest to run jenkins as well as nginx containers in one pod
---
apiVersion: v1
kind: Pod
metadata:
  name: second-pod
spec:
  containers:
    - image: nginx:1.23
      name: nginx
      ports: 
        - containerPort: 80
          protocol: TCP
    - image: jenkins/jenkins:lts-jdk11
      name: jenkins
      ports:
        - containerPort: 8080
          protocol: TCP
  • Activity 3: Write a k8s pod manifest to run one container with alpine with cmd sleep 1d (docker container run -d alpine sleep 1d)
---
apiVersion: v1
kind: Pod
metadata:
  name: activity3
spec:
  containers:
    - image: alpine
      command:
        - sleep
      args:
        - 1d

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner