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

New function development -- yurtctl adds parameter enable app manager to control automatic deployment of yurtappmanager. #352

Merged
merged 3 commits into from
Jun 21, 2021

Conversation

yanyhui
Copy link
Member

@yanyhui yanyhui commented Jun 12, 2021

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:
/kind bug
/kind documentation
/kind enhancement
/kind good-first-issue
/kind feature
/kind question
/kind design
/sig ai
/sig iot
/sig network
/sig storage
/sig storage
/kind feature

What this PR does / why we need it:

New function development.

Which issue(s) this PR fixes:

Fixes #340

Special notes for your reviewer:

Does this PR introduce a user-facing change?


other Note

@openyurt-bot
Copy link
Collaborator

@yanyhui: GitHub didn't allow me to assign the following users: your_reviewer.

Note that only openyurtio members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:
/kind bug
/kind documentation
/kind enhancement
/kind good-first-issue
/kind feature
/kind question
/kind design
/sig ai
/sig iot
/sig network
/sig storage
/sig storage
/kind feature

What this PR does / why we need it:

New function development.

Which issue(s) this PR fixes:

Fixes #340

Special notes for your reviewer:

Does this PR introduce a user-facing change?


other Note

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.

@yanyhui
Copy link
Member Author

yanyhui commented Jun 12, 2021

This function has been verified successfully.

@rambohe-ch
Copy link
Member

@yanyhui Please fix golangci-lint error

@rambohe-ch
Copy link
Member

/assign @kadisi @Peeknut

@@ -38,6 +38,7 @@ import (
"github.com/openyurtio/openyurt/pkg/yurtctl/lock"
kubeutil "github.com/openyurtio/openyurt/pkg/yurtctl/util/kubernetes"
strutil "github.com/openyurtio/openyurt/pkg/yurtctl/util/strings"
"k8s.io/client-go/dynamic"
Copy link
Member

Choose a reason for hiding this comment

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

import order needs to be modified

Copy link
Member Author

Choose a reason for hiding this comment

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

modified

cmd.Flags().BoolP("enable-app-manager", "e", false,
"if set, yurtappmanager will be deployed.")
cmd.Flags().String("yurt-app-manager-image",
"openyurt/yurt-app-manager:v0.4.0",
Copy link
Member

Choose a reason for hiding this comment

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

I think use tag latest is better.

Copy link
Member Author

Choose a reason for hiding this comment

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

The latest version image can't be used without updating. Now we all use the version of v0.4.0.

@@ -353,6 +380,18 @@ func (co *ConvertOptions) RunConvert() (err error) {
if err != nil {
return err
}

//8. deploy the yurtappmanager if required
Copy link
Member

Choose a reason for hiding this comment

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

The codes before and after "deploy the yurtappmanager" all belong to step7. How about move it behind step6?

Copy link
Member Author

Choose a reason for hiding this comment

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

Step 7 and "deploy the yurtappmanager" are separate processes and have no impact, so I don't think we need to put them before step 7.

@@ -50,6 +50,14 @@ import (
"github.com/openyurtio/openyurt/pkg/yurtctl/constants"
strutil "github.com/openyurtio/openyurt/pkg/yurtctl/util/strings"
tmplutil "github.com/openyurtio/openyurt/pkg/yurtctl/util/templates"
"bytes"
Copy link
Member

Choose a reason for hiding this comment

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

import order needs to be modified

Copy link
Member Author

Choose a reason for hiding this comment

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

modified

@@ -377,6 +416,84 @@ func (co *ConvertOptions) RunConvert() (err error) {
return
}

func deployYurtAppManager(
client *kubernetes.Clientset,
cloudNodes []string,
Copy link
Member

Choose a reason for hiding this comment

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

The parameter cloudNodes is not used and can be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a good idea. I found that this parameter was not used at that time.

func CreateCRDFromYaml(clientset *kubernetes.Clientset, yurtAppManagerClient dynamic.Interface, nameSpace string,filebytes []byte) error {
var err error
decoder := yamlutil.NewYAMLOrJSONDecoder(bytes.NewReader(filebytes), 10000)
for {
Copy link
Member

Choose a reason for hiding this comment

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

Why use a for loop?

Copy link
Member Author

Choose a reason for hiding this comment

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

delete

for {
var rawObj runtime.RawExtension
if err = decoder.Decode(&rawObj); err != nil {
break
Copy link
Member

Choose a reason for hiding this comment

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

Why use break instead of return err?

Copy link
Member Author

Choose a reason for hiding this comment

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

modified

}

mapper := restmapper.NewDiscoveryRESTMapper(gr)
mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version)
Copy link
Member

Choose a reason for hiding this comment

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

When was the gvk information of crd registered?

Copy link
Member Author

Choose a reason for hiding this comment

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

Before creating CRD.


// 1.create the YurtAppManagerCustomResourceDefinition
// 1.1 nodepool
if err := kubeutil.CreateCRDFromYaml(client, yurtAppManagerClient, "",[]byte(constants.YurtAppManagerNodePool)); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

It seems like the func CreateCRDFromYaml is to create a cr. However, it's used to register crd here.

Copy link
Member Author

Choose a reason for hiding this comment

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

register crd

@@ -357,6 +504,23 @@ func GenClientSet(flags *pflag.FlagSet) (*kubernetes.Clientset, error) {
return kubernetes.NewForConfig(restCfg)
}

//add by yanyhui at 20210611
Copy link
Member

Choose a reason for hiding this comment

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

It is better to delete the comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

delete

@Peeknut
Copy link
Member

Peeknut commented Jun 18, 2021

/lgtm

@kadisi
Copy link
Member

kadisi commented Jun 21, 2021

/approve

thanks @yanyhui

@openyurt-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kadisi, yanyhui

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

@openyurt-bot openyurt-bot added the approved approved label Jun 21, 2021
@openyurt-bot openyurt-bot merged commit ced11b7 into openyurtio:master Jun 21, 2021
MrGirl pushed a commit to MrGirl/openyurt that referenced this pull request Mar 29, 2022
… to control automatic deployment of yurtappmanager. (openyurtio#352)

* yurtctl增加参数enable-app-manager控制自动部署yurtappmanager

* 代码规范修改

* 代码规范修改golangci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Yurtctl adds the parameter enable-app-manager to specify the deployment of yurt app manager.
5 participants