Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOSTEDCP-1960: Add KubeAPIExteralName api #5458

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jparrill
Copy link
Contributor

@jparrill jparrill commented Jan 22, 2025

This new API autogenerate a new kubeconfig based on a desired url and managed by HCP.

What this PR does / why we need it:
The current implementation of HCP to define the KAS address is using the ServicePublishingType, where you can define a hostname and that, will customize the API and API-INT interfaces where all the kubeconfigs (excepts the ones pointing to local) are pointing to. This makes the customization rigid and customers are asking for more flexibility.

This PR adds a new API which creates a new Kubeconfig (certificate based) pointing to the desired address. With this new API you can:

  • Modify the address day-1 and day-2 without affectation of the DataPlane (No rollout expected)
  • Generation of a new Kubeconfig based on certificates (managed by HCP)
  • The HC and HCP are in sync about this new Kubeconfig and reported in the status as customKubeconfig
  • The target of this new API are the scenarios of Public and PublicAndPrivate

⚠️ IMPORTANT! The external DNSs URL where you plan to point to and you will specify it in this new API, should be properly configured in order to makes this work.

Which issue(s) this PR fixes:

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 22, 2025
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 22, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 22, 2025

@jparrill: This pull request references HOSTEDCP-1960 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

This new API changes the value of the Kubeconfig External URL to points to your desired one

What this PR does / why we need it:
HostedControlPlanes does not follows the separation of API and API-INT as OCP Standalone does. This PR includes a new API called KubeAPIExteralName which takes the desired name for the external KubeAPI Server name.

To have in mind:

  • This can be changed day-0 or day-2
  • This will not cause a nodepool rollout
  • This will generate a new Kubeconfig called apiext-admin-kubeconfig
  • This Kubeconfig should be bubbled up into HC namespace too

Which issue(s) this PR fixes:

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Contributor

openshift-ci bot commented Jan 22, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added do-not-merge/needs-area area/api Indicates the PR includes changes for the API area/cli Indicates the PR includes changes for CLI area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release and removed do-not-merge/needs-area labels Jan 22, 2025
Copy link
Contributor

openshift-ci bot commented Jan 22, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jparrill

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added area/documentation Indicates the PR includes changes for documentation approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 22, 2025
@openshift-ci openshift-ci bot added the area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release label Jan 22, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 23, 2025

@jparrill: This pull request references HOSTEDCP-1960 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

This new API changes the value of the Kubeconfig External URL to points to your desired one

What this PR does / why we need it:
HostedControlPlanes does not follows the separation of API and API-INT as OCP Standalone does. This PR includes a new API called KubeAPIExteralName which takes the desired name for the external KubeAPI Server name.

To have in mind:

  • This can be changed day-0 or day-2
  • This will not cause a nodepool rollout
  • This will generate a new Kubeconfig called apiext-admin-kubeconfig
  • This Kubeconfig is bubbled up into HC namespace too

Which issue(s) this PR fixes:

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 23, 2025

@jparrill: This pull request references HOSTEDCP-1960 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

This new API changes the value of the Kubeconfig External URL to points to your desired one

What this PR does / why we need it:
HostedControlPlanes does not follows the separation of API and API-INT as OCP Standalone does. This PR includes a new API called KubeAPIExteralName which takes the desired name for the external KubeAPI Server name.

To have in mind:

  • This can be changed day-1 or day-2
  • This will not cause a nodepool rollout
  • This will generate a new Kubeconfig called apiext-admin-kubeconfig
  • This Kubeconfig is bubbled up into HC namespace too

Which issue(s) this PR fixes:

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jparrill jparrill force-pushed the HOSTEDCP-1960 branch 2 times, most recently from 5152979 to 0ecdf6a Compare January 24, 2025 17:37
@enxebre
Copy link
Member

enxebre commented Jan 27, 2025

HostedControlPlanes does not follows the separation of API and API-INT

Can we elaborate on this? Which topologies is this use case targeting: privateAndPublic, private, public?
For privateAndPublic we do have decouple internal and external urls routing to kas, so what's this solving?
Seems the PR is effectively implementing a kubeconfig autogeneration using a passed through URL, let's make sure that's clearly stated in the PR desc and API docs, also let's clarify how this is planned to be consumed and that consumption solves the driving rfe.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 28, 2025

@jparrill: This pull request references HOSTEDCP-1960 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

This new API autogenerate a new kubeconfig based on a desired url and managed by HCP.

What this PR does / why we need it:
The current implementation of HCP to define the KAS address is using the ServicePublishingType, where you can define a hostname and that, will customize the API and API-INT interfaces where all the kubeconfigs (excepts the ones pointing to local) are pointing to. This makes the customization rigid and customers are asking for more flexibility.

This PR adds a new API which creates a new Kubeconfig (certificate based) pointing to the desired address. With this new API you can:

  • Modify the address day-1 and day-2 without affectation of the DataPlane (No rollout expected)
  • Generation of a new Kubeconfig based on certificates (managed by HCP)
  • The HC and HCP are in sync about this new Kubeconfig and reported in the status as customKubeconfig
  • The target of this new API are the scenarios of Public and PublicAndPrivate

⚠️ IMPORTANT! The external DNSs URL where you plan to point to and you will specify it in this new API, should be properly configured in order to makes this work.

Which issue(s) this PR fixes:

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jparrill jparrill marked this pull request as ready for review January 29, 2025 09:19
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 29, 2025
@jparrill jparrill requested a review from enxebre January 29, 2025 09:19
@openshift-ci openshift-ci bot requested a review from isco-rodriguez January 29, 2025 09:19
@jparrill jparrill force-pushed the HOSTEDCP-1960 branch 2 times, most recently from f68c435 to 1fd6696 Compare January 29, 2025 11:10
Copy link
Contributor

@csrwng csrwng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits in the API. In general, please use consistent case for "kubeconfig" wherever it appears in the API.

// +optional
CustomKubeConfig *KubeconfigSecretRef `json:"customkubeconfig,omitempty"`

// kubeApiCustomName specifies the external name for the Kube API Server service.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/kubeApiCustomName/kubeAPICustomName

@@ -115,6 +115,10 @@ type HostedControlPlaneSpec struct {
// +optional
KubeConfig *KubeconfigSecretRef `json:"kubeconfig,omitempty"`

// KubeAPICustomKubeconfig is a group that encompasses an additional KAS server address and the customKubeconfig generated for the kube-apiserver.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

@@ -300,6 +324,12 @@ type HostedControlPlaneStatus struct {
// for this control plane.
KubeConfig *KubeconfigSecretRef `json:"kubeConfig,omitempty"`

// CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

@@ -432,6 +432,15 @@ type HostedClusterSpec struct {
// +required
Platform PlatformSpec `json:"platform"`

// kubeApiCustomName specifies the external name for the Kube API Server service.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/kubeApiCustomName/kubeAPICustomName/

@@ -1423,6 +1432,13 @@ type HostedClusterStatus struct {
// +optional
KubeConfig *corev1.LocalObjectReference `json:"kubeconfig,omitempty"`

// CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

This new API changes the value of the Kubeconfig External URL to points to your desired one

Signed-off-by: Juan Manuel Parrilla Madrid <[email protected]>
Copy link
Contributor

openshift-ci bot commented Jan 29, 2025

@jparrill: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-e2e-aws-ovn 22b1bdb link false /test okd-scos-e2e-aws-ovn
ci/prow/e2e-aks 22b1bdb link true /test e2e-aks
ci/prow/e2e-aws-upgrade-hypershift-operator 22b1bdb link true /test e2e-aws-upgrade-hypershift-operator
ci/prow/e2e-aws 22b1bdb link true /test e2e-aws

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

func adaptCustomAdminKubeconfigSecret(cpContext component.WorkloadContext, secret *corev1.Secret) error {
hcp := cpContext.HCP

if hcp.Spec.KubeConfig != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you want hcp.Spec.KubeAPICustomKubeconfig != nil here, right?

@@ -90,6 +90,29 @@ func adaptDeployment(cpContext component.WorkloadContext, deployment *appsv1.Dep
return nil
}

func adaptCustomAdminKubeconfigSecret(cpContext component.WorkloadContext, secret *corev1.Secret) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move this function to kubeconfig.go file


// EnableIfCustomKubeconfig is a helper predicate for the common use case of enabling a resource when a KubeAPICustomKubeconfig is specified.
func EnableIfCustomKubeconfig() option {
return WithPredicate(func(cpContext WorkloadContext) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any other component will use this predicate other than kas.
let's move it to the kas package where its used.
See this as an example https://github.com/muraee/hypershift/blob/karpenter-userdata/control-plane-operator/controllers/hostedcontrolplane/v2/cno/component.go#L47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/api Indicates the PR includes changes for the API area/cli Indicates the PR includes changes for CLI area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/documentation Indicates the PR includes changes for documentation area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants