Skip to content

Lecture 05 - 06/12/2025

Agenda

  • Kubernetes
    • Pod
    • Init Containers
    • Liveness & Readiness Probe
    • Configuration & Secrets Management
      • ConfigMap
      • Secret
    • ReplicaSets
    • Persistent Storage
    • Kubernetes Deployments
    • Kubernetes Services

Slides

  • Lecture slides can be found in Canvas.

Reading

Kubernetes

Lecture Notes

Amazon EKS

Generate Kubeconfig for EKS Cluster

$ aws eks update-kubeconfig --region $region-code --name $my-cluster

K8S Resources

Namespace

1
2
3
4
5
---
apiVersion: v1
kind: Namespace
metadata:
  name: csye7125

Pod

---
apiVersion: v1
kind: Pod
metadata:
  name: busybox
  namespace: default
spec:
  containers:
    - name: busybox
      image: busybox:latest
      command: ['sh', '-c', 'sleep 3600']
---
apiVersion: v1
kind: Pod
metadata:
  name: webapp
  namespace: csye7125
  labels:
    app: myapp
spec:
  containers:
    - image: tejasparikh/webapp:spring2020-v1
      name: webapp
      ports:
        - containerPort: 8080
          protocol: TCP

Deployments

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: csye7125-webapp-deployment
spec:
  replicas: 1
  progressDeadlineSeconds: 300
  minReadySeconds: 1
  strategy:
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
    type: RollingUpdate
  selector:
    matchLabels:
      app: csye7125-webapp-deployment
  template:
    metadata:
      labels:
        app: csye7125-webapp-deployment
    spec:
      containers:
      - image: tejasparikh/webapp:200
        name: webapp
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
          protocol: TCP
        readinessProbe:
          httpGet:
            path: /
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 10
        livenessProbe:
          httpGet:
            path: /
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 30

Service

---
apiVersion: v1
kind: Service
metadata:
  name: csye7125-webapp-deployment
spec:
  type: LoadBalancer
  selector:
    app: csye7125-webapp-deployment
  ports:
  - port: 80
    targetPort: 8080

ReplicaSet

---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: csye7125-webapp-replicaset
spec:
  replicas: 1
  selector:
    matchLabels:
      app: csye7125-webapp-replicaset
  template:
    metadata:
      labels:
        app: csye7125-webapp-replicaset
    spec:
      containers:
      - image: tejasparikh/webapp:200
        name: webapp
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
          protocol: TCP
        readinessProbe:
          httpGet:
            path: /
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 10
        livenessProbe:
          httpGet:
            path: /
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 30

EmptyDir Storage Volume

---
apiVersion: v1
kind: Pod
metadata:
  name: pod-emptydir
spec:
  containers:
  - image: tejasparikh/webapp:spring2020-v1
    name: webapp
    ports:
    - containerPort: 8080
      protocol: TCP
    volumeMounts:
    - mountPath: /cache
      name: emptydir-volume-memory
      readOnly: true
  volumes:
  - name: emptydir-volume-memory
    emptyDir:
      medium: Memory
  - name: emptydir-volume-disk
    emptyDir: {}
``` -->


<!-- #### Storage Classes

```yaml
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: aws-ebs-slow
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
  fsType: ext4

---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: aws-ebs-fast
provisioner: kubernetes.io/aws-ebs
parameters:
  type: io1
  fsType: ext4

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: 04-pod-storageclass-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: aws-ebs-slow
  resources:
    requests:
      storage: 1Gi

---
apiVersion: v1
kind: Pod
metadata:
  name: 04-pod-storageclass-pvc-pod
spec:
  containers:
  - image: tejasparikh/webapp:spring2020-v1
    name: webapp
    ports:
    - containerPort: 8080
      protocol: TCP
    readinessProbe:
      httpGet:
        path: /
        port: 8080
      initialDelaySeconds: 15
      periodSeconds: 10
    livenessProbe:
      httpGet:
        path: /
        port: 8080
      initialDelaySeconds: 15
      periodSeconds: 30
    volumeMounts:
    - mountPath: /ebs
      name: ebs-volume
  volumes:
  - name: ebs-volume
    persistentVolumeClaim:
      claimName: 04-pod-storageclass-pvc