Deploying the Kubernetes Metrics Server on a Cluster Using Kubectl

Find out how to use kubectl to deploy the Kubernetes Metrics Server on a cluster you've created using Container Engine for Kubernetes (OKE).

You can deploy the Kubernetes Metrics Server on clusters you create using Container Engine for Kubernetes to enable autoscaling.

The Kubernetes Metrics Server is a cluster-wide aggregator of resource usage data. The Kubernetes Metrics Server collects resource metrics from the kubelet running on each worker node and exposes them in the Kubernetes API server through the Kubernetes Metrics API. Other Kubernetes add-ons require the Kubernetes Metrics Server, including:

Note you can use the Kubernetes Metrics Server with both managed node pools and virtual node pools.

Note also that the Kubernetes Metrics Server is not intended to be used for anything other than autoscaling. For example, it is not recommended that you use the Kubernetes Metrics Server to forward metrics to monitoring solutions, nor as a source of monitoring solution metrics. For more information, see the Kubernetes Metrics Server documentation.

To deploy the Kubernetes Metrics Server on a cluster you've created with Container Engine for Kubernetes:

  1. If you haven't already done so, follow the steps to set up the cluster's kubeconfig configuration file and (if necessary) set the KUBECONFIG environment variable to point to the file. Note that you must set up your own kubeconfig file. You cannot access a cluster using a kubeconfig file that a different user set up. See Setting Up Cluster Access.
  2. If your Oracle Cloud Infrastructure user is a tenancy administrator or cluster administrator, skip the next step and go straight to the following step.
  3. If your Oracle Cloud Infrastructure user is not a tenancy administrator or cluster administrator, ask a tenancy administrator or cluster administrator to grant your user the Kubernetes RBAC cluster-admin clusterrole on the cluster by entering:
    
    kubectl create clusterrolebinding <my-cluster-admin-binding> --clusterrole=cluster-admin --user=<user-OCID>

    For more information, see About Access Control and Container Engine for Kubernetes.

  4. If you are going to deploy the Kubernetes Metrics Server on a cluster with managed node pools, deploy the Kubernetes Metrics Server by entering the following command in a terminal window:

    kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/<version-number>/components.yaml

    where <version-number> is the Kubernetes Metrics Server version that you want to deploy. For example, v0.6.1.

    Note that the Kubernetes Metrics Server is being actively developed, so the version number to specify will change over time. To find out the currently available versions, see the Kubernetes Metrics Server documentation.

    Tip

    If the command fails to connect to https://github.com/kubernetes-sigs/metrics-server/releases/download/<version-number>/components.yaml , go to the url in a browser and download the manifest file components.yaml to a local directory. Repeat the kubectl apply command and specify the local location of the components.yaml file.
  5. If you are going to deploy the Kubernetes Metrics Server on a cluster with virtual node pools:
    1. Go to the following url in a browser and download the manifest file components.yaml to a local directory:
      https://github.com/kubernetes-sigs/metrics-server/releases/download/<version-number>/components.yaml

      where <version-number> is the Kubernetes Metrics Server version that you want to deploy. For example, v0.6.1.

      Note that the Kubernetes Metrics Server is being actively developed, so the version number to specify will change over time. To find out the currently available versions, see the Kubernetes Metrics Server documentation.

    2. Open the components.yaml file in a text editor of your choice.
    3. Remove the following livenessProbe section from the manifest of the metrics-server deployment:
              livenessProbe:
                failureThreshold: 3
                httpGet:
                  path: /livez
                  port: https
                  scheme: HTTPS
                periodSeconds: 10
    4. Remove the readingessProbe section from the manifest of the metrics-server deployment:
              readinessProbe:
                failureThreshold: 3
                httpGet:
                  path: /readyz
                  port: https
                  scheme: HTTPS
                initialDelaySeconds: 20
                periodSeconds: 10
    5. Deploy the Kubernetes Metrics Server by entering the following command in a terminal window:
      kubectl apply -f <local-location>/components.yaml

      where <local-location> is the local directory containing the components.yaml file that you just modified.

  6. Confirm that the Kubernetes Metrics Server has been deployed successfully and is available by entering:

    kubectl get deployment metrics-server -n kube-system