I m trying to write a kustomize patch for HPA version from autoscaling/v2beta2
to autoscaling/v1
. I am able to change the version with the following patch
patches:
- patch: |-
- op: replace
path: "/apiVersion"
value: autoscaling/v1
target:
group: autoscaling
version: v2beta2
But I m unable to change the following snippet
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 70
to the latest version syntax.
I have tried JsonPatch and various other ways to do this, but I m not succssful in doing that.
Is there anyway to write a patch to achieve this change?
Output of my apiversion patch
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
labels:
environment: production
name: piebot
namespace: piebot
spec:
maxReplicas: 3
metrics:
- resource:
name: cpu
target:
averageUtilization: 70
type: Utilization
type: Resource
- resource:
name: memory
target:
averageUtilization: 70
type: Utilization
type: Resource
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: piebot
JSON patch I tried
- op: replace
path: /apiVersion
value: autoscaling/v2beta2
- op: replace
path: /spec/metrics/0/resource/targetAverageUtilization
value: 70
- op: replace
path: /spec/metrics/1/resource/targetAverageUtilization
value: 70
Thsi patch doesnt work.
Desired output for resource
- type: Resource
resource:
name: memory
targetAverageUtilization: 70