Skip to content

Commit

Permalink
Merge pull request #118 from promhippie/refactor
Browse files Browse the repository at this point in the history
Better documentation, updated build tools, improved workflows
  • Loading branch information
tboerger authored Aug 9, 2022
2 parents aa3f7eb + b00dfd9 commit 2869e27
Show file tree
Hide file tree
Showing 14 changed files with 548 additions and 120 deletions.
24 changes: 0 additions & 24 deletions .bingo/staticcheck.sum
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -40,17 +25,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200410194907-79a7a3126eef h1:RHORRhs540cYZYrzgU2CPUyykkwZM78hGdzocOo9P8A=
golang.org/x/tools v0.0.0-20200410194907-79a7a3126eef/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f h1:OKYpQQVE3DKSc3r3zHVzq46vq5YH7x8xpR3/k9ixmUg=
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
honnef.co/go/tools v0.0.1-2020.1.6 h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc=
honnef.co/go/tools v0.0.1-2020.1.6/go.mod h1:pyyisuGw24ruLjrr1ddx39WE0y9OooInRzEYLhQB2YY=
honnef.co/go/tools v0.3.2 h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=
honnef.co/go/tools v0.3.2/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw=
1 change: 1 addition & 0 deletions .github/workflows/changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
go-version: 1.18.1

- name: Generate labels
id: labels
run: make labels

- name: Commit changes
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ $(BIN)/$(EXECUTABLE)-debug: $(SOURCES)
$(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME)

.PHONY: release
release: $(DIST) release-linux release-darwin release-windows release-reduce release-checksum
release: $(DIST) release-linux release-darwin release-windows release-checksum

$(DIST):
mkdir -p $(DIST)
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# prometheus-scw-sd
# Prometheus Scaleway SD

[![Current Tag](https://img.shields.io/github/v/tag/promhippie/prometheus-scw-sd?sort=semver)](https://github.com/promhippie/prometheus-scw-sd) [![Build Status](https://github.com/promhippie/prometheus-scw-sd/actions/workflows/general.yml/badge.svg)](https://github.com/promhippie/prometheus-scw-sd/actions) [![Join the Matrix chat at https://matrix.to/#/#webhippie:matrix.org](https://img.shields.io/badge/matrix-%23webhippie-7bc9a4.svg)](https://matrix.to/#/#promhippie:matrix.org) [![Docker Size](https://img.shields.io/docker/image-size/promhippie/prometheus-scw-sd/latest)](https://hub.docker.com/r/promhippie/prometheus-scw-sd) [![Docker Pulls](https://img.shields.io/docker/pulls/promhippie/prometheus-scw-sd)](https://hub.docker.com/r/promhippie/prometheus-scw-sd) [![Go Reference](https://pkg.go.dev/badge/github.com/promhippie/prometheus-scw-sd.svg)](https://pkg.go.dev/github.com/promhippie/prometheus-scw-sd) [![Go Report Card](https://goreportcard.com/badge/github.com/promhippie/prometheus-scw-sd)](https://goreportcard.com/report/github.com/promhippie/prometheus-scw-sd) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/4671e4dac861415db19d41c7959a530a)](https://www.codacy.com/gh/promhippie/prometheus-scw-sd/dashboard?utm_source=github.com&utm_medium=referral&utm_content=promhippie/prometheus-scw-sd&utm_campaign=Badge_Grade)
[![Current Tag](https://img.shields.io/github/v/tag/promhippie/prometheus-scw-sd?sort=semver)](https://github.com/promhippie/prometheus-scw-sd) [![General Build](https://github.com/promhippie/prometheus-scw-sd/workflows/general.yml/badge.svg)](https://github.com/promhippie/prometheus-scw-sd/actions/workflows/general.yaml) [![Join the Matrix chat at https://matrix.to/#/#webhippie:matrix.org](https://img.shields.io/badge/matrix-%23webhippie-7bc9a4.svg)](https://matrix.to/#/#webhippie:matrix.org) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/87cbb93f28be43a2a871018f106bc286)](https://www.codacy.com/gh/promhippie/prometheus-scw-sd/dashboard?utm_source=github.com&utm_medium=referral&utm_content=promhippie/prometheus-scw-sd&utm_campaign=Badge_Grade) [![Go Doc](https://godoc.org/github.com/promhippie/prometheus-scw-sd?status.svg)](http://godoc.org/github.com/promhippie/prometheus-scw-sd) [![Go Report](http://goreportcard.com/badge/github.com/promhippie/prometheus-scw-sd)](http://goreportcard.com/report/github.com/promhippie/prometheus-scw-sd)

This project provides a server to automatically discover nodes within your
Scaleway account in a Prometheus SD compatible format.

## Install

You can download prebuilt binaries from our [GitHub releases][releases]. Beside
that we are publishing Docker images to [Docker Hub][dockerhub] and
[Quay][quay]. If you need further guidance how to install this take a look at
our [documentation][docs].
You can download prebuilt binaries from our [GitHub releases][releases], or you
can use our containers published on [Docker Hub][dockerhub] and [Quay][quayio].
If you need further guidance how to install this take a look at our
[documentation][docs].

## Development

Expand Down Expand Up @@ -50,8 +50,8 @@ Apache-2.0
Copyright (c) 2018 Thomas Boerger <thomas@webhippie.de>
```

[releases]: https://github.com/promhippie/prometheus-scw-sd/releases
[dockerhub]: https://hub.docker.com/r/promhippie/prometheus-scw-sd/tags/
[quay]: https://quay.io/repository/promhippie/prometheus-scw-sd?tab=tags
[docs]: https://promhippie.github.io/prometheus-scw-sd/#getting-started
[releases]: https://github.com/promhippie/prometheus-hcloud-sd/releases
[dockerhub]: https://hub.docker.com/r/promhippie/prometheus-hcloud-sd/tags/
[quayio]: https://quay.io/repository/promhippie/prometheus-hcloud-sd?tab=tags
[docs]: https://promhippie.github.io/prometheus-hcloud-sd/#getting-started
[golang]: http://golang.org/doc/install.html
8 changes: 8 additions & 0 deletions changelog/1.2.0_2022-08-10/improved-docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enhancement: Improve doucmentation and repo structure

We have improved the available documentation pretty hard and we also added
documentation how to install this service discovery via Helm or Kustomize on
Kubernetes. Beside that we are testing to build the bundled Kustomize manifests
now.

https://github.com/promhippie/prometheus-scw-sd/pull/118
12 changes: 12 additions & 0 deletions deploy/kubernetes/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
name: prometheus-scw-sd
labels:
app.kubernetes.io/name: prometheus-scw-sd
app.kubernetes.io/component: exporter

spec:
replicas: 1
Expand All @@ -19,11 +20,13 @@ spec:
selector:
matchLabels:
app.kubernetes.io/name: prometheus-scw-sd
app.kubernetes.io/component: server

template:
metadata:
labels:
app.kubernetes.io/name: prometheus-scw-sd
app.kubernetes.io/component: server

spec:
restartPolicy: Always
Expand Down Expand Up @@ -55,4 +58,13 @@ spec:
path: /readyz
port: http

volumeMounts:
- name: files
mountPath: /etc/prometheus-scw-sd

volumes:
- name: files
configMap:
name: prometheus-scw-files

...
3 changes: 3 additions & 0 deletions deploy/kubernetes/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ configMapGenerator:
- name: prometheus-scw-sd
literals:
- PROMETHEUS_SCW_OUTPUT_ENGINE=http
- PROMETHEUS_SCW_OUTPUT_FILE=/etc/prometheus/scw.json

secretGenerator:
- name: prometheus-scw-sd
literals: []
- name: prometheus-scw-files
literals: []

images:
- name: prometheus-scw-sd
Expand Down
2 changes: 2 additions & 0 deletions deploy/kubernetes/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ metadata:
name: prometheus-scw-sd
labels:
app.kubernetes.io/name: prometheus-scw-sd
app.kubernetes.io/component: server

spec:
selector:
app.kubernetes.io/name: prometheus-scw-sd
app.kubernetes.io/component: server

ports:
- name: http
Expand Down
2 changes: 2 additions & 0 deletions deploy/kubernetes/servicemonitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
name: prometheus-scw-sd
labels:
app.kubernetes.io/name: prometheus-scw-sd
app.kubernetes.io/component: server

spec:
endpoints:
Expand All @@ -17,5 +18,6 @@ spec:
selector:
matchLabels:
app.kubernetes.io/name: prometheus-scw-sd
app.kubernetes.io/component: server

...
15 changes: 11 additions & 4 deletions docs/content/building.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
---
title: "Building"
date: 2020-04-01T00:00:00+00:00
date: 2022-07-20T00:00:00+00:00
anchor: "building"
weight: 20
---

As this project is built with Go you need to install Go first. The installation of Go is out of the scope of this document, please follow the [official documentation](https://golang.org/doc/install). After the installation of Go you need to get the sources:
As this project is built with Go you need to install Go first. The installation
of Go is out of the scope of this document, please follow the
[official documentation][golang]. After the installation of Go you need to get
the sources:

{{< highlight txt >}}
git clone https://github.com/promhippie/prometheus-scw-sd.git
cd prometheus-scw-sd/
{{< / highlight >}}

All required tool besides Go itself are bundled by Go modules, all you need is part of the `Makfile`:
All required tool besides Go itself are bundled, all you need is part of the
`Makfile`:

{{< highlight txt >}}
make generate build
{{< / highlight >}}

Finally you should have the binary within the `bin/` folder now, give it a try with `./bin/prometheus-scw-sd -h` to see all available options.
Finally you should have the binary within the `bin/` folder now, give it a try
with `./bin/prometheus-scw-sd -h` to see all available options.

[golang]: https://golang.org/doc/install
113 changes: 113 additions & 0 deletions docs/content/kubernetes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: "Kubernetes"
date: 2022-07-22T00:00:00+00:00
anchor: "kubernetes"
weight: 20
---

## Kubernetes

Currently we are covering the most famous installation methods on Kubernetes,
you can choose between [Kustomize][kustomize] and [Helm][helm].

### Kustomize

We won't cover the installation of [Kustomize][kustomize] within this guide, to
get it installed and working please read the upstream documentation. After the
installation of [Kustomize][kustomize] you just need to prepare a
`kustomization.yml` wherever you like similar to this:

{{< highlight yaml >}}
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: prometheus-scw-sd

resources:
- github.com/promhippie/prometheus-scw-sd//deploy/kubernetes?ref=master

configMapGenerator:
- name: prometheus-scw-sd
behavior: merge
literals: []

secretGenerator:
- name: prometheus-scw-sd
behavior: merge
literals: []
{{< / highlight >}}

After that you can simply execute `kustomize build | kubectl apply -f -` to get
the manifest applied. Generally it's best to use fixed versions of the container
images, this can be done quite easy, you just need to append this block to your
`kustomization.yml` to use this specific version:

{{< highlight yaml >}}
images:
- name: quay.io/promhippie/prometheus-scw-sd
newTag: 1.1.0
{{< / highlight >}}

After applying this manifest the exporter should be directly visible within your
Prometheus instance if you are using the Prometheus Operator as these manifests
are providing a ServiceMonitor.

To consume the service discovery within Prometheus you got to configre matching
scrape targets using the HTTP engine, just add a block similar to this one to
your Prometheus configuration:

{{< highlight yaml >}}
scrape_configs:
- job_name: node
http_sd_configs:
- url: http://scw-sd.prometheus-scw-sd.svc.cluster.local:9000/sd
relabel_configs:
- source_labels: [__meta_scaleway_public_ipv4]
replacement: "${1}:9100"
target_label: __address__
- source_labels: [__meta_scaleway_zone]
target_label: datacenter
- source_labels: [__meta_scaleway_name]
target_label: instance
{{< / highlight >}}

### Helm

We won't cover the installation of [Helm][helm] within this guide, to get it
installed and working please read the upstream documentation. After the
installation of [Helm][helm] you just need to execute the following commands:

{{< highlight console >}}
helm repo add promhippie https://promhippie.github.io/charts
helm show values promhippie/prometheus-vcd-sd
helm install prometheus-vcd-sd promhippie/prometheus-vcd-sd
{{< / highlight >}}

You can also watch that available values and generally the details of the chart
provided by us within our [chart][chart] repository.

After applying this manifest the exporter should be directly visible within your
Prometheus instance depending on your installation if you enabled the
annotations or the service monitor.

To consume the service discovery within Prometheus you got to configre matching
scrape targets using the HTTP engine, just add a block similar to this one to
your Prometheus configuration:

{{< highlight yaml >}}
scrape_configs:
- job_name: node
http_sd_configs:
- url: http://scw-sd.prometheus-scw-sd.svc.cluster.local:9000/sd
relabel_configs:
- source_labels: [__meta_scaleway_public_ipv4]
replacement: "${1}:9100"
target_label: __address__
- source_labels: [__meta_scaleway_zone]
target_label: datacenter
- source_labels: [__meta_scaleway_name]
target_label: instance
{{< / highlight >}}

[kustomize]: https://github.com/kubernetes-sigs/kustomize
[helm]: https://helm.sh
[chart]: https://github.com/promhippie/charts/tree/master/charts/prometheus-scw-sd
9 changes: 6 additions & 3 deletions docs/content/license.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
---
title: "License"
date: 2018-05-02T00:00:00+00:00
date: 2022-07-20T00:00:00+00:00
anchor: "license"
weight: 30
weight: 40
---

This project is licensed under the [Apache 2.0](https://github.com/promhippie/prometheus-scw-sd/blob/master/LICENSE) license. For the license of the used libraries you have to check the respective sources.
This project is licensed under the [Apache 2.0][license] license. For the
license of the used libraries you have to check the respective sources.

[license]: https://github.com/promhippie/prometheus-scw-sd/blob/master/LICENSE
Loading

0 comments on commit 2869e27

Please sign in to comment.