-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(debug): add network/infraservice checker (first commit)
- Loading branch information
Showing
15 changed files
with
2,582 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Copyright 2021 The IOMesh Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/enescakir/emoji" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/iomesh/debugtool/pkg/infra/dns" | ||
) | ||
|
||
var infraCmd = &cobra.Command{ | ||
Use: "infra", | ||
Short: "Verify infra service such as DNS working well", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
fmt.Printf("InfraService %v\n", emoji.Joystick) | ||
dnsChecker := dns.NewDNSChecker() | ||
if err := dnsChecker.Check(); err != nil { | ||
return fmt.Errorf("Check dns fail: %v", err) | ||
} | ||
fmt.Println("") | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(infraCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Copyright 2021 The IOMesh Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/enescakir/emoji" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/iomesh/debugtool/pkg/network/cni" | ||
"github.com/iomesh/debugtool/pkg/network/hostnetwork" | ||
) | ||
|
||
// networkCmd represents the network command | ||
var networkCmd = &cobra.Command{ | ||
Use: "network", | ||
Short: "Verify connectivity and bandwidth of cni and hostnetwork", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
fmt.Printf("Network %v\n", emoji.ElectricPlug) | ||
cniChecker := cni.NewCNIChecker() | ||
if err := cniChecker.CheckConnectivity(); err != nil { | ||
return err | ||
} | ||
|
||
hostNetworkChecker := hostnetwork.NewHostNetworkChecker() | ||
if err := hostNetworkChecker.GetBandwidth(); err != nil { | ||
return err | ||
} | ||
fmt.Println("") | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(networkCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright 2021 The IOMesh Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/iomesh/debugtool/pkg/fixture" | ||
) | ||
|
||
var f = fixture.GetInstance() | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "debug", | ||
Long: `IOMesh debugtool is used to detect whether the k8s environment meets | ||
the installation conditions before installing IOMesh.`, | ||
|
||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { | ||
if cmd.Name() == "help" { | ||
return nil | ||
} | ||
return f.EnsureBasicDsDeployed() | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := networkCmd.RunE(cmd, args); err != nil { | ||
return err | ||
} | ||
if err := infraCmd.RunE(cmd, args); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
PersistentPostRunE: func(cmd *cobra.Command, args []string) error { | ||
if cmd.Name() == "help" { | ||
return nil | ||
} | ||
return f.Cleanup() | ||
}, | ||
} | ||
|
||
func Execute() { | ||
if err := rootCmd.Execute(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module github.com/iomesh/debugtool | ||
|
||
go 1.15 | ||
|
||
replace k8s.io/client-go => k8s.io/client-go v0.20.2 | ||
|
||
require ( | ||
github.com/briandowns/spinner v1.15.0 | ||
github.com/enescakir/emoji v1.0.0 | ||
github.com/go-logr/logr v0.4.0 | ||
github.com/iomesh/operator v0.9.8 | ||
github.com/spf13/cobra v1.1.1 | ||
k8s.io/api v0.20.2 | ||
k8s.io/apimachinery v0.20.2 | ||
k8s.io/cli-runtime v0.20.2 | ||
k8s.io/client-go v12.0.0+incompatible | ||
k8s.io/kubectl v0.20.2 | ||
sigs.k8s.io/controller-runtime v0.6.2 | ||
) |
Oops, something went wrong.