Skip to content

Conversation

@promacanthus
Copy link
Member

When we install a cluster by kubeadm, the deployment tool will create the cluster-info ConfigMap in the kube-public namespace.

However, in some cases, there is no cluster-info ConfigMap in the kube-public namespace.

Under this scenario, the loss of ConfigMap will fail to register managed cluster to hub, and got the following error message.

can not find the cluster in the cluster-info

To resolve this problem, we can do some preflight checks, and print some useful information.

This commit adds two preflight checks:

  1. hub-api-server checker: check whether the server in kubeconfig is a domain name or not. If so, user may add HostAlias into klusterlet.
  2. cluster-info checker: check whether thecluster-info ConfigMap exists in the kube-public namespace or not.

Signed-off-by: Bowen Zhu Promacanthus@gmail.com

Signed-off-by: Bowen Zhu <Promacanthus@gmail.com>
Signed-off-by: Bowen Zhu <Promacanthus@gmail.com>
@promacanthus
Copy link
Member Author

@yue9944882 @ycyaoxdu Please review it when you have time.

@qiujian16
Copy link
Member

/assign @ycyaoxdu

Copy link
Member

@ycyaoxdu ycyaoxdu left a comment

Choose a reason for hiding this comment

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

My Apology for the delay, and thanks a lot for contributing! @promacanthus


preflight is not a command to use, so we can not just put it into pkg/cmd, since it is used in command init, shall we make it a subdirectory of pkg/cmd/init?

name: ocm-hub
current-context: ocm-hub
users:
- name: user-admin No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

No new line at end of file

name: ocm-hub
current-context: ocm-hub
users:
- name: user-admin No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

No new line at end of file

func (f *ClusteradmFlags) AddFlags(flags *pflag.FlagSet) {
flags.BoolVar(&f.DryRun, "dry-run", false, "If set the generated resources will be displayed but not applied")
flags.IntVar(&f.Timeout, "timeout", 300, "extend timeout from 300 secounds ")
flags.StringVar(&f.Context, "context", "", "The name of the kubeconfig context to use")
Copy link
Member

Choose a reason for hiding this comment

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

kubectl have already provide a flag --context to specify which context to use, maybe you can't use the flag context here? wondering whether this will override the kubectl flag? or do we need to do something to handle this?

Copy link
Member Author

Choose a reason for hiding this comment

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

kubectl have already provide a flag --context to specify which context to use, maybe you can't use the flag context here? wondering whether this will override the kubectl flag? or do we need to do something to handle this?

I did not think about that before. I think we can get context from kubectl flag --context.

@promacanthus
Copy link
Member Author

My Apology for the delay, and thanks a lot for contributing! @promacanthus

preflight is not a command to use, so we can not just put it into pkg/cmd, since it is used in command init, shall we make it a subdirectory of pkg/cmd/init?

Agreed with you, I will move it into pkg/cmd/init.

Signed-off-by: Bowen Zhu <Promacanthus@gmail.com>
Copy link
Member

@ycyaoxdu ycyaoxdu left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jul 24, 2022
@ycyaoxdu
Copy link
Member

looks good to me, any suggestions? @qiujian16

@qiujian16
Copy link
Member

/approve

@openshift-ci
Copy link

openshift-ci bot commented Jul 25, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Promacanthus, qiujian16, ycyaoxdu

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-merge-robot openshift-merge-robot merged commit 7a41de5 into open-cluster-management-io:main Jul 25, 2022
@promacanthus promacanthus deleted the feat/preflight_check branch July 26, 2022 02:28
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.

4 participants