DevOps Classroom notes 11/Feb/2024

HPA (Horizontal Pod Autoscaling)

  • For this to work we need metrics server to be running.
  • Refer Here for hpa official docs
  • Lets create a nginx deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
        resources:
          limits:
            cpu: 250m
            memory: 256Mi
       - name: alpine
         image: alpine
         args:
           - sleep
           - 1d

  • Lets create a hpa kubectl autoscale deployment nginx-deployment --cpu-percent=50 --min=1 --max=10
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: nginx-deployment
spec:
  maxReplicas: 10
  metrics:
  - resource:
      name: cpu
      target:
        averageUtilization: 50
        type: Utilization
    type: Resource
  minReplicas: 1
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: nginx-deployment
  • Lets create a service called as nginx with cluster ip
apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
spec:
  selector:
    app: nginx
  ports:
  - name: websvc
    protocol: TCP
    port: 80
    targetPort: 80
  • Lets make the application busy
kubectl run -i --tty load-generator --rm --image=busybox:1.28 --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://nginx-svc; done"
  • Now watch number of pods

Cluster Autoscaler

Kubernetes Lens (UI Based Client)

Helm – Package Manager for k8s

  • Chart: An Application/Component to be deployed
  • Repository: This hosts Charts
  • Try installing
    • wordpress
    • prometheus and grafana
    • redis cache
  • To Author:
    • Go Template
    • use helm playground
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

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

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio
Exit mobile version
%%footer%%