Services and ports

Services can be placed in two groups based on the network interface they bind to. Services binding to the localhost interface are only available from within the host. Services binding to the default host interface are available from outside the host and thus are subject to access restrictions.

Services binding to the default Host interface

PortServiceAccess Restrictions
16443API serverSSL encrypted. Clients need to present a valid password from a Static Password File.
10250kubeletAnonymous authentication is disabled. X509 client certificate is required.
10255kubeletRead only port for the Kubelet.
25000cluster-agentProper token required to authorise actions.
12379etcdSSL encrypted. Client certificates required to connect.
10257kube-controllerServe HTTPS with authentication and authorization.
10259kube-schedulerServe HTTPS with authentication and authorization.
19001dqliteSSL encrypted. Client certificates required to connect.

Services binding to the localhost interface

PortServiceDescription
10248kubeletLocalhost healthz endpoint.
10249kube-proxyPort for the metrics server to serve on.
10251kube-schedulePort on which to serve HTTP insecurely.
10252kube-controllerPort on which to serve HTTP insecurely.
10256kube-proxyPort to bind the health check server.
2380etcdUsed for peer connections.
1338containerdMetrics port

Containerd and etcd

Both these services are exposed through unix sockets.

ServiceSocket
containerdunix:///var/snap/microk8s/common/run/containerd.sock

Authentication and authorization

Upon deployment MicroK8s creates a Certificate Authority, a signed server certificate and a service account key file. These files are stored under /var/snap/microk8s/current/certs/. Kubelet and the API server are aware of the same CA and so the signed server certificate is used by the API server to authenticate with kubelet (--kubelet-client-certificate).

Initially the server certificates will be issued for:

  • localhost and all the ip addresses avaliable on the machine, typically it’s LAN address
  • various mDNS addresses, such as kubernetes.default and kubernetes.default.svc.cluster.local

This will only allow Kubectl to access the API server locally, to access it through the internet and a real domain name you must add it to the file /var/snap/microk8s/current/certs/csr.conf.template, for example:

  1. [ alt_names ]
  2. DNS.1 = kubernetes
  3. DNS.2 = kubernetes.default
  4. DNS.3 = kubernetes.default.svc
  5. DNS.4 = kubernetes.default.svc.cluster
  6. DNS.5 = kubernetes.default.svc.cluster.local
  7. DNS.6 = mydomain.com

After changing, the apiserver-kicker will automatically detect the difference, generate new certs and restart the apiserver. Your DNS server settings and kubeconfig file must be updated appropriately.

Clients talking to the secure port of the API server (16443), such as the Kubectl command line utility, have to be aware of the CA (certificate-authority-data in user kubeconfig).

The authentication strategies enabled by default are:

  • Static Token File with tokens in /var/snap/microk8s/current/credentials/known_tokens.csv
  • X509 Client Certs with the client CA file set to /var/snap/microk8s/current/certs/ca.crt

Prior to version 1.19, the following strategy is also available:

  • Static Password File with password tokens and usernames stored in /var/snap/microk8s/current/credentials/basic_auth.csv

Under /var/snap/microk8s/current/credentials/ you can find the client.config kubeconfig file used by microk8s kubectl.

By default all authenticated requests are authorized as the api-server runs with --authorization-mode=AlwaysAllow. Turning on RBAC is done through microk8s enable rbac.

References

Last updated 8 months ago. Help improve this document in the forum.