title: How to expose kubernetes metric server api to curl from inside the pod?
body: <p>I am using <a href="https://github.com/kubernetes-sigs/metrics-server" rel="nofollow noreferrer">metric server</a> to get the usage of my Kubernetes cluster. But in order to use it from outside the host, I need to use "kubectl proxy". But i don't want to do that as it is not intended to run on background. I want it to be run as a service continuously </p>
  
  <p>How can i achieve these</p>
  
  <p><strong>expected output</strong>
   curl clusterip:8001/apis/metrics.k8s.io/v1beta1/nodes</p>
  
  <pre><code>{
    "kind": "NodeMetricsList",
    "apiVersion": "metrics.k8s.io/v1beta1",
    "metadata": {
      "selfLink": "/apis/metrics.k8s.io/v1beta1/nodes"
    },
    "items": [
      {
        "metadata": {
          "name": "manhattan-master",
          "selfLink": "/apis/metrics.k8s.io/v1beta1/nodes/manhattan-master",
          "creationTimestamp": "2019-11-15T04:26:47Z"
        },
        "timestamp": "2019-11-15T04:26:33Z",
        "window": "30s",
        "usage": {
          "cpu": "222998424n",
          "memory": "3580660Ki"
        }
      }
    ]
  </code></pre>
  
  <p>I tried by using <strong>LoadBalancig service</strong>
  <strong>metrics-server-service.yaml</strong></p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: metrics-server
    namespace: kube-system
    labels:
      kubernetes.io/name: "Metrics-server"
      kubernetes.io/cluster-service: "true"
  spec:
    selector:
      k8s-app: metrics-server
    ports:
    - port: 443
      protocol: TCP
      targetPort: main-port
    externalTrafficPolicy: Local
    type: LoadBalancer
  </code></pre>
  
  <p><strong>kubectl describe service metrics-master -n kube-system</strong></p>
  
  <pre><code>[root@manhattan-master 1.8+]# kubectl describe service metrics-server -n kube-system
  Name:                     metrics-server
  Namespace:                kube-system
  Labels:                   kubernetes.io/cluster-service=true
                            kubernetes.io/name=Metrics-server
  Annotations:              kubectl.kubernetes.io/last-applied-configuration:
                              {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"kubernetes.io/cluster-service":"true","kubernetes.io/name":"Me...
  Selector:                 k8s-app=metrics-server
  Type:                     LoadBalancer
  IP:                       10.110.223.216
  Port:                     &lt;unset&gt;  443/TCP
  TargetPort:               main-port/TCP
  NodePort:                 &lt;unset&gt;  31043/TCP
  Endpoints:                10.32.0.7:4443
  Session Affinity:         None
  External Traffic Policy:  Local
  HealthCheck NodePort:     32208
  Events:                   &lt;none&gt;
  </code></pre>