Skip to content

Instantly share code, notes, and snippets.

@sanketsudake
Last active December 5, 2024 12:00
Show Gist options
  • Save sanketsudake/a089e691286bf2189bfedf295222bd43 to your computer and use it in GitHub Desktop.
Save sanketsudake/a089e691286bf2189bfedf295222bd43 to your computer and use it in GitHub Desktop.
Running metric-server on Kind Kubernetes

I have created a local Kubernetes cluster with kind. Following are changes you need to get metric-server running on Kind.

Deploy latest metric-server release.

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.5.0/components.yaml

Within existing arguments to metric-server container, you need to add argument --kubelet-insecure-tls.

You can create file metric-server-patch.yaml with following content,

spec:
  template:
    spec:
      containers:
      - args:
        - --cert-dir=/tmp
        - --secure-port=443
        - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
        - --kubelet-use-node-status-port
        - --metric-resolution=15s
        - --kubelet-insecure-tls
        name: metrics-server

NOTE: If you are using metric-server latest release above 0.5.0, it's possible container arguments may change. You should get existing arguments to container and just add --kubelet-insecure-tls argument to get patch.

Patch metric-server deployment,

kubectl patch deployment metrics-server -n kube-system --patch "$(cat metric-server-patch.yaml)"
@avoidik
Copy link

avoidik commented Oct 2, 2021

one-liner

$ kubectl patch -n kube-system deployment metrics-server --type=json \
  -p '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]'

@wind57
Copy link

wind57 commented Jan 4, 2022

@avoidik very nice!

@pmorelli92
Copy link

Thanks a lot for this!

@tschifftner
Copy link

Great, thank you! This can easily be used in a kustomization.yaml

bases:
  - https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.6.1/components.yaml

patchesJson6902:
  - target:
      version: v1
      kind: Deployment
      name: metrics-server
      namespace: kube-system
    patch: |-
      - op: add
        path: /spec/template/spec/containers/0/args/-
        value: --kubelet-insecure-tls

To apply it just run kubectl apply -k kustomization.yaml

@reegnz
Copy link

reegnz commented May 18, 2022

Thanks @tschifftner ! You literally put that comment there just in time! I could use it successfully.

@ChieftainY2k
Copy link

ChieftainY2k commented Feb 3, 2023

I suggest running the metrics server with the HELM Charts , works like a charm!:

helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/
helm repo update
helm upgrade --install --set args={--kubelet-insecure-tls} metrics-server metrics-server/metrics-server --namespace kube-system

@RafalSkolasinski
Copy link

Helm Chart was is much better!

@bergpb
Copy link

bergpb commented Mar 25, 2023

Great, thank you! This can easily be used in a kustomization.yaml

bases:
  - https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.6.1/components.yaml

patchesJson6902:
  - target:
      version: v1
      kind: Deployment
      name: metrics-server
      namespace: kube-system
    patch: |-
      - op: add
        path: /spec/template/spec/containers/0/args/-
        value: --kubelet-insecure-tls

To apply it just run kubectl apply -k kustomization.yaml

bases:
  - https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.6.1/components.yaml

patchesJson6902:
  - target:
      version: v1
      kind: Deployment
      name: metrics-server
      namespace: kube-system
    patch: |-
      - op: add
        path: /spec/template/spec/containers/0/args/-
        value: --kubelet-insecure-tls

Thanks, just a few updates in the code to prevent warnings on run kubectl apply:

resources:
  - https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.6.3/components.yaml

patches:
  - patch: |-
      - op: add
        path: /spec/template/spec/containers/0/args/-
        value: --kubelet-insecure-tls
    target:
      version: v1
      kind: Deployment
      name: metrics-server
      namespace: kube-system

@itacirgabral
Copy link

@luizpolli
Copy link

luizpolli commented Aug 24, 2023

the kodekloud example still works: https://github.com/kodekloudhub/kubernetes-metrics-server

This is not working. At least is for me

@ETisREAL
Copy link

Absolute God <3 I owe you a beer whenever dude

@qasimsqt
Copy link

@avoidik Thanks alot :)

@kishorevaishnav
Copy link

one-liner

$ kubectl patch -n kube-system deployment metrics-server --type=json \
  -p '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]'

This worked nicely.

@MA3CIN
Copy link

MA3CIN commented Apr 4, 2024

one-liner

$ kubectl patch -n kube-system deployment metrics-server --type=json \
  -p '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]'

The one liner is still the fastest solution, almost 3 years later :)

@kkbruce
Copy link

kkbruce commented Apr 5, 2024

kubectl patch -n kube-system deployment metrics-server --type=json \
  -p '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]'

This worked nicely +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment