42 Commits
1.0.2 ... 1.1.0

Author SHA1 Message Date
Mikolaj Pawlikowski
d93a43d68b Merge pull request #28 from twexler/dynamic-label-selector
Use a configuration value for the label selector when discovering goldpinger pods
2018-12-20 19:11:35 +01:00
Ted Wexler
38f409b7bd Fix merge issue
Signed-off-by: Ted Wexler <twexler@bloomberg.net>
2018-12-20 17:26:46 +00:00
Mikolaj Pawlikowski
083b4ef962 Merge branch 'master' into dynamic-label-selector 2018-12-20 18:20:38 +01:00
Mikolaj Pawlikowski
0060f82c02 Merge pull request #20 from blakebarnett/bdb__limit_pod_list_by_namespace
Limit Pod.List calls by namespace
2018-12-20 18:19:01 +01:00
Mikolaj Pawlikowski
5bad42922e Explicitly return empty string on error reading namespace
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-20 18:03:17 +01:00
Ted Wexler
6f0dab4dfd Merge branch 'master' into dynamic-label-selector 2018-12-20 09:54:25 -05:00
Ted Wexler
4cddd3b5f8 Use a configuration value for the label selector when discovering goldpinger pods
Signed-off-by: Ted Wexler <twexler@bloomberg.net>
2018-12-20 14:53:59 +00:00
Mikolaj Pawlikowski
8a2d9e6f37 Fix indentation
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-20 15:42:47 +01:00
Mikolaj Pawlikowski
a8aa0cee74 Merge branch 'master' into bdb__limit_pod_list_by_namespace 2018-12-20 15:35:29 +01:00
Mikolaj Pawlikowski
bfa78dcc7d Merge pull request #26 from seeker89/seeker89-patch-1
Bump patch version to 1.0.3
2018-12-20 14:15:41 +01:00
Mikolaj Pawlikowski
eddb8fe8d7 Merge branch 'master' into seeker89-patch-1 2018-12-20 12:06:12 +00:00
Mikolaj Pawlikowski
c8ad7abfe8 Merge pull request #25 from 0xflotus/patch-1
did you mean 'compiling'?
2018-12-20 11:26:43 +00:00
Mikolaj Pawlikowski
0eceb9e282 Merge branch 'master' into seeker89-patch-1 2018-12-20 11:02:55 +00:00
0xflotus
6a04adb86a Merge branch 'master' into patch-1 2018-12-20 12:02:41 +01:00
Mikolaj Pawlikowski
0c034d8751 Bump patch version to 1.0.3
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-20 12:01:44 +01:00
Mikolaj Pawlikowski
33655dd9d8 Merge branch 'master' into bdb__limit_pod_list_by_namespace 2018-12-20 11:00:04 +00:00
0xflotus
cbee29b97e did you mean 'compiling'?
Signed-off-by: 0xflotus <0xflotus@gmail.com>
2018-12-20 11:59:20 +01:00
Mikolaj Pawlikowski
a9322e6b42 Merge pull request #24 from infinitydon/master
Fix broken links in the UI when accessed via an Ingress
2018-12-20 10:57:24 +00:00
Christopher Adigun
c2b0cd2188 Fix broken links in the UI when accessed via an Ingress
Signed-off-by: Christopher Adigun <ca@cloudssky.com>
2018-12-20 09:20:11 +01:00
Mikolaj Pawlikowski
e4eaca592a Merge branch 'master' into bdb__limit_pod_list_by_namespace 2018-12-19 13:31:29 +00:00
Mikolaj Pawlikowski
4f29ec9d55 Merge pull request #23 from seeker89/docs-build
Add docs about using the multi-stage Dockerfile
2018-12-19 12:52:48 +00:00
Mikolaj Pawlikowski
6bc695b771 print the images built in the meantime
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-19 12:21:25 +00:00
Mikolaj Pawlikowski
d0ad01c06e also print the docker version
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-19 12:13:43 +00:00
Mikolaj Pawlikowski
758cc2bcd6 use docker service in travis, and build both the simple and the
multistage dockerfiles

Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-19 12:12:00 +00:00
Mikolaj Pawlikowski
8f738e70a7 fix the reference to the Dockerfile in the buld folder
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-19 12:05:10 +00:00
Mikolaj Pawlikowski
6640f0d5c8 more typos
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-19 12:00:14 +00:00
Mikolaj Pawlikowski
53c1b0e78e add link to michiel's profile in readme
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-19 11:58:33 +00:00
Mikolaj Pawlikowski
28cc2894eb added the menu, fixed few typos
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-19 11:57:09 +00:00
Mikolaj Pawlikowski
bdcf179d5f rename the base Dockerfile to Dockerfile-simple
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-19 11:55:13 +00:00
Mikolaj Pawlikowski
c294816ae5 rename the base Dockerfile to Dockerfile-simple
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-19 11:53:22 +00:00
Mikolaj Pawlikowski
dcf8da2814 Merge pull request #18 from michiel/feature/add-multi-stage-dockerfile
Add Dockerfile for automated builds
2018-12-19 11:33:09 +00:00
Michiel Kalkman
a00da77b2c Run 'apk add' once for all required packages
Signed-off-by: Michiel Kalkman <michiel@nosuchtype.com>
2018-12-19 21:43:22 +11:00
Mikolaj Pawlikowski
63e7820b1d Bump minor version to 1.1.0
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-19 10:27:11 +00:00
Michiel Kalkman
4bdda1f6be Remove unnecessary pkg installation, add static
- Remove curl installation
 - Change dep installation from 'curl' to 'go get'
 - Copy static content to asset container

Signed-off-by: Michiel Kalkman <michiel@nosuchtype.com>
2018-12-19 10:25:02 +11:00
Blake
7612a46029 Limit the list of Pod.List calls by namespace
On larger clusters with thousands of pods listing all pods is too expensive.

Signed-off-by: Blake <blake.barnett@postmates.com>
2018-12-18 14:45:43 -08:00
Michiel Kalkman
9a62862cbc Add Dockerfile for automated builds
Signed-off-by: Michiel Kalkman <michiel@nosuchtype.com>
2018-12-19 08:36:47 +11:00
Mikolaj Pawlikowski
3bff17f0b1 Merge pull request #16 from seeker89/update-readme
Update README to address confusion around deploying Goldpinger
2018-12-18 16:05:54 +00:00
Mikolaj Pawlikowski
0ddc7f0fe6 Merge branch 'master' into update-readme 2018-12-18 15:53:16 +00:00
Mikolaj Pawlikowski
9667600fde Update README to address things from the issues
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-18 15:47:28 +00:00
Mikolaj Pawlikowski
42db86e327 Merge pull request #10 from seeker89/example-serviceaccounts
Create example-serviceaccounts.yml
2018-12-11 17:01:09 -08:00
Mikolaj Pawlikowski
ca464c0e77 Merge branch 'master' into example-serviceaccounts 2018-12-11 16:49:12 -08:00
Mikolaj Pawlikowski
1342f80776 Create example-serviceaccounts.yml
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
2018-12-11 16:45:31 -08:00
9 changed files with 152 additions and 11 deletions

View File

@@ -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
View 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"]

View File

@@ -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)

View File

@@ -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).
![](./extras/screenshot.png)
@@ -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

View 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

View File

@@ -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
}{}

View File

@@ -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")

View File

@@ -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">