Oi Daniel, bom dia! Tudo bem? Eu não estou conseguindo criar o horizontal pod autoscaler, você pode me ajudar?
PS C:\Users\Michael\Desktop\kubernetes-alura> kubectl apply -f .\portal-noticias-hpa.yaml
error: error validating ".\\portal-noticias-hpa.yaml": error validating data: [ValidationError(HorizontalPodAutoscaler.spec): unknown field "apiVersion" in io.k8s.api.autoscaling.v2beta2.HorizontalPodAutoscalerSpec, ValidationError(HorizontalPodAutoscaler.spec): unknown field "kind" in io.k8s.api.autoscaling.v2beta2.HorizontalPodAutoscalerSpec, ValidationError(HorizontalPodAutoscaler.spec.metrics[0]): unknown field "name" in io.k8s.api.autoscaling.v2beta2.MetricSpec, ValidationError(HorizontalPodAutoscaler.spec.metrics[0]): unknown field "target" in io.k8s.api.autoscaling.v2beta2.MetricSpec, ValidationError(HorizontalPodAutoscaler.spec): unknown field "name" in io.k8s.api.autoscaling.v2beta2.HorizontalPodAutoscalerSpec, ValidationError(HorizontalPodAutoscaler.spec): missing required field "scaleTargetRef" in io.k8s.api.autoscaling.v2beta2.HorizontalPodAutoscalerSpec]; if you choose to ignore these errors, turn validation off with --validate=false
Portal-noticias-hpa
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: portal-noticias-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: portal-noticias-deployment
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: utilization
averageUtilization: 50
Portal-noticias-deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: portal-noticias-deployment
spec:
template:
metadata:
name: portal-noticias
labels:
app: portal-noticias
spec:
containers:
- name: portal-noticias-container
image: aluracursos/portal-noticias:1
ports:
- containerPort: 80
envFrom:
- configMapRef:
name: portal-configmap
livenessProbe:
httpGet:
path: /
port: 80
periodSeconds: 10
failureThreshold: 5
initialDelaySeconds: 3
readinessProbe:
httpGet:
path: /
port: 80
periodSeconds: 10
failureThreshold: 3
initialDelaySeconds: 20
resources:
requests:
cpu: 10m
replicas: 3
selector:
matchLabels:
app: portal-noticias