mirror of
https://github.com/bloomberg/goldpinger.git
synced 2026-04-27 20:36:36 +00:00
Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d93a43d68b | ||
|
|
38f409b7bd | ||
|
|
083b4ef962 | ||
|
|
0060f82c02 | ||
|
|
5bad42922e | ||
|
|
6f0dab4dfd | ||
|
|
4cddd3b5f8 | ||
|
|
8a2d9e6f37 | ||
|
|
a8aa0cee74 | ||
|
|
bfa78dcc7d | ||
|
|
eddb8fe8d7 | ||
|
|
c8ad7abfe8 | ||
|
|
0eceb9e282 | ||
|
|
6a04adb86a | ||
|
|
0c034d8751 | ||
|
|
33655dd9d8 | ||
|
|
cbee29b97e | ||
|
|
a9322e6b42 | ||
|
|
c2b0cd2188 | ||
|
|
e4eaca592a | ||
|
|
4f29ec9d55 | ||
|
|
6bc695b771 | ||
|
|
d0ad01c06e | ||
|
|
758cc2bcd6 | ||
|
|
8f738e70a7 | ||
|
|
6640f0d5c8 | ||
|
|
53c1b0e78e | ||
|
|
28cc2894eb | ||
|
|
bdcf179d5f | ||
|
|
c294816ae5 | ||
|
|
dcf8da2814 | ||
|
|
a00da77b2c | ||
|
|
63e7820b1d | ||
|
|
4bdda1f6be | ||
|
|
7612a46029 | ||
|
|
9a62862cbc | ||
|
|
3bff17f0b1 | ||
|
|
0ddc7f0fe6 | ||
|
|
9667600fde | ||
|
|
42db86e327 | ||
|
|
ca464c0e77 | ||
|
|
1342f80776 |
10
.travis.yml
10
.travis.yml
@@ -1,7 +1,15 @@
|
||||
language: go
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
go:
|
||||
- "1.10.x"
|
||||
- master
|
||||
|
||||
script: go get -u github.com/golang/dep/cmd/dep && make vendor && make
|
||||
script:
|
||||
- docker --version
|
||||
- go get -u github.com/golang/dep/cmd/dep && make vendor && make && make build
|
||||
- docker images
|
||||
- make build-multistage
|
||||
- docker images
|
||||
|
||||
27
Dockerfile
Normal file
27
Dockerfile
Normal file
@@ -0,0 +1,27 @@
|
||||
FROM golang:1.11-alpine as builder
|
||||
|
||||
# Install our build tools
|
||||
|
||||
RUN apk add --update git make bash
|
||||
RUN go get -u github.com/golang/dep/cmd/dep
|
||||
|
||||
# Get sources
|
||||
|
||||
RUN go get github.com/bloomberg/goldpinger/cmd/goldpinger
|
||||
WORKDIR /go/src/github.com/bloomberg/goldpinger
|
||||
|
||||
# Install our dependencies
|
||||
|
||||
RUN make vendor
|
||||
|
||||
# Build goldpinger
|
||||
|
||||
RUN make bin/goldpinger
|
||||
|
||||
# Build the asset container, copy over goldpinger
|
||||
|
||||
FROM scratch
|
||||
COPY --from=builder /go/src/github.com/bloomberg/goldpinger/bin/goldpinger /goldpinger
|
||||
COPY ./static /static
|
||||
ENTRYPOINT ["/goldpinger", "--static-file-path", "/static"]
|
||||
|
||||
7
Makefile
7
Makefile
@@ -1,5 +1,5 @@
|
||||
name ?= goldpinger
|
||||
version ?= 1.0.2
|
||||
version ?= 1.1.0
|
||||
bin ?= goldpinger
|
||||
pkg ?= "github.com/bloomberg/goldpinger"
|
||||
tag = $(name):$(version)
|
||||
@@ -22,8 +22,11 @@ swagger:
|
||||
swagger generate server -t pkg -f ./swagger.yml --exclude-main -A goldpinger && \
|
||||
swagger generate client -t pkg -f ./swagger.yml -A goldpinger
|
||||
|
||||
build-multistage:
|
||||
sudo docker build -t $(tag) -f ./Dockerfile .
|
||||
|
||||
build: bin/$(bin)
|
||||
sudo docker build -t $(tag) -f ./build/Dockerfile .
|
||||
sudo docker build -t $(tag) -f ./build/Dockerfile-simple .
|
||||
|
||||
tag:
|
||||
sudo docker tag $(tag) $(namespace)$(tag)
|
||||
|
||||
49
README.md
49
README.md
@@ -3,7 +3,7 @@
|
||||
__Goldpinger__ makes calls between its instances for visibility and alerting.
|
||||
It runs as a `DaemonSet` on `Kubernetes` and produces `Prometheus` metrics that can be scraped, visualised and alerted on.
|
||||
|
||||
Oh, and it gives you the graph below for your cluster.
|
||||
Oh, and it gives you the graph below for your cluster. Check out the [video explainer](https://youtu.be/DSFxRz_0TU4).
|
||||
|
||||

|
||||
|
||||
@@ -13,6 +13,8 @@ Oh, and it gives you the graph below for your cluster.
|
||||
- [Rationale](#rationale)
|
||||
- [Quick start](#quick-start)
|
||||
- [Building](#building)
|
||||
- [Compiling using a multi-stage Dockerfile](#compiling-using-a-multi-stage-dockerfile)
|
||||
- [Compiling locally](#compiling-locally)
|
||||
- [Installation](#installation)
|
||||
- [Authentication with Kubernetes API](#authentication-with-kubernetes-api)
|
||||
- [Example YAML](#example-yaml)
|
||||
@@ -31,6 +33,8 @@ We built __Goldpinger__ to troubleshoot, visualise and alert on our networking l
|
||||
|
||||
It's small, simple and you'll wonder why you hadn't had it before.
|
||||
|
||||
If you'd like to know more, you can watch [our presentation at Kubecon 2018 Seattle](https://youtu.be/DSFxRz_0TU4).
|
||||
|
||||
|
||||
## Quick start
|
||||
|
||||
@@ -44,9 +48,28 @@ Note, that in order to guarantee correct versions of dependencies, the project [
|
||||
|
||||
## Building
|
||||
|
||||
The repo comes with two ways of building a `docker` image: compiling locally, and compiling using a multi-stage `Dockerfile` image.
|
||||
|
||||
### Compiling using a multi-stage Dockerfile
|
||||
|
||||
You will need `docker` version 17.05+ installed to support multi-stage builds.
|
||||
|
||||
```sh
|
||||
# step 1: launch the build
|
||||
make build-multistage
|
||||
|
||||
# step 2: push the image somewhere
|
||||
namespace="docker.io/myhandle/" make tag
|
||||
namespace="docker.io/myhandle/" make push
|
||||
```
|
||||
|
||||
This was contributed via [@michiel](https://github.com/michiel) - kudos !
|
||||
|
||||
### Compiling locally
|
||||
|
||||
In order to build `Goldpinger`, you are going to need `go` version 1.10+, `dep`, and `docker`.
|
||||
|
||||
Building from source code consists of compiling the binary and building a [Docker image](./build/Dockerfile):
|
||||
Building from source code consists of compiling the binary and building a [Docker image](./build/Dockerfile-simple):
|
||||
|
||||
```sh
|
||||
# step 0: check out the code into your $GOPATH
|
||||
@@ -80,7 +103,9 @@ namespace="docker.io/myhandle/" make push
|
||||
### Example YAML
|
||||
|
||||
|
||||
Here's an example of what you can do (using the in-cluster authentication to `Kubernetes` apiserver):
|
||||
Here's an example of what you can do (using the in-cluster authentication to `Kubernetes` apiserver).
|
||||
|
||||
:warning: Replace `docker.io/mynamespace-replaceme/goldpinger:1.0.0` with the actual tag you built.
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -134,6 +159,24 @@ spec:
|
||||
app: goldpinger
|
||||
```
|
||||
|
||||
Note, that you will also need to add an RBAC rule to allow `Goldpinger` to list other pods. If you're just playing around, you can consider a view-all default rule:
|
||||
|
||||
```yaml
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: default
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: view
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: default
|
||||
namespace: default
|
||||
```
|
||||
|
||||
You can also see [an example of using `kubeconfig` in the `./extras`](./extras/example-with-kubeconfig.yaml).
|
||||
|
||||
## Usage
|
||||
|
||||
49
extras/example-serviceaccounts.yml
Normal file
49
extras/example-serviceaccounts.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: goldpinger
|
||||
spec:
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: goldpinger
|
||||
version: "1.0.0"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: goldpinger
|
||||
version: "1.0.0"
|
||||
spec:
|
||||
containers:
|
||||
- name: goldpinger
|
||||
env:
|
||||
- name: HOST
|
||||
value: "0.0.0.0"
|
||||
- name: PORT
|
||||
value: "80"
|
||||
# injecting real hostname will make for easier to understand graphs/metrics
|
||||
- name: HOSTNAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: spec.nodeName
|
||||
image: "docker.io/mynamespace-replaceme/goldpinger:1.0.0"
|
||||
ports:
|
||||
- containerPort: 80
|
||||
name: http
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: goldpinger
|
||||
labels:
|
||||
app: goldpinger
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- port: 80
|
||||
nodePort: 30080
|
||||
name: http
|
||||
selector:
|
||||
app: goldpinger
|
||||
@@ -26,5 +26,6 @@ var GoldpingerConfig = struct {
|
||||
Hostname string `long:"hostname" description:"Hostname to use" env:"HOSTNAME"`
|
||||
Port int `long:"client-port-override" description:"(for testing) use this port when calling other instances" env:"CLIENT_PORT_OVERRIDE"`
|
||||
UseHostIP bool `long:"use-host-ip" description:"When making the calls, use host ip (defaults to pod ip)" env:"USE_HOST_IP"`
|
||||
LabelSelector string `long:"label-selector" description:"label selector to use to discover goldpinger pods in the cluster" env:"LABEL_SELECTOR" default:"app=goldpinger"`
|
||||
KubernetesClient *kubernetes.Clientset
|
||||
}{}
|
||||
|
||||
@@ -16,14 +16,24 @@ package goldpinger
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"io/ioutil"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func GetAllPods() map[string]string {
|
||||
func getNamespace() string {
|
||||
b, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
|
||||
if err != nil {
|
||||
log.Println("Unable to determine namespace: ", err.Error())
|
||||
return ""
|
||||
}
|
||||
namespace := string(b)
|
||||
return namespace
|
||||
}
|
||||
|
||||
// GetAllPods returns a map of Pod IP to Host IP based on a label selector defined in config
|
||||
func GetAllPods() map[string]string {
|
||||
timer := GetLabeledKubernetesCallsTimer()
|
||||
pods, err := GoldpingerConfig.KubernetesClient.CoreV1().Pods("").List(metav1.ListOptions{LabelSelector: "app=goldpinger"})
|
||||
pods, err := GoldpingerConfig.KubernetesClient.CoreV1().Pods(getNamespace()).List(metav1.ListOptions{LabelSelector: GoldpingerConfig.LabelSelector})
|
||||
if err != nil {
|
||||
log.Println("Error getting pods for selector: ", err.Error())
|
||||
CountError("kubernetes_api")
|
||||
|
||||
@@ -90,8 +90,8 @@ limitations under the License.
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a href="#">Graph</a></li>
|
||||
<li><a href="#" id="show-data">Data</a></li>
|
||||
<li><a href="/check_all" >Raw</a></li>
|
||||
<li><a href="/metrics" >Metrics</a></li>
|
||||
<li><a href="check_all" >Raw</a></li>
|
||||
<li><a href="metrics" >Metrics</a></li>
|
||||
</ul>
|
||||
<div class="navbar-form navbar-left" role="search">
|
||||
<div class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user