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
|
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).
|
* 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`
|
`kubectl apply -f npd-config.yaml`
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
|
|
||||||
"os"
|
"os"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Cluster(ctx context.Context) (int, error) {
|
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")
|
fmt.Println("do not get cluster information")
|
||||||
}
|
}
|
||||||
|
|
||||||
componentStatusResult, err := ComponentStatusResult(k.ComponentStatus)
|
BasicComponentStatus, err := ComponentStatusResult(k.ComponentStatus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("do not get componentStatus")
|
fmt.Println("do not get componentStatus")
|
||||||
}
|
}
|
||||||
|
|
||||||
problemDetector, err := ProblemDetectorResult(k.ProblemDetector)
|
clusterCheckResults, err := ProblemDetectorResult(k.ProblemDetector)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("do not get problemDetector")
|
fmt.Println("do not get problemDetector")
|
||||||
}
|
}
|
||||||
|
@ -43,19 +42,19 @@ func Cluster(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auditData := AuditData{
|
auditData := AuditData{
|
||||||
AuditTime: k.CreationTime.Format(time.RFC3339),
|
// AuditTime: k.CreationTime.Format(time.RFC3339),
|
||||||
AuditAddress: k.AuditAddress,
|
// AuditAddress: k.AuditAddress,
|
||||||
ComponentStatus: componentStatusResult,
|
BasicComponentStatus: BasicComponentStatus,
|
||||||
ClusterInfo: ClusterInfo{
|
BasicClusterInformation: BasicClusterInformation{
|
||||||
K8sVersion: k.ServerVersion,
|
K8sVersion: k.ServerVersion,
|
||||||
PodNum: len(k.Pods),
|
PodNum: len(k.Pods),
|
||||||
NodeNum: len(k.Nodes),
|
NodeNum: len(k.Nodes),
|
||||||
NamespaceNum: len(k.Namespaces),
|
NamespaceNum: len(k.Namespaces),
|
||||||
},
|
},
|
||||||
|
|
||||||
GoodPractice: goodPractice,
|
ClusterConfigurationResults: goodPractice,
|
||||||
NodeStatus: nodeStatus,
|
AllNodeStatusResults: nodeStatus,
|
||||||
ProblemDetector: problemDetector,
|
ClusterCheckResults: clusterCheckResults,
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonBytes, err := json.Marshal(auditData)
|
jsonBytes, err := json.Marshal(auditData)
|
||||||
|
@ -71,33 +70,33 @@ func ComponentStatusResult(cs []v1.ComponentStatus) (interface{}, error) {
|
||||||
}
|
}
|
||||||
return cr, nil
|
return cr, nil
|
||||||
}
|
}
|
||||||
func ProblemDetectorResult(event []v1.Event) ([]ProblemDetector, error) {
|
func ProblemDetectorResult(event []v1.Event) ([]ClusterCheckResults, error) {
|
||||||
var pdrs []ProblemDetector
|
var pdrs []ClusterCheckResults
|
||||||
for j := 0; j < len(event); j++{
|
for j := 0; j < len(event); j++ {
|
||||||
if event[j].Type == "Warning" {
|
if event[j].Type == "Warning" {
|
||||||
pdr := ProblemDetector{
|
pdr := ClusterCheckResults{
|
||||||
Namespace: event[j].ObjectMeta.Namespace,
|
Namespace: event[j].ObjectMeta.Namespace,
|
||||||
Name: event[j].ObjectMeta.Name,
|
Name: event[j].ObjectMeta.Name,
|
||||||
EventTime: event[j].LastTimestamp.Time,
|
EventTime: event[j].LastTimestamp.Time,
|
||||||
Reason: event[j].Reason,
|
Reason: event[j].Reason,
|
||||||
Message: event[j].Message,
|
Message: event[j].Message,
|
||||||
}
|
}
|
||||||
pdrs = append(pdrs, pdr)
|
pdrs = append(pdrs, pdr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pdrs, nil
|
return pdrs, nil
|
||||||
}
|
}
|
||||||
func NodeStatusResult(nodes []v1.Node) ([]NodeStatus, error) {
|
func NodeStatusResult(nodes []v1.Node) ([]AllNodeStatusResults, error) {
|
||||||
var nodestatus []NodeStatus
|
var nodestatus []AllNodeStatusResults
|
||||||
for k :=0; k < len(nodes); k++{
|
for k := 0; k < len(nodes); k++ {
|
||||||
nodestate := NodeStatus{
|
nodestate := AllNodeStatusResults{
|
||||||
Name: nodes[k].ObjectMeta.Name,
|
Name: nodes[k].ObjectMeta.Name,
|
||||||
HeartbeatTime: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].LastHeartbeatTime.Time,
|
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,
|
Status: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Status,
|
||||||
Reason: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Reason,
|
Reason: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Reason,
|
||||||
Message: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Message,
|
Message: nodes[k].Status.Conditions[len(nodes[k].Status.Conditions)-1].Message,
|
||||||
}
|
}
|
||||||
nodestatus = append(nodestatus, nodestate)
|
nodestatus = append(nodestatus, nodestate)
|
||||||
}
|
}
|
||||||
return nodestatus, nil
|
return nodestatus, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,57 +7,56 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuditData struct {
|
type AuditData struct {
|
||||||
AuditTime string
|
//AuditTime string `yaml:"auditTime" json:"auditTime,omitempty"`
|
||||||
AuditAddress string
|
//AuditAddress string `yaml:"auditAddress" json:"auditAddress,omitempty"`
|
||||||
ClusterInfo ClusterInfo
|
BasicClusterInformation BasicClusterInformation `yaml:"basicClusterInformation" json:"basicClusterInformation,omitempty"`
|
||||||
ComponentStatus interface{}
|
BasicComponentStatus interface{} `yaml:"basicComponentStatus" json:"basicComponentStatus,omitempty"`
|
||||||
ProblemDetector []ProblemDetector
|
ClusterCheckResults []ClusterCheckResults `yaml:"clusterCheckResults" json:"clusterCheckResults,omitempty"`
|
||||||
GoodPractice []PodResult
|
ClusterConfigurationResults []PodResult `yaml:"clusterConfigurationResults" json:"clusterConfigurationResults,omitempty"`
|
||||||
NodeStatus []NodeStatus
|
AllNodeStatusResults []AllNodeStatusResults `yaml:"allNodeStatusResults" json:"allNodeStatusResults,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProblemDetector struct {
|
type ClusterCheckResults struct {
|
||||||
Namespace string
|
Namespace string `yaml:"namespace" json:"namespace,omitempty"`
|
||||||
Name string
|
Name string `yaml:"name" json:"name,omitempty"`
|
||||||
EventTime time.Time
|
EventTime time.Time `yaml:"eventTime" json:"eventTime,omitempty"`
|
||||||
Reason string
|
Reason string `yaml:"reason" json:"reason,omitempty"`
|
||||||
Message string
|
Message string `yaml:"message" json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeStatus struct {
|
type AllNodeStatusResults struct {
|
||||||
Name string
|
Name string `yaml:"name" json:"name,omitempty"`
|
||||||
Status corev1.ConditionStatus
|
Status corev1.ConditionStatus `yaml:"status" json:"status,omitempty"`
|
||||||
HeartbeatTime time.Time
|
HeartbeatTime time.Time `yaml:"heartbeatTime" json:"heartbeatTime,omitempty"`
|
||||||
Reason string
|
Reason string `yaml:"reason" json:"reason,omitempty"`
|
||||||
Message string
|
Message string `yaml:"message" json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClusterInfo struct {
|
type BasicClusterInformation struct {
|
||||||
K8sVersion string
|
K8sVersion string `yaml:"k8sVersion" json:"k8sVersion,omitempty"`
|
||||||
NodeNum int
|
NodeNum int `yaml:"nodeNum" json:"nodeNum,omitempty"`
|
||||||
PodNum int
|
PodNum int `yaml:"podNum" json:"podNum,omitempty"`
|
||||||
NamespaceNum int
|
NamespaceNum int `yaml:"namespaceNum" json:"namespaceNum,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PodResult struct {
|
type PodResult struct {
|
||||||
CreatedTime string
|
CreatedTime string `yaml:"createdTime" json:"createdTime,omitempty"`
|
||||||
Namespace string
|
Namespace string `yaml:"namespace" json:"namespace,omitempty"`
|
||||||
Kind string
|
Kind string `yaml:"kind" json:"kind,omitempty"`
|
||||||
Name string
|
Name string `yaml:"name" json:"name,omitempty"`
|
||||||
ContainerResults []ContainerResult
|
ContainerResults []ContainerResult `yaml:"containerResults" json:"containerResults,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContainerResult struct {
|
type ContainerResult struct {
|
||||||
Results ResultSet
|
Results ResultSet `yaml:"results" json:"results,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResultSet map[string]ResultMessage
|
type ResultSet map[string]ResultMessage
|
||||||
|
|
||||||
|
|
||||||
type ResultMessage struct {
|
type ResultMessage struct {
|
||||||
ID string
|
ID string `yaml:"id" json:"id,omitempty"`
|
||||||
Message string
|
Message string `yaml:"message" json:"message,omitempty"`
|
||||||
Success bool
|
Success bool `yaml:"success" json:"success,omitempty"`
|
||||||
Severity config.Severity
|
Severity config.Severity `yaml:"severity" json:"severity,omitempty"`
|
||||||
Category string
|
Category string `yaml:"category" json:"category,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue