|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * hosted-control-planes/hcp-certificates.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="hcp-kube-api-server-cert_{context}"] |
| 7 | += Configuring the Kubernetes API server for a hosted cluster |
| 8 | + |
| 9 | +If you want to customize the Kubernetes API server for your hosted cluster, complete the following steps. |
| 10 | + |
| 11 | +.Prerequisites |
| 12 | + |
| 13 | +* You have a running hosted cluster. |
| 14 | +
|
| 15 | +* You have access to modify the `HostedCluster` resource. |
| 16 | +
|
| 17 | +* You have a custom DNS domain to use for the Kubernetes API server. |
| 18 | ++ |
| 19 | +** The custom DNS domain must be properly configured and resolvable. |
| 20 | +** The DNS domain must have valid TLS certificates configured. |
| 21 | +** Network access to the domain must be properly configured in your environment. |
| 22 | +** The custom DNS domain must be unique across your hosted clusters. |
| 23 | +
|
| 24 | +* You have a configured custom certificate. For more information, see "Configuring a custom API server certificate in a hosted cluster". |
| 25 | +
|
| 26 | +.Procedure |
| 27 | + |
| 28 | +. In your provider platform, configure the DNS record so that the `kubeAPIServerDNSName` URL points to the IP address that the Kubernetes API server is being exposed to. The DNS record must be properly configured and resolvable from your cluster. |
| 29 | ++ |
| 30 | +.Example command to configure the DNS record |
| 31 | +[source,terminal] |
| 32 | +---- |
| 33 | +$ dig + short kubeAPIServerDNSName |
| 34 | +---- |
| 35 | + |
| 36 | +. In your `HostedCluster` specification, modify the `kubeAPIServerDNSName` field, as shown in the following example: |
| 37 | ++ |
| 38 | +[source,yaml] |
| 39 | +---- |
| 40 | +apiVersion: hypershift.openshift.io/v1beta1 |
| 41 | +kind: HostedCluster |
| 42 | +metadata: |
| 43 | + name: <hosted_cluster_name> |
| 44 | + namespace: <hosted_cluster_namespace> |
| 45 | +spec: |
| 46 | + configuration: |
| 47 | + apiServer: |
| 48 | + servingCerts: |
| 49 | + namedCertificates: |
| 50 | + - names: <1> |
| 51 | + - api-custom-cert-sample-hosted.sample-hosted.example.com |
| 52 | + servingCertificate: <2> |
| 53 | + name: sample-hosted-kas-custom-cert |
| 54 | + kubeAPIServerDNSName: api-custom-cert-sample-hosted.sample-hosted.example.com <3> |
| 55 | +# ... |
| 56 | +---- |
| 57 | +<1> The list of DNS names that the certificate is valid for. The names listed in this field cannot be the same as the names specified in the `spec.servicePublishingStrategy.*hostname` field. |
| 58 | +<2> The name of the secret that contains the custom certificate. |
| 59 | +<3> This field accepts a URI that will be used as the API server endpoint. |
| 60 | + |
| 61 | +. Apply the configuration by entering the following command: |
| 62 | ++ |
| 63 | +[source,terminal] |
| 64 | +---- |
| 65 | +$ oc -f <hosted_cluster_spec>.yaml |
| 66 | +---- |
| 67 | ++ |
| 68 | +After the configuration is applied, the HyperShift Operator generates a new `kubeconfig` secret that points to your custom DNS domain. |
| 69 | + |
| 70 | +. Retrieve the `kubeconfig` secret by using the CLI or the console. |
| 71 | ++ |
| 72 | +.. To retrieve the secret by using the CLI, enter the following command: |
| 73 | ++ |
| 74 | +[source,terminal] |
| 75 | +---- |
| 76 | +$ kubectl get secret <hosted_cluster_name>-custom-admin-kubeconfig \ |
| 77 | + -n <cluster_namespace> \ |
| 78 | + -o jsonpath='{.data.kubeconfig}' | base64 -d |
| 79 | +---- |
| 80 | + |
| 81 | ++ |
| 82 | +.. To retrieve the secret by using the console, go to your hosted cluster and click **Download Kubeconfig**. |
| 83 | ++ |
| 84 | +[NOTE] |
| 85 | +==== |
| 86 | +You cannot consume the new `kubeconfig` secret by using the **show login command** option in the console. |
| 87 | +==== |
0 commit comments