<p>I have seen that the standard way to access http services through the kubectl proxy is the following:
<code>http://api.host/api/v1/namespaces/NAMESPACE/services/SERVICE_NAME:SERVICE_PORT/proxy/</code></p>

<p>Why is it that the kubernetes-dashboard uses <code>https:kubernetes-dashboard:</code> for <code>SERVICE_NAME:SERVICE_PORT</code>?</p>

<p>I would assume from the following that it would be <code>kubernetes_dashboard:443</code>.</p>

<pre><code>kubectl -n kube-system get service kubernetes-dashboard -o wide
NAME                   TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE   SELECTOR
kubernetes-dashboard   ClusterIP   10.233.50.212   &lt;none&gt;        443:31663/TCP   15d   k8s-app=kubernetes-dashboard
</code></pre>

<p>Additionally, what is the meaning of the port show <code>443:31663</code> when all other services will just have <code>x/TCP</code> (<em>x</em> being one number instead of <em>x</em>:<em>y</em>)</p>

<p>Lastly, <code>kubectl cluster-info</code> will show</p>

<pre><code>Kubernetes master is running at https://x.x.x.x:x
kubernetes-dashboard is running at https://x.x.x.x:x/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
</code></pre>

<p>I have created a simple service but it does not show here and I am confused how to determine what services show here or not.</p>

xbfh0516
<blockquote>
  <p>Why is it that the kubernetes-dashboard uses
  https:kubernetes-dashboard: for SERVICE_NAME:SERVICE_PORT?</p>
  
  <p>Additionally, what is the meaning of the port show 443:31663 when all
  other services will just have x/TCP (x being one number instead of
  x:y)</p>
</blockquote>

<p>As described in <a href="https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#manually-constructing-apiserver-proxy-urls" rel="nofollow noreferrer">Manually constructing apiserver proxy URLs</a>, the default way is </p>

<pre><code>http://kubernetes_master_address/api/v1/namespaces/namespace_name/services/service_name[:port_name]/proxy
</code></pre>

<blockquote>
  <p>By default, the API server proxies to your service using http. To use
  https, prefix the service name with https::</p>
</blockquote>

<p><code>http://kubernetes_master_address/api/v1/namespaces/namespace_name/services/https:service_name:[port_name]/proxy</code></p>

<p>The supported formats for the name segment of the URL are:</p>

<p><code>&lt;service_name&gt;</code> - proxies to the default or unnamed port using http</p>

<p><code>&lt;service_name&gt;:&lt;port_name&gt;</code> - proxies to the specified port using http</p>

<p><code>https:&lt;service_name&gt;:</code> - proxies to the default or unnamed port using https (note the trailing colon)</p>

<p><code>https:&lt;service_name&gt;:&lt;port_name&gt;</code> - proxies to the specified port using https</p>

<p>Next:</p>

<blockquote>
  <p>I have created a simple service but it does not show here and I am
  confused how to determine what services show here or not.</p>
</blockquote>

<p>What is what I found and tested for you:</p>

<p><a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#cluster-info" rel="nofollow noreferrer">cluster-info API reference</a>:</p>

<p>Display addresses of the master and services with label <strong>kubernetes.io/cluster-service=true</strong> To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.</p>

<p>So, as soon as you add <code>kubernetes.io/cluster-service: "true"</code> label - the service starts to be seen under <code>kubectl cluster-info</code>.</p>

<p>BUT!! There is an expected behavior when you see that you service  disappear from output in couple of minutes. Explanation has been found <a href="https://github.com/kubernetes/dashboard/issues/1849#issuecomment-294100681" rel="nofollow noreferrer">here</a> - I only copy paste it here for future reference.</p>

<blockquote>
  <p>The other part is the addon manager. It uses this annotation to
  synchronizes the cluster state with static manifest files. The
  behavior was something like this:</p>
</blockquote>

<p>1) addon manager reads a yaml from disk -> deploys the contents</p>

<p>2) addon manager reads all deployments from api server with annotation cluster-service:true -> deletes all that do not exist as files</p>

<p><strong>As a result, if you add this annotation, addon manager will remove dashboard after a minute or so.</strong></p>

<p>So,</p>

<p><strong>dashboard is deployed after cluster creation -> annotation should not be set:</strong>
<a href="https://github.com/kubernetes/dashboard/blob/b98d167dadaafb665a28091d1e975cf74eb31c94/src/deploy/kubernetes-dashboard.yaml" rel="nofollow noreferrer">https://github.com/kubernetes/dashboard/blob/b98d167dadaafb665a28091d1e975cf74eb31c94/src/deploy/kubernetes-dashboard.yaml</a></p>

<p><strong>dashboard is deployed part of cluster creation -> annotation should be set:</strong>
<a href="https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dashboard/dashboard-controller.yaml" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dashboard/dashboard-controller.yaml</a></p>

<p>At least this was the behavior some time ago. I think kubeadm does not use addon-manager. But it is still part of kube-up script.</p>

<p>Solution for this behavior also exists: add additional label <code>addonmanager.kubernetes.io/mode: EnsureExists</code></p>

<p>Explanation is <a href="https://github.com/kubernetes/dashboard/issues/1849#issuecomment-337480580" rel="nofollow noreferrer">here</a></p>

<p>You final service should look like:</p>

<pre><code># ------------------- Dashboard Service ------------------- #

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: EnsureExists
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  ports:
    - port: 443
      targetPort: 8443
  selector:
    k8s-app: kubernetes-dashboard



kubectl get svc kubernetes-dashboard -n kube-system -o yaml
apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"addonmanager.kubernetes.io/mode":"EnsureExists","k8s-app":"kubernetes-dashboard","kubernetes.io/cluster-service":"true"},"name":"kubernetes-dashboard","namespace":"kube-system"},"spec":{"ports":[{"port":443,"targetPort":8443}],"selector":{"k8s-app":"kubernetes-dashboard"}}}
  labels:
    addonmanager.kubernetes.io/mode: EnsureExists
    k8s-app: kubernetes-dashboard
    kubernetes.io/cluster-service: "true"



kubectl cluster-info
Kubernetes master is running at https://*.*.*.*
...
kubernetes-dashboard is running at https://*.*.*.*/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
...
</code></pre>
