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

[customcluster] fix configContent is nil bug #361

Merged
merged 1 commit into from Jul 21, 2023

Conversation

Xieql
Copy link
Contributor

@Xieql Xieql commented Jul 13, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

If the ControlPlaneConfig parameter is not set, a null pointer exception will occur. Therefore, it is necessary to check its existence in the code.

Other variables were also checked in a similar manner. However, since they are mandatory and guaranteed to be non-nil during the admission phase, no changes were required.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix configContent in customcluster is nil bug

Signed-off-by: Xieql <xieqianglong@huawei.com>
@netlify
Copy link

netlify bot commented Jul 13, 2023

Deploy Preview for kurator-dev canceled.

Name Link
🔨 Latest commit 6edcf76
🔍 Latest deploy log https://app.netlify.com/sites/kurator-dev/deploys/64affa00ccb4780007b6b604

if cc.Spec.ControlPlaneConfig != nil {
configContent.ControlPlaneCertSANs = strings.Join(cc.Spec.ControlPlaneConfig.CertSANs, ",")
configContent.ControlPlaneAddress = cc.Spec.ControlPlaneConfig.Address
configContent.LoadBalancerDomainName = cc.Spec.ControlPlaneConfig.LoadBalancerDomainName
Copy link
Member

Choose a reason for hiding this comment

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

just one questiom: do we allow these fields to be empty?
ControlPlaneConfig.CertSANs
ControlPlaneConfig.Address
ControlPlaneConfig.LoadBalancerDomainName

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, these fields could be left empty under certain circumstances. Here is the interpretation of each field being empty:

ControlPlaneConfig.CertSANs: If this field is empty, it indicates that the user has not specified any additional Subject Alternative Names for the Kubernetes API Server certificate. This is suitable for simple deployments where the API server is accessed from a single and unchanging address, typically the address of the first master node.

ControlPlaneConfig.Address: If this field is empty, Kubespray will default to using the IP address of the first master node listed in the configuration as the Control Plane (API Server) address. This is often the case for straightforward, non-HA deployments where there's no need for a load balancer to distribute traffic among multiple master nodes.

ControlPlaneConfig.LoadBalancerDomainName: If this field is empty, it means that the user has not specified a domain name for a load balancer. This is fine for deployments where a load balancer is not used, or where access to the API Server is only required via IP address.

In summary, if you are deploying in a simple environment, such as for testing or development purposes where a single master node without a load balancer or HA mode is sufficient, you can leave the ControlPlaneConfig fields empty. The system will apply default settings that allow for quick and easy setup of a on-premise Kubernetes cluster. However, for more complex or production environments, it's recommended to carefully consider and appropriately set these fields.

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@kurator-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

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

@kurator-bot kurator-bot merged commit 32989dc into kurator-dev:main Jul 21, 2023
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants