I am working on rebuilding my Kubernetes cluster with containerd as the CRI. I have to use an init file to specify the cgroup. Which means I can't specify the endpoint as an argument.

After much hunting on the Kubernetes documentation I could not find out how or where to specify the control plane endpoint in the init file. The information was just not there in their regular docs.

But, alas, I figured it out by digging through the API spec: https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2#ClusterConfiguration

In your init file you need to have a ClusterConfiguration section. In there it needs a controlPlaneEndpoint value. A minimal config would look like this:

apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
kubernetesVersion: stable
controlPlaneEndpoint: "kubecp.example.com:6443"

That's it. Now with my kubeadm init --config ./kubeconfig.yaml it adds that hostname to the certificate and shows the correct URL when printing out the details to join additional control planes:

You can now join any number of control-plane nodes by copying certificate authorities
and service account keys on each node and then running the following as root:

  kubeadm join kubecp.example.com:6443 --token #### \
    --discovery-token-ca-cert-hash sha256:##### \
    --control-plane

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join kubecp.example.com:6443 --token ##### \
    --discovery-token-ca-cert-hash sha256:#####

Conclusion

It was annoying that the controlPlaneEndpoint didn't show up in the dump of default configs.