Skip to content

Instantly share code, notes, and snippets.

@llaughlin
Last active November 16, 2023 19:39
Show Gist options
  • Save llaughlin/538c81b711645771598136347444419b to your computer and use it in GitHub Desktop.
Save llaughlin/538c81b711645771598136347444419b to your computer and use it in GitHub Desktop.
Kubernetes Commands

Get CPU & Memory Request & Limit for each deployment

Expanded
k get deploy -o yaml | yq '[.items[].spec.template.spec.containers[] | {.name: (.resources | {"cpu-req":.requests.cpu, "cpu-limit":.limits.cpu, "mem-req":.requests.memory, "mem-limit":.limits.memory})} ]'
Shortened
k get deploy -o yaml | yq '[.items[].spec.template.spec.containers[] | {.name: (.resources | {"cpu": .requests.cpu + " / " + .limits.cpu, "mem": .requests.memory + " / " + .limits.memory})} ]'
Oneline
k get deploy -o yaml | yq '[.items[].spec.template.spec.containers[] | {.name: (.resources | .requests.cpu + " / " + .limits.cpu + " , " + .requests.memory + " / " + .limits.memory)} ]'

Update HPA

Set minReplicas
k patch hpa --patch '{"spec":{"minReplicas": }}'

ALB

Get Service ALB Annotations
k get service -o json | jq '[.items[].metadata.annotations | {app: .app, path: .["alb.ingress.kubernetes.io/healthcheck-path"], interval: .["alb.ingress.kubernetes.io/healthcheck-interval-seconds"] }]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment