Skip to content

Commit 932a451

Browse files
Initial commit
0 parents  commit 932a451

File tree

112 files changed

+12384
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+12384
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea/
2+
.DS_Store
3+
/store/
4+
/data/
5+
coverage.out
6+
sloop.iml

CODE_OF_CONDUCT.md

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Salesforce Open Source Community Code of Conduct
2+
3+
## About the Code of Conduct
4+
5+
Equality is a core value at Salesforce. We believe a diverse and inclusive
6+
community fosters innovation and creativity, and are committed to building a
7+
culture where everyone feels included.
8+
9+
Salesforce open-source projects are committed to providing a friendly, safe, and
10+
welcoming environment for all, regardless of gender identity and expression,
11+
sexual orientation, disability, physical appearance, body size, ethnicity, nationality,
12+
race, age, religion, level of experience, education, socioeconomic status, or
13+
other similar personal characteristics.
14+
15+
The goal of this code of conduct is to specify a baseline standard of behavior so
16+
that people with different social values and communication styles can work
17+
together effectively, productively, and respectfully in our open source community.
18+
It also establishes a mechanism for reporting issues and resolving conflicts.
19+
20+
All questions and reports of abusive, harassing, or otherwise unacceptable behavior
21+
in a Salesforce open-source project may be reported by contacting the Salesforce
22+
Open Source Conduct Committee at [email protected].
23+
24+
## Our Pledge
25+
26+
In the interest of fostering an open and welcoming environment, we as
27+
contributors and maintainers pledge to making participation in our project and
28+
our community a harassment-free experience for everyone, regardless of gender
29+
identity and expression, sexual orientation, disability, physical appearance,
30+
body size, ethnicity, nationality, race, age, religion, level of experience, education,
31+
socioeconomic status, or other similar personal characteristics.
32+
33+
## Our Standards
34+
35+
Examples of behavior that contributes to creating a positive environment
36+
include:
37+
38+
* Using welcoming and inclusive language
39+
* Being respectful of differing viewpoints and experiences
40+
* Gracefully accepting constructive criticism
41+
* Focusing on what is best for the community
42+
* Showing empathy toward other community members
43+
44+
Examples of unacceptable behavior by participants include:
45+
46+
* The use of sexualized language or imagery and unwelcome sexual attention or
47+
advances
48+
* Personal attacks, insulting/derogatory comments, or trolling
49+
* Public or private harassment
50+
* Publishing, or threatening to publish, others' private information—such as
51+
a physical or electronic address—without explicit permission
52+
* Other conduct which could reasonably be considered inappropriate in a
53+
professional setting
54+
* Advocating for or encouraging any of the above behaviors
55+
56+
## Our Responsibilities
57+
58+
Project maintainers are responsible for clarifying the standards of acceptable
59+
behavior and are expected to take appropriate and fair corrective action in
60+
response to any instances of unacceptable behavior.
61+
62+
Project maintainers have the right and responsibility to remove, edit, or
63+
reject comments, commits, code, wiki edits, issues, and other contributions
64+
that are not aligned with this Code of Conduct, or to ban temporarily or
65+
permanently any contributor for other behaviors that they deem inappropriate,
66+
threatening, offensive, or harmful.
67+
68+
## Scope
69+
70+
This Code of Conduct applies both within project spaces and in public spaces
71+
when an individual is representing the project or its community. Examples of
72+
representing a project or community include using an official project email
73+
address, posting via an official social media account, or acting as an appointed
74+
representative at an online or offline event. Representation of a project may be
75+
further defined and clarified by project maintainers.
76+
77+
## Enforcement
78+
79+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
80+
reported by contacting the Salesforce Open Source Conduct Committee
81+
at [email protected]. All complaints will be reviewed and investigated
82+
and will result in a response that is deemed necessary and appropriate to the
83+
circumstances. The committee is obligated to maintain confidentiality with
84+
regard to the reporter of an incident. Further details of specific enforcement
85+
policies may be posted separately.
86+
87+
Project maintainers who do not follow or enforce the Code of Conduct in good
88+
faith may face temporary or permanent repercussions as determined by other
89+
members of the project's leadership and the Salesforce Open Source Conduct
90+
Committee.
91+
92+
## Attribution
93+
94+
This Code of Conduct is adapted from the [Contributor Covenant][contributor-covenant-home],
95+
version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html.
96+
It includes adaptions and additions from [Go Community Code of Conduct][golang-coc],
97+
[CNCF Code of Conduct][cncf-coc], and [Microsoft Open Source Code of Conduct][microsoft-coc].
98+
99+
This Code of Conduct is licensed under the [Creative Commons Attribution 3.0 License][cc-by-3-us].
100+
101+
[contributor-covenant-home]: https://www.contributor-covenant.org (https://www.contributor-covenant.org/)
102+
[golang-coc]: https://golang.org/conduct
103+
[cncf-coc]: https://github.com/cncf/foundation/blob/master/code-of-conduct.md
104+
[microsoft-coc]: https://opensource.microsoft.com/codeofconduct/
105+
[cc-by-3-us]: https://creativecommons.org/licenses/by/3.0/us/

CONTRIBUTING.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Build
2+
3+
Sloop uses GitHub to manager reviews of pull requests
4+
5+
## Steps to Contribute
6+
7+
ADD
8+
9+
## Pull Request Checklist
10+
11+
ADD
12+
13+
## Dependency Management
14+
15+
Sloop uses [go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more).
16+
This requires a working Go environment with version 1.13 or greater installed.
17+
It is suggested you set `export GO111MODULE=on`
18+
19+
To add or update a new dependency:
20+
21+
1. use `go get` to pull in the new dependency
22+
1. run `go mod tidy`
23+
24+
## Protobuf Schema Changes
25+
26+
When changing schema in pkg/sloop/store/typed/schema.proto you will need to do the following:
27+
28+
1. Install protobuf. On OSX you can do `brew install protobuf`
29+
1. Grab protoc-gen-go with `go get -u github.com/golang/protobuf/protoc-gen-go`
30+
1. Run this makefile target: `make protobuf`
31+
32+
## Changes to Generated Code
33+
34+
Sloop uses genny to code-gen typed table wrappers. Any changes to `pkg/sloop/store/typed/tabletemplate*.go` will need
35+
to be followed with `go generate`. We have a Makefile target for this: `make generate`
36+
37+
## Prometheus
38+
39+
Sloop uses prometheus to emit metrics, which is very helpful for performance debugging. In the root of the repo is a prometheus config.
40+
41+
On OSX you can install prometheus with `brew install prometheus`. Then simply start it from the sloop directory by running `prometheus`
42+
43+
Open your browser to http://localhost:9090.
44+
45+
An example of a useful query is [rate(kubewatch_event_count[5m])](http://localhost:9090/graph?g0.range_input=1h&g0.expr=rate(kubewatch_event_count%5B1m%5D)&g0.tab=0)

Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM alpine:3.10
2+
ADD sloop /bin/
3+
# Place webfiles in the same relative path from github to the root of the container
4+
# which is the default current working directory
5+
ADD ./pkg/sloop/webfiles/ /pkg/sloop/webfiles/
6+
CMD ["/bin/sloop"]

LICENSE.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Copyright (c) 2019 Salesforce.com, Inc.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
8+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9+
10+
* Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11+
12+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Makefile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.PHONY:perf perfasm
2+
3+
export GO111MODULE=on
4+
5+
all:
6+
go get ./pkg/...
7+
go fmt ./pkg/...
8+
go install ./pkg/...
9+
go test -cover ./pkg/...
10+
11+
run:
12+
go install ./pkg/...
13+
$(GOPATH)/bin/sloop
14+
15+
linux:
16+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install -ldflags "-s" -installsuffix cgo -v ./pkg/...
17+
18+
docker: linux
19+
cp $(GOPATH)/bin/linux_amd64/sloop .
20+
docker build -t sloop .
21+
rm sloop
22+
23+
generate:
24+
go generate ./pkg/...
25+
26+
tidy:
27+
# Run tidy whenever go.mod is changed
28+
go mod tidy
29+
30+
protobuf:
31+
# Make sure you `brew install protobuf` first
32+
# go get -u github.com/golang/protobuf/protoc-gen-go
33+
protoc -I=./pkg/sloop/store/typed/ --go_out=./pkg/sloop/store/typed/ ./pkg/sloop/store/typed/schema.proto
34+
35+
cover:
36+
go test ./pkg/... -coverprofile=coverage.out
37+
go tool cover -html=coverage.out

README.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# sloop - Kubernetes History Visualization
2+
3+
Sloop monitors Kubernetes, recording histories of events and resource state changes
4+
and providing visualizations to aid in debugging past events.
5+
6+
Key features:
7+
8+
1. Allows you to find and inspect resources that no longer exist (example: discover what host the pod from the previous deployment was using).
9+
1. Provides timeline displays that show rollouts of related resources in updates to Deployments, ReplicaSets, and StatefulSets.
10+
1. Helps debug transient and intermittent errors.
11+
1. Allows you to see changes over time in a Kubernetes application.
12+
1. Is a self-contained service with no dependencies on distributed storage.
13+
14+
## Screenshots
15+
16+
![Screenshot1](other/screenshot1.png?raw=true "Screenshot 1")
17+
18+
## Architecture Overview
19+
20+
![Architecture](other/architecture.png?raw=true "Architecture")
21+
22+
## Install
23+
24+
Sloop can be installed using any of these options:
25+
26+
### Precompiled Binaries
27+
28+
_DockerHub images coming soon._
29+
30+
### Helm Chart
31+
32+
_Helm chart coming soon._
33+
34+
### Build from Source
35+
36+
Building Sloop from source needs a working Go environment
37+
with [version 1.13 or greater installed](https://golang.org/doc/install).
38+
39+
Clone the sloop repository and build using `make`:
40+
41+
```sh
42+
$ mkdir -p $GOPATH/src/github.com/salesforce
43+
$ cd $GOPATH/src/github.com/salesforce
44+
$ git clone https://github.com/salesforce/sloop.git
45+
$ cd sloop
46+
$ make
47+
$ ~/go/bin/sloop
48+
```
49+
50+
When complete, you should have a running Sloop version accessing the current context from your kubeConfig. Just point your browser at http://localhost:8080/
51+
52+
Other makefile targets:
53+
54+
* *docker*: Builds a Docker image.
55+
* *cover*: Runs unit tests with code coverage.
56+
* *generate*: Updates genny templates for typed table classes.
57+
* *protobuf*: Generates protobuf code-gen.
58+
59+
### Local Docker Run
60+
61+
To run from Docker you need to host mount your kubeconfig:
62+
63+
```shell script
64+
$ make docker
65+
$ docker run --rm -it -p 8080:8080 -v ~/.kube/:/kube/ -e KUBECONFIG=/kube/config sloop
66+
```
67+
68+
In this mode, data is written to a memory-backed volume and is discarded after each run. To preserve the data, you can host-mount /data with something like `-v /data/:/some_path_on_host/`
69+
70+
## Contributing
71+
72+
Refer to [CONTRIBUTING.md](CONTRIBUTING.md)
73+
74+
## License
75+
76+
BSD 3-Clause

go.mod

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module github.com/salesforce/sloop
2+
3+
go 1.12
4+
5+
require (
6+
github.com/Jeffail/gabs/v2 v2.1.0
7+
github.com/dgraph-io/badger v0.0.0-20190809121831-9d7b751e85c9
8+
github.com/ghodss/yaml v1.0.0
9+
github.com/gogo/protobuf v1.3.0
10+
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
11+
github.com/golang/protobuf v1.3.2
12+
github.com/google/go-cmp v0.3.1 // indirect
13+
github.com/googleapis/gnostic v0.3.1 // indirect
14+
github.com/hashicorp/golang-lru v0.5.3 // indirect
15+
github.com/imdario/mergo v0.3.7 // indirect
16+
github.com/nsf/jsondiff v0.0.0-20190712045011-8443391ee9b6
17+
github.com/pkg/errors v0.8.1
18+
github.com/prometheus/client_golang v1.1.0
19+
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect
20+
github.com/prometheus/procfs v0.0.4 // indirect
21+
github.com/spf13/afero v1.2.2
22+
github.com/stretchr/testify v1.4.0
23+
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 // indirect
24+
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b // indirect
25+
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
26+
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b // indirect
27+
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
28+
google.golang.org/appengine v1.6.2 // indirect
29+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
30+
gopkg.in/inf.v0 v0.9.1 // indirect
31+
k8s.io/api v0.0.0-20190905160310-fb749d2f1064 // indirect
32+
k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
33+
k8s.io/utils v0.0.0-20190907131718-3d4f5b7dea0b // indirect
34+
)

0 commit comments

Comments
 (0)