Skip to content

Commit

Permalink
Merge pull request #81 from replicatedhq/collector-node
Browse files Browse the repository at this point in the history
Collector node
  • Loading branch information
marccampbell authored Nov 8, 2019
2 parents 2a3e4e7 + ed8453c commit cd43fd6
Show file tree
Hide file tree
Showing 17 changed files with 1,009 additions and 41 deletions.
78 changes: 78 additions & 0 deletions config/crds/troubleshoot.replicated.com_analyzers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,45 @@ spec:
required:
- outcomes
type: object
containerRuntime:
properties:
checkName:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
customResourceDefinition:
properties:
checkName:
Expand Down Expand Up @@ -520,6 +559,45 @@ spec:
- namespace
- name
type: object
distribution:
properties:
checkName:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
imagePullSecret:
properties:
checkName:
Expand Down
78 changes: 78 additions & 0 deletions config/crds/troubleshoot.replicated.com_preflights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,45 @@ spec:
required:
- outcomes
type: object
containerRuntime:
properties:
checkName:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
customResourceDefinition:
properties:
checkName:
Expand Down Expand Up @@ -520,6 +559,45 @@ spec:
- namespace
- name
type: object
distribution:
properties:
checkName:
type: string
outcomes:
items:
properties:
fail:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
pass:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
warn:
properties:
message:
type: string
uri:
type: string
when:
type: string
type: object
type: object
type: array
required:
- outcomes
type: object
imagePullSecret:
properties:
checkName:
Expand Down
64 changes: 64 additions & 0 deletions config/crds/zz_generated.deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ func (in *Analyze) DeepCopyInto(out *Analyze) {
*out = new(StatefulsetStatus)
(*in).DeepCopyInto(*out)
}
if in.ContainerRuntime != nil {
in, out := &in.ContainerRuntime, &out.ContainerRuntime
*out = new(ContainerRuntime)
(*in).DeepCopyInto(*out)
}
if in.Distribution != nil {
in, out := &in.Distribution, &out.Distribution
*out = new(Distribution)
(*in).DeepCopyInto(*out)
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Analyze.
Expand Down Expand Up @@ -677,6 +687,33 @@ func (in *CollectorStatus) DeepCopy() *CollectorStatus {
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ContainerRuntime) DeepCopyInto(out *ContainerRuntime) {
*out = *in
out.AnalyzeMeta = in.AnalyzeMeta
if in.Outcomes != nil {
in, out := &in.Outcomes, &out.Outcomes
*out = make([]*Outcome, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(Outcome)
(*in).DeepCopyInto(*out)
}
}
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerRuntime.
func (in *ContainerRuntime) DeepCopy() *ContainerRuntime {
if in == nil {
return nil
}
out := new(ContainerRuntime)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Copy) DeepCopyInto(out *Copy) {
*out = *in
Expand Down Expand Up @@ -752,6 +789,33 @@ func (in *DeploymentStatus) DeepCopy() *DeploymentStatus {
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Distribution) DeepCopyInto(out *Distribution) {
*out = *in
out.AnalyzeMeta = in.AnalyzeMeta
if in.Outcomes != nil {
in, out := &in.Outcomes, &out.Outcomes
*out = make([]*Outcome, len(*in))
for i := range *in {
if (*in)[i] != nil {
in, out := &(*in)[i], &(*out)[i]
*out = new(Outcome)
(*in).DeepCopyInto(*out)
}
}
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Distribution.
func (in *Distribution) DeepCopy() *Distribution {
if in == nil {
return nil
}
out := new(Distribution)
in.DeepCopyInto(out)
return out
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Exec) DeepCopyInto(out *Exec) {
*out = *in
Expand Down
22 changes: 12 additions & 10 deletions examples/troubleshoot/sample-analyzers.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
apiVersion: troubleshoot.replicated.com/v1beta1
kind: Analyzer
metadata:
name: defaultAnalyzers
name: a
spec:
analyzers:
- clusterVersion:
- distribution:
outcomes:
- fail:
when: "< 1.13.0"
message: The application requires at Kubernetes 1.13.0 or later, and recommends 1.15.0.
uri: https://www.kubernetes.io
when: "= docker desktop"
message: "docker for desktop is not allowed"
- fail:
when: "microk8s"
message: "mickrk8s is not prod"
- warn:
when: "< 1.15.0"
message: Your cluster meets the minimum version of Kubernetes, but we recommend you update to 1.15.0 or later.
uri: https://kubernetes.io
when: "!= eks"
message: "YMMV on not eks"
- pass:
when: ">= 1.15.0"
message: Your cluster meets the recommended and required versions of Kubernetes.
message: "good work"


25 changes: 1 addition & 24 deletions examples/troubleshoot/sample-troubleshoot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,4 @@ kind: Collector
metadata:
name: collector-sample
spec:
collectors:
- secret:
name: myapp-postgres
namespace: default
key: uri
includeValue: false
- logs:
selector:
- name=cilium-operator
namespace: kube-system
limits:
maxAge: 30d
maxLines: 10000
- run:
collectorName: ping-google
namespace: default
image: flungo/netutils
command: ["ping"]
args: ["www.google.com"]
timeout: 5s
- http:
collectorName: echo-ip
get:
url: https://api.replicated.com/market/v1/echo/ip
collectors: []
10 changes: 8 additions & 2 deletions pkg/analyze/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ func Analyze(analyzer *troubleshootv1beta1.Analyze, getFile getCollectedFileCont
return analyzeImagePullSecret(analyzer.ImagePullSecret, findFiles)
}
if analyzer.DeploymentStatus != nil {
return deploymentStatus(analyzer.DeploymentStatus, getFile)
return analyzeDeploymentStatus(analyzer.DeploymentStatus, getFile)
}
if analyzer.StatefulsetStatus != nil {
return statefulsetStatus(analyzer.StatefulsetStatus, getFile)
return analyzeStatefulsetStatus(analyzer.StatefulsetStatus, getFile)
}
if analyzer.ContainerRuntime != nil {
return analyzeContainerRuntime(analyzer.ContainerRuntime, getFile)
}
if analyzer.Distribution != nil {
return analyzeDistribution(analyzer.Distribution, getFile)
}

return nil, errors.New("invalid analyzer")
Expand Down
Loading

0 comments on commit cd43fd6

Please sign in to comment.