Generating additional kubeconfig files for remote access
To support more host names or IP addresses for remote access than the default file provides, you can generate additional kubeconfig files in MicroShift. Add the entries to apiServer.subjectAltNames in config.yaml and restart the service to create the files.
|
|
You must restart MicroShift for configuration changes to be implemented. |
-
You have created a
config.yamlfile for MicroShift.
-
Optional: You can show the contents of the
config.yaml. Run the following command:$ cat /etc/microshift/config.yaml -
Optional: You can show the contents of the remote-access
kubeconfigfile. Run the following command:$ cat /var/lib/microshift/resources/kubeadmin/<hostname>/kubeconfigAdditional remote access
kubeconfigfiles must include one of the server names listed in the {product-title}config.yamlfile. Additionalkubeconfigfiles must also use the same CA for validation. -
To generate additional
kubeconfigfiles for additional DNS names SANs or external IP addresses, add the entries you need to theapiServer.subjectAltNamesfield. In the following example, the DNS name used isalt-name-1and the IP address is1.2.3.4.Exampleconfig.yamlwith additional authentication valuesdns: baseDomain: example.com node: hostnameOverride: "microshift-rhel9" nodeIP: 10.0.0.1 apiServer: subjectAltNames: - alt-name-1 - 1.2.3.4where:
microshift-rhel9-
Specifies the hostname of the node.
alt-name-1-
Specifies the DNS name.
1.2.3.4-
Specifies the IP address or range.
-
Restart MicroShift to apply configuration changes and auto-generate the
kubeconfigfiles you need by running the following command:$ sudo systemctl restart microshift -
To check the contents of additional remote-access
kubeconfigfiles, insert the name or IP address as listed in theconfig.yamlinto thecatcommand. For example,alt-name-1is used in the following example command:$ cat /var/lib/microshift/resources/kubeadmin/alt-name-1/kubeconfig -
Choose the
kubeconfigfile to use that contains the SAN or IP address you want to use to connect your node. In this example, thekubeconfigcontainingalt-name-1in theclusters.cluster.serverfield is the correct file.Example contents of an additionalkubeconfigfileclusters: - cluster: certificate-authority-data: <base64 CA> server: https://alt-name-1:6443-
The
/var/lib/microshift/resources/kubeadmin/alt-name-1/kubeconfigfile values are from theapiServer.subjectAltNamesconfiguration values.All parameters are included as common names (CN) and subject alternative names (SAN) in the external serving certificates for the API server.
-