Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove namespace field from scaleTargetRef for hpa #271

Merged
merged 4 commits into from
Nov 25, 2024

Conversation

fivesheep
Copy link
Contributor

Trying to enable hpa with this chart and getting the following error

unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(HorizontalPodAutoscaler.spec.scaleTargetRef): unknown field "namespace" in io.k8s.api.autoscaling.v2beta1.CrossVersionObjectReference

per HorizontalPodAutoscaler spec, it doesn't have this namespace field from scaleTargetRef, removing this line shall fix it. more example can be found from https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics

@divyansh-gupta
Copy link
Contributor

@fivesheep - Thank you for the pull request, we will review it soon. Can you please confirm that when you removed the line locally, HPA worked for you?

@fivesheep
Copy link
Contributor Author

@divyansh-gupta yes, it works after deleting that line. however, the version of the hpa we have is a bit old. I am getting this error

Warning: autoscaling/v2beta1 HorizontalPodAutoscaler is deprecated in v1.22+, unavailable in v1.25+; use autoscaling/v2 HorizontalPodAutoscaler
horizontalpodautoscaler.autoscaling/aws-privateca-issuer created

i can update this from the same pr to upgrade this to autoscaling/v2

@bmsiegel
Copy link
Contributor

That'd be great if you wouldn't mind adding that. Thanks!

@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fivesheep
Once this PR has been reviewed and has the lgtm label, please assign sgtcodfish for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fivesheep
Copy link
Contributor Author

@bmsiegel the pr has been updated and tested

@fivesheep
Copy link
Contributor Author

test failure seems to be unrelated, the command from the test as shown below, didn't even trigger the hpa logic, which is off by default

helm install issuer ./charts/aws-pca-issuer -n aws-privateca-issuer \
--set serviceAccount.create=false --set serviceAccount.name=aws-privateca-issuer-sa \
--set image.repository="localhost:5000/aws-privateca-issuer" --set image.tag=latest --set image.pullPolicy=Always

@bmsiegel
Copy link
Contributor

Yea I agree, I merged a fix to this recently (ccf4d25). Would you mind rebasing?

@bmsiegel
Copy link
Contributor

Thanks, running testing now

Signed-off-by: Abhishek Mishra <[email protected]>
Use `targetAverageUtilization` if cluster is running `autoscaling/v2beta1`, otherwise use new format.

Signed-off-by: Abhishek Mishra <[email protected]>
@amibhi
Copy link
Contributor

amibhi commented Nov 20, 2024

Made changes to use targetAverageUtilization if cluster is running autoscaling/v2beta1, otherwise use new format e.g.

        target:
          type: Utilization
          averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}

I have tested this PR on a cluster running K8s v1.22.17 with autoscaling/v2beta1 and a cluster running K8s v1.27.1 with autoscaling/v2, with results below

v1.22.17

[ec2-user@ip-10-0-0-41 aws-privateca-issuer]$ kubectl version
Client Version: v1.28.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.22.17
WARNING: version difference between client (1.28) and server (1.22) exceeds the supported minor version skew of +/-1

[ec2-user@ip-10-0-0-41 aws-privateca-issuer]$ helm install issuer ./charts/aws-pca-issuer -n aws-privateca-issuer \
--set serviceAccount.create=false --set serviceAccount.name=aws-privateca-issuer-sa \
--set image.repository="localhost:5000/aws-privateca-issuer" --set image.tag=latest --set image.pullPolicy=Always \
--set autoscaling.enabled=true
W1120 22:59:48.819326  269981 warnings.go:70] autoscaling/v2beta1 HorizontalPodAutoscaler is deprecated in v1.22+, unavailable in v1.25+; use autoscaling/v2beta2 HorizontalPodAutoscaler
W1120 22:59:48.879265  269981 warnings.go:70] autoscaling/v2beta1 HorizontalPodAutoscaler is deprecated in v1.22+, unavailable in v1.25+; use autoscaling/v2beta2 HorizontalPodAutoscaler
NAME: issuer
LAST DEPLOYED: Wed Nov 20 22:59:48 2024
NAMESPACE: aws-privateca-issuer
STATUS: deployed
REVISION: 1
TEST SUITE: None

[ec2-user@ip-10-0-0-41 aws-privateca-issuer]$ helm -n aws-privateca-issuer get manifest issuer
...
---
# Source: aws-privateca-issuer/templates/hpa.yaml
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: issuer-aws-privateca-issuer
  labels:
    helm.sh/chart: aws-privateca-issuer-v1.4.0
    app.kubernetes.io/name: aws-privateca-issuer
    app.kubernetes.io/instance: issuer
    app.kubernetes.io/version: "v1.4.0"
    app.kubernetes.io/managed-by: Helm
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: issuer-aws-privateca-issuer
  minReplicas: 1
  maxReplicas: 100
  metrics:
    - type: Resource
      resource:
        name: cpu
        targetAverageUtilization: 80

v1.27.1

ubuntu@ip-172-31-80-22:~/aws-privateca-issuer$ kubectl version
Client Version: v1.31.2
Kustomize Version: v5.4.2
Server Version: v1.27.1
WARNING: version difference between client (1.31) and server (1.27) exceeds the supported minor version skew of +/-1

ubuntu@ip-172-31-80-22:~/aws-privateca-issuer$ helm install issuer ./charts/aws-pca-issuer -n aws-privateca-issuer \
--set serviceAccount.create=false --set serviceAccount.name=aws-privateca-issuer-sa \
--set image.repository="localhost:5000/aws-privateca-issuer" --set image.tag=latest --set image.pullPolicy=Always \
--set autoscaling.enabled=true
NAME: issuer
LAST DEPLOYED: Wed Nov 20 22:52:13 2024
NAMESPACE: aws-privateca-issuer
STATUS: deployed
REVISION: 1
TEST SUITE: None

ubuntu@ip-172-31-80-22:~/aws-privateca-issuer$ helm -n aws-privateca-issuer get manifest issuer
...
---
# Source: aws-privateca-issuer/templates/hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: issuer-aws-privateca-issuer
  labels:
    helm.sh/chart: aws-privateca-issuer-v1.4.0
    app.kubernetes.io/name: aws-privateca-issuer
    app.kubernetes.io/instance: issuer
    app.kubernetes.io/version: "v1.4.0"
    app.kubernetes.io/managed-by: Helm
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: issuer-aws-privateca-issuer
  minReplicas: 1
  maxReplicas: 100
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 80

@amibhi
Copy link
Contributor

amibhi commented Nov 20, 2024

Full testing worklog: HPA worklog.md

@cert-manager-prow
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cert-manager-prow cert-manager-prow bot merged commit 3456e43 into cert-manager:main Nov 25, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants