Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Add --listen-metrics flag for /metrics endpoint's port #1325

Merged
merged 1 commit into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func main() {
// This mirrors how kubectl extracts information from the environment.
var (
listenAddr = fs.StringP("listen", "l", ":3030", "Listen address where /metrics and API will be served")
listenMetricsAddr = fs.String("listen-metrics", "", "Listen address for /metrics endpoint")
kubernetesKubectl = fs.String("kubernetes-kubectl", "", "Optional, explicit path to kubectl tool")
versionFlag = fs.Bool("version", false, "Get version number")
// Git repo & key etc.
Expand Down Expand Up @@ -445,12 +446,24 @@ func main() {

go func() {
mux := http.DefaultServeMux
mux.Handle("/metrics", promhttp.Handler())
// Serve /metrics alongside API
if *listenMetricsAddr == "" {
mux.Handle("/metrics", promhttp.Handler())
}
handler := daemonhttp.NewHandler(daemon, daemonhttp.NewRouter())
mux.Handle("/api/flux/", http.StripPrefix("/api/flux", handler))
logger.Log("addr", *listenAddr)
errc <- http.ListenAndServe(*listenAddr, mux)
}()

if *listenMetricsAddr != "" {
go func() {
mux := http.NewServeMux()
mux.Handle("/metrics", promhttp.Handler())
logger.Log("metrics-addr", *listenMetricsAddr)
errc <- http.ListenAndServe(*listenMetricsAddr, mux)
}()
}

// Fall off the end, into the waiting procedure.
}
8 changes: 7 additions & 1 deletion deploy/flux-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
type: Recreate
template:
metadata:
annotations:
prometheus.io.port: "3031" # tell prometheus to scrape /metrics endpoint's port.
labels:
name: flux
spec:
Expand All @@ -34,7 +36,7 @@ spec:
# repo rather than using github or the like. You'll also need to
# mount it into the container, below.
# - name: ssh-config
# configMap:
# configMap:
# name: flux-ssh-config

containers:
Expand Down Expand Up @@ -78,3 +80,7 @@ spec:
# (e.g., Weave Cloud). The token is particular to the service.
# - --connect=wss://cloud.weave.works/api/flux
# - --token=abc123abc123abc123abc123

# serve /metrics endpoint at different port.
# make sure to set prometheus' annotation to scrape the port value.
- --listen-metrics=:3031
5 changes: 3 additions & 2 deletions site/daemon.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ Version controlling of cluster manifests provides reproducibility and a historic
Deployment happens automatically when a new image tag is detected.
Deautomated deployment will not proceed until manually released (through
the UI or the CLI tool fluxctl).

2.
Lock vs Unlock
Deployment is pinned to a particular image tag. New deployment will not
proceed upon triggered release.

# Flags

fluxd requires setup and offers customization though a multitude of flags.

|flag | default | purpose |
|------------------------|-------------------------------|---------|
|--listen -l | `:3030` | listen address where /metrics and API will be served|
|--listen-metrics | | listen address for /metrics endpoint |
|--kubernetes-kubectl | | optional, explicit path to kubectl tool|
|--version | false | output the version number and exit |
|**Git repo & key etc.** | ||
Expand Down