In order to access the Kubernetes dashboard you have to run kubectl proxy on your local machine, then point your web browser to the proxy. Similarly, if you want to submit a Spark job you again run kubectl proxy on your local machine then run spark-submit against the localhost address.
My question is, why does Kubernetes have this peculiar arrangement? The dashboard service is running on the Kubernetes cluster, so why am I not pointing my web browser at the cluster directly? Why have a proxy? In some cases the need for proxy is inconvenient. For example, from my Web server I want to submit a Spark job. I can't do that--I have to run a proxy first, but this ties me to a specific cluster. I may have many Kubernetes clusters.
Why was Kubernetes designed such that you can only access it through a proxy?
type: nodePort
in your service definition ortype: LoadBalancer
if you're in an environment that supports LBs (Azure, AWS, GKE, etc.). See K8s services and Using a Service to Expose Your App – Hortense