Skip to main content

Install vpa Tested 03-08-2025

 #!/bin/bash


echo "Step 1: Creating VPA CRDs with required annotations..."


cat <<EOF | kubectl apply -f -

apiVersion: apiextensions.k8s.io/v1

kind: CustomResourceDefinition

metadata:

  name: verticalpodautoscalers.autoscaling.k8s.io

  annotations:

    api-approved.kubernetes.io: "https://github.com/kubernetes/enhancements/pull/1867"

spec:

  group: autoscaling.k8s.io

  names:

    kind: VerticalPodAutoscaler

    plural: verticalpodautoscalers

    singular: verticalpodautoscaler

    shortNames:

      - vpa

  scope: Namespaced

  versions:

    - name: v1

      served: true

      storage: true

      schema:

        openAPIV3Schema:

          type: object

---

apiVersion: apiextensions.k8s.io/v1

kind: CustomResourceDefinition

metadata:

  name: verticalpodautoscalercheckpoints.autoscaling.k8s.io

  annotations:

    api-approved.kubernetes.io: "https://github.com/kubernetes/enhancements/pull/1867"

spec:

  group: autoscaling.k8s.io

  names:

    kind: VerticalPodAutoscalerCheckpoint

    plural: verticalpodautoscalercheckpoints

    singular: verticalpodautoscalercheckpoint

  scope: Namespaced

  versions:

    - name: v1

      served: true

      storage: true

      schema:

        openAPIV3Schema:

          type: object

EOF


echo "Step 2: Applying RBAC..."

kubectl apply -f https://raw.githubusercontent.com/kubernetes/autoscaler/master/vertical-pod-autoscaler/deploy/vpa-rbac.yaml


echo "🚀 Step 3: Deploying VPA components..."


cat <<EOF | kubectl apply -f -

apiVersion: apps/v1

kind: Deployment

metadata:

  name: vpa-updater

  namespace: kube-system

spec:

  replicas: 1

  selector:

    matchLabels:

      app: vpa-updater

  template:

    metadata:

      labels:

        app: vpa-updater

    spec:

      serviceAccountName: vpa-updater

      containers:

        - name: vpa-updater

          image: k8s.gcr.io/autoscaling/vpa-updater:0.13.0

          resources:

            limits:

              cpu: 100m

              memory: 300Mi

---

apiVersion: apps/v1

kind: Deployment

metadata:

  name: vpa-recommender

  namespace: kube-system

spec:

  replicas: 1

  selector:

    matchLabels:

      app: vpa-recommender

  template:

    metadata:

      labels:

        app: vpa-recommender

    spec:

      serviceAccountName: vpa-recommender

      containers:

        - name: vpa-recommender

          image: k8s.gcr.io/autoscaling/vpa-recommender:0.13.0

          resources:

            limits:

              cpu: 100m

              memory: 300Mi

---

apiVersion: apps/v1

kind: Deployment

metadata:

  name: vpa-admission-controller

  namespace: kube-system

spec:

  replicas: 1

  selector:

    matchLabels:

      app: vpa-admission-controller

  template:

    metadata:

      labels:

        app: vpa-admission-controller

    spec:

      serviceAccountName: vpa-admission-controller

      containers:

        - name: vpa-admission-controller

          image: k8s.gcr.io/autoscaling/vpa-admission-controller:0.13.0

          ports:

            - containerPort: 8000

              name: webhook

          resources:

            limits:

              cpu: 100m

              memory: 200Mi

---

apiVersion: v1

kind: Service

metadata:

  name: vpa-webhook

  namespace: kube-system

spec:

  selector:

    app: vpa-admission-controller

  ports:

    - port: 443

      targetPort: webhook

EOF


echo "✅ All VPA components deployed."


echo "Final Check - VPA Pods:"

kubectl get pods -n kube-system | grep vpa

chmod +x install-vpa-complete.sh

./install-vpa-complete.sh


Comments

Popular posts from this blog

CKA 2025 MOCK Q -11 TLS

  You’re managing a web server running in a Kubernetes Deployment called secure-site , located in the web-zone namespace. Its NGINX configuration comes from a ConfigMap called site-tls-config . 🧩 Task: Update the ConfigMap ( site-tls-config ) to ensure that only TLS version 1.3 is accepted by the server. Older versions like TLS 1.2 should be blocked completely. Once the ConfigMap is updated: Make sure the secure-site deployment picks up the changes. You might need to restart or roll it out again. Test it with this command: curl --tls-max 1.2 -k https://neokloud.in:32443 The command should fail , because the server should now reject anything below TLSv1.3.   echo "[1/8] Creating namespace: web-zone" kubectl create ns web-zone || true echo "[2/8] Generating TLS certificate for neokloud.in" mkdir -p /tmp/tls && cd /tmp/tls openssl req -x509 -nodes -days 365 \   -newkey rsa:2048 \   -keyout tls.key \   -out tls.crt \   -su...

CKA-2025 MOCK Q-06 PRIORITY

 Generate a PriorityClass named urgent-priority for urgent workloads,  setting the value to 10 less than the highest current user-defined priority class value.  Patch the Deployment mysql-writer in the database namespace to use the urgent-priority class and verify a successful rollout.   Note – Pods from other Deployments in the database namespace should be evicted if resources Cruch kubectl create namespace database # redis-cache Deployment cat <<EOF | kubectl apply -f - apiVersion: apps/v1 kind: Deployment metadata:   name: redis-cache   namespace: database spec:   replicas: 2   selector:     matchLabels:       app: redis-cache   template:     metadata:       labels:         app: redis-cache     spec:       containers:       - name: redis         image: redis:7         resources: ...

CKA 2025 MOCK Q-05 HPA

5 Mock Questions on Horizontal Pod Autoscaler (HPA) 🔶 Question 1: Scale Based on Custom CPU Target and Scale-Up Cooldown You have a Deployment named api-backend in the default namespace. Task: Create an HPA targeting 70% CPU usage Min: 1, Max: 10 replicas Set scale-up cooldown (delay before scaling up again) to 30 seconds File name: hpa-backend.yaml Bonus: Set the HPA to avoid scaling up rapidly even if CPU spikes.   cat <<EOF | kubectl apply -f - apiVersion: apps/v1 kind: Deployment metadata:   name: api-backend   namespace: default spec:   replicas: 2   selector:     matchLabels:       app: api-backend   template:     metadata:       labels:         app: api-backend     spec:       containers:   ...