Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
marccampbell committed Jul 8, 2019
1 parent b229d56 commit a4824db
Show file tree
Hide file tree
Showing 22 changed files with 212 additions and 1,274 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ manager: generate fmt vet
troubleshoot: generate fmt vet
go build -o bin/troubleshoot github.com/replicatedhq/troubleshoot/cmd/troubleshoot

.PHONY: collector
collector: generate fmt vet
go build -o bin/collector github.com/replicatedhq/troubleshoot/cmd/collector

.PHONY: preflight
preflight: generate fmt vet
go build -o bin/preflight github.com/replicatedhq/troubleshoot/cmd/preflight
Expand All @@ -26,11 +30,11 @@ run: generate fmt vet

# Install CRDs into a cluster
install: manifests
kubectl apply -f config/crds
kubectl apply -f config/crd

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
kubectl apply -f config/crds
kubectl apply -f config/crd
kustomize build config/default | kubectl apply -f -

# Generate manifests e.g. CRD, RBAC etc.
Expand Down
27 changes: 27 additions & 0 deletions cmd/collector/cli/collect.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cli

import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

func Server() *cobra.Command {
cmd := &cobra.Command{
Use: "server",
Short: "start the collector server",
Long: `...`,
PreRun: func(cmd *cobra.Command, args []string) {
viper.BindPFlag("port", cmd.Flags().Lookup("port"))
},
RunE: func(cmd *cobra.Command, args []string) error {

return nil
},
}

cmd.Flags().Int("port", 8000, "port to bind to")

viper.BindPFlags(cmd.Flags())

return cmd
}
38 changes: 38 additions & 0 deletions cmd/collector/cli/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cli

import (
"fmt"
"os"
"strings"

"github.com/spf13/cobra"
"github.com/spf13/viper"
)

func RootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "collector",
Short: "Run the cluster-side server for bundle collection",
Long: ``,
SilenceUsage: true,
}

cobra.OnInitialize(initConfig)

cmd.AddCommand(Server())

viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
return cmd
}

func InitAndExecute() {
if err := RootCmd().Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

func initConfig() {
viper.SetEnvPrefix("TROUBLESHOT")
viper.AutomaticEnv()
}
7 changes: 7 additions & 0 deletions cmd/collector/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/replicatedhq/troubleshoot/cmd/collector/cli"

func main() {
cli.InitAndExecute()
}
12 changes: 12 additions & 0 deletions config/crd/troubleshoot.replicated.com_collectorjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,18 @@ spec:
type: string
type: object
spec:
properties:
collector:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
required:
- collector
type: object
status:
type: object
Expand Down
594 changes: 5 additions & 589 deletions config/crd/troubleshoot.replicated.com_collectors.yaml

Large diffs are not rendered by default.

39 changes: 0 additions & 39 deletions config/crds/troubleshoot_v1beta1_analyzer.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions config/crds/troubleshoot_v1beta1_analyzerjob.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions config/crds/troubleshoot_v1beta1_collector.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions config/crds/troubleshoot_v1beta1_collectorjob.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions config/crds/troubleshoot_v1beta1_preflight.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions config/crds/troubleshoot_v1beta1_preflightjob.yaml

This file was deleted.

19 changes: 1 addition & 18 deletions config/samples/troubleshoot_v1beta1_collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,4 @@ kind: Collector
metadata:
name: collector-sample
spec:
collectors:
- kubernetes.resource-list:
output_dir: /kubernetes/resources/jobs
kind: jobs
namespace: ""
- kubernetes.resource-list:
output_dir: /kubernetes/resources/deployments
kind: deployments
namespace: ""
- kubernetes.resource-list:
output_dir: /kubernetes/resources/pods
kind: pods
namespace: ""
- kubernetes.resource-list:
output_dir: /kubernetes/resources/events
kind: events
namespace: ""

- cluster-info: {}
7 changes: 3 additions & 4 deletions config/samples/troubleshoot_v1beta1_collectorjob.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
apiVersion: troubleshoot.replicated.com/v1beta1
kind: CollectorJob
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: collectorjob-sample
spec:
# Add fields here
foo: bar
collector:
name: collector-sample
namespace: default
Loading

0 comments on commit a4824db

Please sign in to comment.