stefanprodan / podinfo

Go microservice template for Kubernetes
Apache License 2.0
5.35k stars 1.7k forks source link

HorizontalPodAutoscaler/podinfo not found #333

Closed giuliohome closed 8 months ago

giuliohome commented 8 months ago

I see the following error message

NAME            REVISION                SUSPENDED       READY   MESSAGE

flux-system     main@sha1:203f897d      False           True    Applied revision:
 main@sha1:203f897d
podinfo                                 False           False   HorizontalPodAuto
scaler/podinfo not found: the server could not find the requested resource

and this is my configuration

cat ./clusters/my-cluster/podinfo-kustomization.yaml
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: podinfo
  namespace: flux-system
spec:
  interval: 5m0s
  path: ./kustomize
  prune: true
  sourceRef:
    kind: GitRepository
    name: podinfo
stefanprodan commented 8 months ago

You need to set targetNamespace: default to tell Flux where to deploy it.

See https://fluxcd.io/flux/get-started/#deploy-podinfo-application

giuliohome commented 8 months ago

Thank you!!!

giuliohome commented 8 months ago

Now I'm seeing

podinfo         master@sha1:badf3271    False           False   health check failed after 43.990272ms: failed early due to stalled resources: [Deployment/default/podin
fo status: 'Failed', HorizontalPodAutoscaler/default/podinfo status: 'Unknown']

and from k8s get events:

11m         Normal    ScalingReplicaSet              deployment/podinfo                Scaled up replica set podinfo-85c45f85db to 2 from 1
78s         Warning   FailedGetResourceMetric        horizontalpodautoscaler/podinfo   failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server could not find the requested resource (get pods.metrics.k8s.io)
8m18s       Warning   FailedComputeMetricsReplicas   horizontalpodautoscaler/podinfo   invalid metrics (1 invalid out of 1), first error is: failed to get cpu resource metric value: failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server could not find the requested resource (get pods.metrics.k8s.io)
stefanprodan commented 8 months ago

To use HPA you need metrics-server, which Kubernetes distribution are you using?

giuliohome commented 8 months ago

Hi, thanks again it's DigitalOcean 2 nodes s-1vcpu-2gb - 1.28.2-do.0 maybe too low the cpu or other resources?

I'm adding a third node now, if it can help...

stefanprodan commented 8 months ago

You need to install metrics-server, probably DigitalOcean, unlike most cloud vendors, don't set it up for you.

You can install metrics-server with Flux like so:

---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
  name: metrics-server
  namespace: flux-system
spec:
  interval: 24h
  url: https://kubernetes-sigs.github.io/metrics-server/
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: metrics-server
  namespace: flux-system
spec:
  interval: 30m
  targetNamespace: kube-system
  chart:
    spec:
      chart: metrics-server
      version: "*"
      sourceRef:
        kind: HelmRepository
        name: metrics-server
      interval: 12h
  values:
    args:
      - --kubelet-insecure-tls
giuliohome commented 8 months ago

wow :tada: thank you again !!!!!

image