-
Notifications
You must be signed in to change notification settings - Fork 405
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
Conversation
@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. In response to this:
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. |
This function has been verified successfully. |
@yanyhui Please fix golangci-lint error |
pkg/yurtctl/cmd/convert/convert.go
Outdated
@@ -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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
pkg/yurtctl/cmd/convert/convert.go
Outdated
@@ -353,6 +380,18 @@ func (co *ConvertOptions) RunConvert() (err error) { | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
//8. deploy the yurtappmanager if required |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
pkg/yurtctl/util/kubernetes/util.go
Outdated
@@ -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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified
pkg/yurtctl/cmd/convert/convert.go
Outdated
@@ -377,6 +416,84 @@ func (co *ConvertOptions) RunConvert() (err error) { | |||
return | |||
} | |||
|
|||
func deployYurtAppManager( | |||
client *kubernetes.Clientset, | |||
cloudNodes []string, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
pkg/yurtctl/util/kubernetes/util.go
Outdated
func CreateCRDFromYaml(clientset *kubernetes.Clientset, yurtAppManagerClient dynamic.Interface, nameSpace string,filebytes []byte) error { | ||
var err error | ||
decoder := yamlutil.NewYAMLOrJSONDecoder(bytes.NewReader(filebytes), 10000) | ||
for { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
pkg/yurtctl/util/kubernetes/util.go
Outdated
for { | ||
var rawObj runtime.RawExtension | ||
if err = decoder.Decode(&rawObj); err != nil { | ||
break |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified
pkg/yurtctl/util/kubernetes/util.go
Outdated
} | ||
|
||
mapper := restmapper.NewDiscoveryRESTMapper(gr) | ||
mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before creating CRD.
pkg/yurtctl/cmd/convert/convert.go
Outdated
|
||
// 1.create the YurtAppManagerCustomResourceDefinition | ||
// 1.1 nodepool | ||
if err := kubeutil.CreateCRDFromYaml(client, yurtAppManagerClient, "",[]byte(constants.YurtAppManagerNodePool)); err != nil { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
register crd
pkg/yurtctl/util/kubernetes/util.go
Outdated
@@ -357,6 +504,23 @@ func GenClientSet(flags *pflag.FlagSet) (*kubernetes.Clientset, error) { | |||
return kubernetes.NewForConfig(restCfg) | |||
} | |||
|
|||
//add by yanyhui at 20210611 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
/lgtm |
/approve thanks @yanyhui |
[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 |
… to control automatic deployment of yurtappmanager. (openyurtio#352) * yurtctl增加参数enable-app-manager控制自动部署yurtappmanager * 代码规范修改 * 代码规范修改golangci
What type of PR is this?
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