-
Notifications
You must be signed in to change notification settings - Fork 111
kmeshctl install #978
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
base: main
Are you sure you want to change the base?
kmeshctl install #978
Conversation
Welcome @thebigbone! It looks like this is your first PR to kmesh-net/kmesh 🎉 |
ctl/main.go
Outdated
@@ -43,6 +44,7 @@ func main() { | |||
rootCmd.AddCommand(waypoint.NewCmd()) | |||
rootCmd.AddCommand(version.NewCmd()) | |||
rootCmd.AddCommand(accesslog.NewCmd()) | |||
rootCmd.AddCommand(install.NewCmd()) |
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.
Also need to update doc when this PR get merged.
ctl/install/install.go
Outdated
log.Fatal(err) | ||
} | ||
|
||
kubeconfig := os.Getenv("HOME") + "/.kube/config" |
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.
Use existing (tools)[https://github.com/kmesh-net/kmesh/blob/main/ctl/utils/utils.go#L31] to create k8s client direclty which has built-in method for applying yaml files.
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.
So, I should remove the custom doServerSideApply function?
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 you could.
@@ -0,0 +1,167 @@ | |||
package install |
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.
Add copyright
ctl/install/install.go
Outdated
"log" | ||
"os" | ||
|
||
"k8s.io/apimachinery/pkg/api/meta" |
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.
Arrange the dependency order, put the standard lib together, put Kmesh lib together and put third-party dependencies together.
ctl/install/install.go
Outdated
func NewCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "install", | ||
Short: "install kmesh with all the resources", |
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.
Add examples, refer to other subcommands.
ctl/install/install.go
Outdated
panic(err.Error()) | ||
} | ||
|
||
resources := []Resource{ |
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 not just apply all files in the yaml
diretory instead of listing each files which may change in the future?
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.
How would that work?
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.
You could get all yaml contents and call this function
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 don't know if there is an elegant way to direclty get the contents of all files under yaml directory or to know which files are in this directory and download them one by one.
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 don't know if there is an elegant way to direclty get the contents of all files under yaml directory or to know which files are in this directory and download them one by one.
curl -s "https://api.github.com/repos/kmesh-net/kmesh/contents/deploy/yaml" | jq -r '.[] | .download_url'
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 ApplyYAMLContents
function works fine but it requires namespace argument. For now, I can separate the kmesh-system
and istio
but it can break in the future because there could be a new yaml file with a different namespace.
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 you could specify namespace as "", so that it will direcly use the ns specified in yaml.
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.
Oh, that's helpful. I was parsing the namespace field in every file.
ctl/install/install.go
Outdated
{Name: "serviceAccount", URL: getURL(version, "serviceaccount.yaml")}, | ||
} | ||
|
||
fmt.Println("using version: ", 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.
nit:install kmesh version:
Codecov ReportAll modified and coverable lines are covered by tests ✅
see 35 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
# Install a specific version of kmesh | ||
kmeshctl install --version 0.5`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
version, err := cmd.Flags().GetString("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.
We still have issue #949.
@YaoZengzeng Has this problem been fixed?
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.
No, I hope this issue could be fixed with the solution of #892, but it seems that this problem is not being addressed now. If no one has dealt it by then, I will fix it.
ctl/install/install.go
Outdated
|
||
deployYaml, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
log.Fatalf("yamlFile.Get err #%v ", 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.
log.Fatalf("yamlFile.Get err #%v ", err) | |
log.Fatalf("yamlFile.Get err: %v ", err) |
ctl/install/install.go
Outdated
func NewCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "install", | ||
Short: "install kmesh with all the resources", |
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.
Descriptive content use Kmesh
, with the first letter capitalized.
The overall framework seems fine for me, @hzxuzhonghu PTAL. |
ctl/install/install.go
Outdated
func getYAMLFile(version string) string { | ||
var url string | ||
if version != "main" { | ||
url = fmt.Sprintf("https://api.github.com/repos/kmesh-net/kmesh/contents/deploy/yaml?ref=release-%s", 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.
I donot think this is quite correct, because?:
- we didn't update the image tag
- should not use the github branch, but use the tag instead
So in short should we use helm chart https://github.com/kmesh-net/kmesh/releases/download/v0.5.0/kmesh-helm-v0.5.0.tgz
or the OCI chart image https://github.com/orgs/kmesh-net/packages/container/package/kmesh-helm
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 using release tag? Using helm will introduce new dependency which is totally unnecessary.
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.
See the released version above
ping @hzxuzhonghu |
please see above comment, when you set version-=0.5, then you will install kmesh with latest image https://github.com/kmesh-net/kmesh/blob/release-0.5/deploy/yaml/kmesh.yaml#L72 This is not expected, can you replace that image? I would suggest we support v0.5.0 or 0.5.0 rather than 0.5, see our releases |
Should I just replace the image and get the yaml files from |
This probably not work, think of the case that a yaml is updated because of some new features. The old image may cannot work with the new daemonset yaml |
Signed-off-by: thebigbone <[email protected]>
Signed-off-by: thebigbone <[email protected]>
Signed-off-by: thebigbone <[email protected]>
Signed-off-by: thebigbone <[email protected]>
Signed-off-by: thebigbone <[email protected]>
Signed-off-by: thebigbone <[email protected]>
Co-authored-by: Tiger Xu / Zhonghu Xu <[email protected]> Signed-off-by: thebigbone <[email protected]>
Signed-off-by: thebigbone <[email protected]>
Removed the branch and instead using tags now. |
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.
/lgtm
YOu can fix it later
if err != nil { | ||
log.Fatal(err) | ||
} | ||
defer resp.Body.Close() |
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.
nit: not use defer in a for loop
[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 |
New changes are detected. LGTM label has been removed. |
Adding label 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. |
The kube package was changed so it's not able to find |
Can you implement this method? Or use helm client https://github.com/kurator-dev/kurator/blob/ac68f35c8799773aea22643e39ca032a20e65fb7/pkg/client/client.go#L66 |
@thebigbone This PR can be merged after you pass CI. |
Should I use the istio's implementation directly in |
ping @LiZhenCheng9527 |
log.Fatal(err) | ||
} | ||
} else { | ||
err = cli.ApplyYAMLContents("", combinedYAMLFile) |
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.
There is no ApplyYamlContents in kmesh's kube pkg.
After fixing this problem, this PR can be merged.
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.
Yes, which is why I asked if I should use the istio's implementation or the previous doServerSideApply function which I used at the beginning.
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.
Perhaps we can implement applyYamlContents in Kmesh. If that doesn't work, we can switch back to the doServerSideApply function.
I have implemented the method @LiZhenCheng9527 |
What type of PR is this?
/kind feature
What this PR does / why we need it:
adds install command for
kmeshctl
which will install all the resources for kmesh in a k8s clusterWhich issue(s) this PR fixes:
Fixes #552
Does this PR introduce a user-facing change?: