Add gitignore and delete ke
This commit is contained in:
parent
a30a6efc92
commit
024eb37e87
|
@ -0,0 +1,38 @@
|
|||
# OSX leaves these everywhere on SMB shares
|
||||
._*
|
||||
|
||||
# OSX trash
|
||||
.DS_Store
|
||||
|
||||
# Eclipse files
|
||||
.classpath
|
||||
.project
|
||||
.settings/**
|
||||
|
||||
# Files generated by JetBrains IDEs, e.g. IntelliJ IDEA
|
||||
.idea/
|
||||
*.iml
|
||||
.bin/
|
||||
|
||||
# Vscode files
|
||||
.vscode
|
||||
|
||||
# This is where the result of the go build goes
|
||||
/output*/
|
||||
/_output*/
|
||||
/_output
|
||||
|
||||
# Emacs save files
|
||||
*~
|
||||
\#*\#
|
||||
.\#*
|
||||
|
||||
# Vim-related files
|
||||
[._]*.s[a-w][a-z]
|
||||
[._]s[a-w][a-z]
|
||||
*.un~
|
||||
Session.vim
|
||||
.netrwhist
|
||||
|
||||
# Generate by makefile
|
||||
bin
|
|
@ -1,2 +0,0 @@
|
|||
# Default ignored files
|
||||
/workspace.xml
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/kubeye.iml" filepath="$PROJECT_DIR$/.idea/kubeye.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -7,6 +7,8 @@ Quickly get cluster core component status and cluster size information and abnor
|
|||
|
||||
1、Install Node-problem-Detector in the inspection cluster
|
||||
|
||||
> Note: The NPD module does not need to be installed when no node information needs to be probed.
|
||||
|
||||
* Create a ConfigMap file for Node-Problem-Detector, which contains fault patrol rules and can be added by the user [npd-config.yaml](./docs/npd-config.yaml).
|
||||
`kubectl apply -f npd-config.yaml`
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
|
||||
"os"
|
||||
"sigs.k8s.io/yaml"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Cluster(ctx context.Context) (int, error) {
|
||||
|
@ -20,12 +19,12 @@ func Cluster(ctx context.Context) (int, error) {
|
|||
fmt.Println("do not get cluster information")
|
||||
}
|
||||
|
||||
componentStatusResult, err := ComponentStatusResult(k.ComponentStatus)
|
||||
BasicComponentStatus, err := ComponentStatusResult(k.ComponentStatus)
|
||||
if err != nil {
|
||||
fmt.Println("do not get componentStatus")
|
||||
}
|
||||
|
||||
problemDetector, err := ProblemDetectorResult(k.ProblemDetector)
|
||||
clusterCheckResults, err := ProblemDetectorResult(k.ProblemDetector)
|
||||
if err != nil {
|
||||
fmt.Println("do not get problemDetector")
|
||||
}
|
||||
|
@ -43,19 +42,19 @@ func Cluster(ctx context.Context) (int, error) {
|
|||
}
|
||||
|
||||
auditData := AuditData{
|
||||
AuditTime: k.CreationTime.Format(time.RFC3339),
|
||||
AuditAddress: k.AuditAddress,
|
||||
ComponentStatus: componentStatusResult,
|
||||
ClusterInfo: ClusterInfo{
|
||||
// AuditTime: k.CreationTime.Format(time.RFC3339),
|
||||
// AuditAddress: k.AuditAddress,
|
||||
BasicComponentStatus: BasicComponentStatus,
|
||||
BasicClusterInformation: BasicClusterInformation{
|
||||
K8sVersion: k.ServerVersion,
|
||||
PodNum: len(k.Pods),
|
||||
NodeNum: len(k.Nodes),
|
||||
NamespaceNum: len(k.Namespaces),
|
||||
},
|
||||
|
||||
GoodPractice: goodPractice,
|
||||
NodeStatus: nodeStatus,
|
||||
ProblemDetector: problemDetector,
|
||||
ClusterConfigurationResults: goodPractice,
|
||||
AllNodeStatusResults: nodeStatus,
|
||||
ClusterCheckResults: clusterCheckResults,
|
||||
}
|
||||
|
||||
jsonBytes, err := json.Marshal(auditData)
|
||||
|
@ -71,33 +70,33 @@ func ComponentStatusResult(cs []v1.ComponentStatus) (interface{}, error) {
|
|||
}
|
||||
return cr, nil
|
||||
}
|
||||
func ProblemDetectorResult(event []v1.Event) ([]ProblemDetector, error) {
|
||||
var pdrs []ProblemDetector
|
||||
for j := 0; j < len(event); j++{
|
||||
if event[j].Type == "Warning" {
|
||||
pdr := ProblemDetector{
|
||||
func ProblemDetectorResult(event []v1.Event) ([]ClusterCheckResults, error) {
|
||||
var pdrs []ClusterCheckResults
|
||||
for j := 0; j < len(event); j++ {
|
||||
if event[j].Type == "Warning" {
|
||||
pdr := ClusterCheckResults{
|
||||
Namespace: event[j].ObjectMeta.Namespace,
|
||||
Name: event[j].ObjectMeta.Name,
|
||||
Name: event[j].ObjectMeta.Name,
|
||||
EventTime: event[j].LastTimestamp.Time,
|
||||
Reason: event[j].Reason,
|
||||
Message: event[j].Message,
|
||||
Reason: event[j].Reason,
|
||||
Message: event[j].Message,
|
||||
}
|
||||
pdrs = append(pdrs, pdr)
|
||||
}
|
||||
}
|
||||
return pdrs, nil
|
||||
}
|
||||
func NodeStatusResult(nodes []v1.Node) ([]NodeStatus, error) {
|
||||
var nodestatus []NodeStatus
|
||||
for k :=0; k < len(nodes); k++{
|
||||
nodestate := NodeStatus{
|
||||
Name: nodes[k].ObjectMeta.Name,
|
||||
func NodeStatusResult(nodes []v1.Node) ([]AllNodeStatusResults, error) {
|
||||
var nodestatus []AllNodeStatusResults
|
||||
for k := 0; k < len(nodes); k++ {
|
||||
nodestate := AllNodeStatusResults{
|
||||
Name: nodes[k].ObjectMeta.Name,
|
||||
HeartbeatTime: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].LastHeartbeatTime.Time,
|
||||
Status: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Status,
|
||||
Reason: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Reason,
|
||||
Message: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Message,
|
||||
Status: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Status,
|
||||
Reason: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Reason,
|
||||
Message: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Message,
|
||||
}
|
||||
nodestatus = append(nodestatus, nodestate)
|
||||
}
|
||||
return nodestatus, nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,57 +7,56 @@ import (
|
|||
)
|
||||
|
||||
type AuditData struct {
|
||||
AuditTime string
|
||||
AuditAddress string
|
||||
ClusterInfo ClusterInfo
|
||||
ComponentStatus interface{}
|
||||
ProblemDetector []ProblemDetector
|
||||
GoodPractice []PodResult
|
||||
NodeStatus []NodeStatus
|
||||
//AuditTime string `yaml:"auditTime" json:"auditTime,omitempty"`
|
||||
//AuditAddress string `yaml:"auditAddress" json:"auditAddress,omitempty"`
|
||||
BasicClusterInformation BasicClusterInformation `yaml:"basicClusterInformation" json:"basicClusterInformation,omitempty"`
|
||||
BasicComponentStatus interface{} `yaml:"basicComponentStatus" json:"basicComponentStatus,omitempty"`
|
||||
ClusterCheckResults []ClusterCheckResults `yaml:"clusterCheckResults" json:"clusterCheckResults,omitempty"`
|
||||
ClusterConfigurationResults []PodResult `yaml:"clusterConfigurationResults" json:"clusterConfigurationResults,omitempty"`
|
||||
AllNodeStatusResults []AllNodeStatusResults `yaml:"allNodeStatusResults" json:"allNodeStatusResults,omitempty"`
|
||||
}
|
||||
|
||||
type ProblemDetector struct {
|
||||
Namespace string
|
||||
Name string
|
||||
EventTime time.Time
|
||||
Reason string
|
||||
Message string
|
||||
type ClusterCheckResults struct {
|
||||
Namespace string `yaml:"namespace" json:"namespace,omitempty"`
|
||||
Name string `yaml:"name" json:"name,omitempty"`
|
||||
EventTime time.Time `yaml:"eventTime" json:"eventTime,omitempty"`
|
||||
Reason string `yaml:"reason" json:"reason,omitempty"`
|
||||
Message string `yaml:"message" json:"message,omitempty"`
|
||||
}
|
||||
|
||||
type NodeStatus struct {
|
||||
Name string
|
||||
Status corev1.ConditionStatus
|
||||
HeartbeatTime time.Time
|
||||
Reason string
|
||||
Message string
|
||||
type AllNodeStatusResults struct {
|
||||
Name string `yaml:"name" json:"name,omitempty"`
|
||||
Status corev1.ConditionStatus `yaml:"status" json:"status,omitempty"`
|
||||
HeartbeatTime time.Time `yaml:"heartbeatTime" json:"heartbeatTime,omitempty"`
|
||||
Reason string `yaml:"reason" json:"reason,omitempty"`
|
||||
Message string `yaml:"message" json:"message,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterInfo struct {
|
||||
K8sVersion string
|
||||
NodeNum int
|
||||
PodNum int
|
||||
NamespaceNum int
|
||||
type BasicClusterInformation struct {
|
||||
K8sVersion string `yaml:"k8sVersion" json:"k8sVersion,omitempty"`
|
||||
NodeNum int `yaml:"nodeNum" json:"nodeNum,omitempty"`
|
||||
PodNum int `yaml:"podNum" json:"podNum,omitempty"`
|
||||
NamespaceNum int `yaml:"namespaceNum" json:"namespaceNum,omitempty"`
|
||||
}
|
||||
|
||||
type PodResult struct {
|
||||
CreatedTime string
|
||||
Namespace string
|
||||
Kind string
|
||||
Name string
|
||||
ContainerResults []ContainerResult
|
||||
CreatedTime string `yaml:"createdTime" json:"createdTime,omitempty"`
|
||||
Namespace string `yaml:"namespace" json:"namespace,omitempty"`
|
||||
Kind string `yaml:"kind" json:"kind,omitempty"`
|
||||
Name string `yaml:"name" json:"name,omitempty"`
|
||||
ContainerResults []ContainerResult `yaml:"containerResults" json:"containerResults,omitempty"`
|
||||
}
|
||||
|
||||
type ContainerResult struct {
|
||||
Results ResultSet
|
||||
Results ResultSet `yaml:"results" json:"results,omitempty"`
|
||||
}
|
||||
|
||||
type ResultSet map[string]ResultMessage
|
||||
|
||||
|
||||
type ResultMessage struct {
|
||||
ID string
|
||||
Message string
|
||||
Success bool
|
||||
Severity config.Severity
|
||||
Category string
|
||||
ID string `yaml:"id" json:"id,omitempty"`
|
||||
Message string `yaml:"message" json:"message,omitempty"`
|
||||
Success bool `yaml:"success" json:"success,omitempty"`
|
||||
Severity config.Severity `yaml:"severity" json:"severity,omitempty"`
|
||||
Category string `yaml:"category" json:"category,omitempty"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue