CKA Mock Exam 3 Question 11

Good day,

Please I want to know if I was marked wrong because of “technicality” and not because I was inherently wrong.

The question

Create a Horizontal Pod Autoscaler (HPA) for the deployment named 
api-deployment located in the api namespace.
The HPA should scale the deployment based on a custom metric 
named requests_per_second, targeting an average value of 1000
 requests per second across all pods.
Set the minimum number of replicas to 1 and the maximum to 20.

Note: Deployment named api-deployment is available in api 
namespace. Ignore errors due to the metric requests_per_second 
not being tracked in metrics-server

The proposed solution:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: api-hpa
  namespace: api
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api-deployment
  minReplicas: 1
  maxReplicas: 20
  metrics:
  - type: Pods
    pods:
      metric:
        name: requests_per_second
      target:
        type: AverageValue
        averageValue: "1000"

The solution I applied:

controlplane ~ ➜  cat hpa.yaml 
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: api-hpa
  namespace: api
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api-deployment
  minReplicas: 1
  maxReplicas: 20
  metrics:
  - type: Pods
    pods:
      metric:
        name: requests-per-second
      target:
        type: AverageValue
        averageValue: 1k

The result I was shown (and the issue):
Details

Is api-hpa HPA deployed in api namespace?

Is api-hpa configured for metric requests_per_second?

Essentially, the only difference between the two yamls (as far as I can tell is the averageValue) expressed by me as “1k” (which I took off the kubernetes website) and by the examiner as “1000”. I have tried to research and they are supposed to both mean the same thing. My best guess is that because the examiner has to mark by checking certain values, they may not have set up the system to accept “1k” as a valid answer.

I realise I have been posting here a lot but I just failed CKA and my rewrite is coming up soon. lol. So all help is greatly appreciated. lol

@rob_kodekloud @Alistair_KodeKloud @Santosh_KodeKloud

I’m still researching what metric names are actually allowed for HPA. The doc on the k8s docs people reference is NOT A SPECIFICATION. Most of the specs seem to say that identifiers should use underscores, AND NOT DASHES. Note that we use underscores in our answer. This difference is likely NOT A TECHNICALITY.

How you are supposed to know which values to use is difficult to know, but the docs I’ve been able to find seem to use underscores.

1 Like

Oh. I totally get it.

It isn’t the “1k” that was the issue. It was most likely the

I COMPLETELY missed the naming requirement of the examiner. Wow! That’s chilling! :joy::rofl:

Thanks for pointing it out!

Although technically not what failed you on this question, let’s clear up the bit about numeric values.

The Kubernetes code uses an SI unit parser for all numeric values, so yes 1000 == 1k. These units may additionally include i for binary representation, meaning 1024 == 1ki.

Although we cannot say for certain what the real exam would do in this situation, it is likely that their grader will exactly follow the Kubernetes specification in this respect. Whether ours does, I have not tested!

Rob and I have investigated the numeric value a bit further and what we’ve found is this

If you apply the manifest with the value "1000" and then do

kubectl get hpa api-hpa -o yaml

you will see that the value is now 1k. What this means is that API server will convert numeric values to SI values before committing the manifest to etcd.

Graders work by doing the above command to get back the manifest from the cluster and then looking at the values in it. Ergo it has to test for the value being 1k which it will be if you put either 1000 or 1k

1 Like

Thank you both (@Alistair_KodeKloud @rob_kodekloud) so much for your explanations about the 1k.

However, I believe the “chief” reason I was failed the task (after analyzing @rob_kodekloud’s response above), is that I used requests-per-second (I blindly copied from the example on the kubernetes documentation walkthrough) instead of using the (explicitly specified…lol) unit of requests_per_second. Infact, the entire thread is quite embarrassing that I missed it :slight_smile:

I cannot appreciate the attention to detail that you guys have! It’s beautiful! Thank you again.