KubernetesのHorizontalPodAutoscalerでハマった話
ふとしたきっかけで、deploymentを以下のように定義していたわけです。
apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: app: v1 name: nginx spec: replicas: 1 selector: matchLabels: app: v1 strategy: {} template: metadata: creationTimestamp: null labels: app: v1 spec: containers: - image: nginx name: nginx resources: requests: cpu: "100m" memory: 128Mi limits: cpu: "100m" memory: 256Mi
このマニフェストによるdeployment、kubectl autoscale
でもhpaが機能しません!
以下のように、app
ラベルはapp: <deployment名>
である必要があるみたいです。。。
apiVersion: apps/v1 kind: Deployment metadata: creationTimestamp: null labels: app: nginx name: nginx spec: replicas: 1 selector: matchLabels: app: nginx strategy: {} template: metadata: creationTimestamp: null labels: app: nginx spec: containers: - image: nginx name: nginx resources: requests: cpu: "100m" memory: 128Mi limits: cpu: "100m" memory: 256Mi
今日、1/3日ぐらいハマってしましました。。。