Kubernetes Metrics Server Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* https://github.com/kubernetes-sigs/metrics-server
=Internal=
=Internal=
* [[Kubernetes Metrics Server]]
* [[Kubernetes Metrics Server]]
=Help=
<syntaxhighlight lang='yaml'>
docker run --rm k8s.gcr.io/metrics-server/metrics-server:v0.3.7 --help
</syntaxhighlight>
=Installation=
=Installation=
{{External|https://github.com/kubernetes-sigs/metrics-server#requirements}}
{{External|https://github.com/kubernetes-sigs/metrics-server#requirements}}
==Docker Desktop Kubernetes==
==With Helm==
==EKS==
{{External|https://github.com/helm/charts/tree/master/stable/metrics-server}}
 
Can be installed directly from the "stable" repository:
<syntaxhighlight lang='bash'>
helm install metrics-server stable/metrics-server --set args="{--kubelet-insecure-tls,--cert-dir=/tmp}"
</syntaxhighlight>
 
Alternatively, the chart can be built locally with with 'helm package ./metrics-server', then installed with:
<syntaxhighlight lang='bash'>
helm install metrics-server ./metrics-server-2.11.2.tgz -f ./values.yaml
</syntaxhighlight>
where values.yaml:
<syntaxhighlight lang='yaml'>
image:
  repository: k8s.gcr.io/metrics-server/metrics-server
  tag: v0.3.7
args:
  - --kubelet-insecure-tls
  - --cert-dir=/tmp
</syntaxhighlight>
 
==With Manifest==
===Docker Desktop Kubernetes===
====Install====
<syntaxhighlight lang='text'>
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.4.1/components.yaml
</syntaxhighlight>
 
By default, metrics-server is deployed in "kube-system" namespace, without being necessary to use "-n kube-system":
 
<syntaxhighlight lang='text'>
kubectl -n kube-system get pods
NAME                              READY  STATUS    RESTARTS  AGE
metrics-server-866b7d5b74-845tb  1/1    Running  0          15s
</syntaxhighlight>
 
The up-to-date release list can be found here: https://github.com/kubernetes-sigs/metrics-server/tags
 
If configuration needs to be changed, pull the file locally and install it with:
<syntaxhighlight lang='text'>
kubectl apply -f ./components.yaml
 
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
serviceaccount/metrics-server created
deployment.apps/metrics-server created
service/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
</syntaxhighlight>
 
====Configuration====
For Docker Desktop Kubernetes, add "--kubelet-insecure-tls", otherwise the pod reads will fail with:
<syntaxhighlight lang='text'>
x509: certificate signed by unknown authority
</syntaxhighlight>
<syntaxhighlight lang='yaml'>
kind: Deployment
metadata:
  name: metrics-server
spec:
  template:
    spec:
      containers:
      - name: metrics-server
        args:
          - --kubelet-insecure-tls
          - --cert-dir=/tmp
          - --secure-port=4443
</syntaxhighlight>
 
====Uninstall====
Uninstall all the Kubernetes API resources. To reconfigure, it is sufficient to uninstall then re-install the deployment.
 
===EKS===
{{External|https://docs.aws.amazon.com/eks/latest/userguide/horizontal-pod-autoscaler.html}}
{{External|https://docs.aws.amazon.com/eks/latest/userguide/horizontal-pod-autoscaler.html}}


=Installation Validation=
=Installation Validation=
{{Internal|kubectl top|kubectl top}}
{{Internal|kubectl top|kubectl top}}

Latest revision as of 01:14, 3 February 2021

External

Internal

Help

docker run --rm k8s.gcr.io/metrics-server/metrics-server:v0.3.7 --help

Installation

https://github.com/kubernetes-sigs/metrics-server#requirements

With Helm

https://github.com/helm/charts/tree/master/stable/metrics-server

Can be installed directly from the "stable" repository:

helm install metrics-server stable/metrics-server --set args="{--kubelet-insecure-tls,--cert-dir=/tmp}"

Alternatively, the chart can be built locally with with 'helm package ./metrics-server', then installed with:

helm install metrics-server ./metrics-server-2.11.2.tgz -f ./values.yaml

where values.yaml:

image:
  repository: k8s.gcr.io/metrics-server/metrics-server
  tag: v0.3.7
args:
  - --kubelet-insecure-tls
  - --cert-dir=/tmp

With Manifest

Docker Desktop Kubernetes

Install

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

By default, metrics-server is deployed in "kube-system" namespace, without being necessary to use "-n kube-system":

kubectl -n kube-system get pods
NAME                              READY   STATUS    RESTARTS   AGE
metrics-server-866b7d5b74-845tb   1/1     Running   0          15s

The up-to-date release list can be found here: https://github.com/kubernetes-sigs/metrics-server/tags

If configuration needs to be changed, pull the file locally and install it with:

kubectl apply -f ./components.yaml

clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
serviceaccount/metrics-server created
deployment.apps/metrics-server created
service/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created

Configuration

For Docker Desktop Kubernetes, add "--kubelet-insecure-tls", otherwise the pod reads will fail with:

x509: certificate signed by unknown authority
kind: Deployment
metadata:
  name: metrics-server
spec:
  template:
    spec:
      containers:
      - name: metrics-server
        args:
          - --kubelet-insecure-tls
          - --cert-dir=/tmp
          - --secure-port=4443

Uninstall

Uninstall all the Kubernetes API resources. To reconfigure, it is sufficient to uninstall then re-install the deployment.

EKS

https://docs.aws.amazon.com/eks/latest/userguide/horizontal-pod-autoscaler.html

Installation Validation

kubectl top