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

Replace the Helm command #4852

Merged
merged 4 commits into from
Jun 27, 2022
Merged

Replace the Helm command #4852

merged 4 commits into from
Jun 27, 2022

Conversation

nioshield
Copy link
Contributor

@nioshield nioshield commented May 6, 2022

What type of PR is this?

/kind feature

What this PR does / why we need it:

Use Helm action package directly to manage Helm Releases, avoiding dependency on helm/kustomize Command.The Helm can be flexibly configured

Which issue(s) this PR fixes:

Fixes #

Special notes for reviewers:

Does this PR introduced a user-facing change?

None

Additional documentation, usage docs, etc.:


@ks-ci-bot ks-ci-bot added kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/release-note-label-needed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-ok-to-test labels May 6, 2022
@ks-ci-bot
Copy link
Collaborator

Hi @nioshield. Thanks for your PR.

I'm waiting for a kubesphere member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@xyz-li
Copy link
Contributor

xyz-li commented May 6, 2022

/ok-to-test

@wansir
Copy link
Member

wansir commented May 6, 2022

@nioshield Thanks for your contribution! The job pull-kubesphere-verify is failed, you can get more information about this, refer to https://prow.kubesphere.io/view/s3/prow-logs/pr-logs/pull/kubesphere_kubesphere/4852/pull-kubesphere-verify/1522493840206860288.

@wansir
Copy link
Member

wansir commented May 6, 2022

/cc @kubesphere/sig-apps

@xyz-li
Copy link
Contributor

xyz-li commented May 6, 2022

/cc @zheng1

@ks-ci-bot ks-ci-bot requested a review from zheng1 May 6, 2022 08:56
@nioshield
Copy link
Contributor Author

/retest

pkg/simple/client/openpitrix/helmwrapper/helm_wrapper.go Outdated Show resolved Hide resolved
pkg/simple/client/openpitrix/helmwrapper/helm_wrapper.go Outdated Show resolved Hide resolved
pkg/simple/client/openpitrix/helmwrapper/helm_wrapper.go Outdated Show resolved Hide resolved
Stdout: stdout,
}
klog.V(2).Infof("namespace: %s, name: %s, run command success", c.Namespace, c.ReleaseName)
klog.V(8).Infof("namespace: %s, name: %s, run command success, release: %v", c.Namespace, c.ReleaseName, rel)
Copy link
Contributor

Choose a reason for hiding this comment

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

rel is a struct, if we use %v to format it, the output is difficult to read.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should encode rel to string.

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,It's enough to output rel.Manifest here

Comment on lines 197 to 207
if kubeconfig != "" {
cfg, _ := clientcmd.RESTConfigFromKubeConfig([]byte(kubeconfig))
flags = genericclioptions.NewConfigFlags(false)
flags.APIServer = &cfg.Host
flags.BearerToken = &cfg.BearerToken
flags.CAFile = &cfg.CAFile
flags.WithDiscoveryBurst(cfg.Burst)
if sa := cfg.Impersonate.UserName; sa != "" {
flags.Impersonate = &sa
}
}
Copy link
Member

Choose a reason for hiding this comment

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

The following code will cause a cert error if the kubefonfig includes certificate-authority-data.

E0513 11:24:17.485511       1 helm_wrapper.go:107] namespace: z1, name: redis-emjr1v, run command failed, error: Kubernetes cluster unreachable: Get "https://10.233.0.1:443/version?timeout=32s": x509: certificate signed by unknown authority

Copy link
Member

@wansir wansir May 13, 2022

Choose a reason for hiding this comment

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

Wrapped RESTClientGetter

ttype restClientGetter struct {
	config clientcmd.ClientConfig
}

func (r *restClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig {
	return r.config
}

func (r *restClientGetter) ToRESTConfig() (*rest.Config, error) {
	return r.ToRawKubeConfigLoader().ClientConfig()
}

func (r *restClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error) {
	config, err := r.ToRESTConfig()
	if err != nil {
		return nil, err
	}
	discoveryClient, err := discovery.NewDiscoveryClientForConfig(config)
	if err != nil {
		return nil, err
	}
	clientset := memory.NewMemCacheClient(discoveryClient)
	return clientset, nil
}

Comment on lines 197 to 207
if kubeconfig != "" {
cfg, _ := clientcmd.RESTConfigFromKubeConfig([]byte(kubeconfig))
flags = genericclioptions.NewConfigFlags(false)
flags.APIServer = &cfg.Host
flags.BearerToken = &cfg.BearerToken
flags.CAFile = &cfg.CAFile
flags.WithDiscoveryBurst(cfg.Burst)
if sa := cfg.Impersonate.UserName; sa != "" {
flags.Impersonate = &sa
}
}
Copy link
Member

Choose a reason for hiding this comment

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

The following code will cause a cert error if the kubefonfig includes certificate-authority-data.

E0513 11:24:17.485511       1 helm_wrapper.go:107] namespace: z1, name: redis-emjr1v, run command failed, error: Kubernetes cluster unreachable: Get "https://10.233.0.1:443/version?timeout=32s": x509: certificate signed by unknown authority

Copy link
Contributor Author

@nioshield nioshield May 16, 2022

Choose a reason for hiding this comment

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

Thanks for your reply.the multi cluster kubeconfig havn't check err,i will fix this err.In addition how can i fast to mock a multi cluster env

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for your reply.the multi cluster kubeconfig havn't check err,i will fix this err.In addition how can i fast to mock a multi cluster env

sigs.k8s.io/controller-runtime/pkg/envtest may be helpful for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks to your help, I created the MemoryRESTClientGetter to solve this problem

@wansir
Copy link
Member

wansir commented May 23, 2022

LGTM @xyz-li Any comments?

@xyz-li
Copy link
Contributor

xyz-li commented May 25, 2022

LGTM @xyz-li Any comments?

Merge after v3.3.0 is released.

@wansir
Copy link
Member

wansir commented May 29, 2022

/hold
/lgtm

@ks-ci-bot ks-ci-bot added the lgtm Indicates that a PR is ready to be merged. label May 29, 2022
@ks-ci-bot
Copy link
Collaborator

LGTM label has been added.

Git tree hash: 4c6a057aa056469ed7cddb5af8a307a3a8cc1e3d

@zheng1
Copy link
Member

zheng1 commented Jun 27, 2022

Hi, @nioshield have you tried installing the following chart?
https://github.com/kubesphere/helm-charts/tree/master/src/main/mysql
In our previous experience, it may fail because the helm package may not be able to handle the tests folder correctly

@wansir
Copy link
Member

wansir commented Jun 27, 2022

/retest

@wansir
Copy link
Member

wansir commented Jun 27, 2022

Hi, @nioshield have you tried installing the following chart? https://github.com/kubesphere/helm-charts/tree/master/src/main/mysql In our previous experience, it may fail because the helm package may not be able to handle the tests folder correctly

I have verified this pr, it works.

@wansir
Copy link
Member

wansir commented Jun 27, 2022

/unhold
/approve

@ks-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nioshield, wansir

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

@ks-ci-bot ks-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 27, 2022
@ks-ci-bot ks-ci-bot merged commit fe992ae into kubesphere:master Jun 27, 2022
sologgfun pushed a commit to sologgfun/kubesphere that referenced this pull request Apr 24, 2023
* Replace the helm command line with helm action

* fix log misspelling

* helm wrapper formate log msg

* fix: helm action faild in multi cluster
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test release-note-none size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants