Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pressurecooker to multicooker #1

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
98af565
added helm chart
first-sportsbook Dec 7, 2022
1d1ba58
fix docker to run
first-sportsbook Dec 7, 2022
d9cb2a1
extend deployment
first-sportsbook Dec 7, 2022
346a78f
extracted prometheus metrics
first-sportsbook Dec 8, 2022
78ea4e4
clear some not needed param
first-sportsbook Dec 8, 2022
893a0e0
fix docker
first-sportsbook Dec 8, 2022
6fbd9d7
fixed issue with event.go to access /tmp for error
first-sportsbook Dec 9, 2022
d74be6c
init working state
first-sportsbook Dec 10, 2022
f2514d6
update k8s api packages
first-sportsbook Dec 11, 2022
e016317
lowering k8s api
first-sportsbook Dec 11, 2022
4353b8e
downgrade polycy only cos GKE doesnt work with it
first-sportsbook Dec 12, 2022
82b4348
pre rename
first-sportsbook Dec 13, 2022
e98bda8
rename
first-sportsbook Dec 13, 2022
20bd5fa
init squashed commit
first-sportsbook Dec 13, 2022
09b6672
Merge branch 'init'
first-sportsbook Dec 13, 2022
b399714
updateded Readme
first-sportsbook Dec 14, 2022
6d757f3
Added install section
first-sportsbook Dec 14, 2022
550f53f
fixed install command
first-sportsbook Dec 14, 2022
ef9ee62
added public img and fixed typo
first-sportsbook Dec 14, 2022
c057d8c
copy/paste is the root of all evil
first-sportsbook Dec 14, 2022
0169f77
Added NodeName to logs"
first-sportsbook Dec 14, 2022
908210e
Added Node name to metrics
first-sportsbook Dec 15, 2022
026c1ba
added podmonitor for metrics scraping
first-sportsbook Dec 19, 2022
21d97ee
Added a release version for metrics
first-sportsbook Dec 19, 2022
776b868
small cleanup
first-sportsbook Dec 23, 2022
01ed0ac
fixed fhe fork link
first-sportsbook Dec 23, 2022
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
Prev Previous commit
Next Next commit
small cleanup
first-sportsbook committed Dec 23, 2022
commit 776b86804758fff677c05f28ab7a53f4cd96bbd7
3 changes: 0 additions & 3 deletions chart/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -31,9 +31,6 @@ spec:
- containerPort: 8080
protocol: TCP
name: metrics
- containerPort: 80
protocol: TCP
name: web
env:
- name: NODE_NAME
valueFrom:
14 changes: 12 additions & 2 deletions chart/templates/pormonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.podMonitor.isEnabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
@@ -8,12 +9,21 @@ metadata:
app: kube-prometheus-stack-operator
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: kube-prometheus-stack
{{- range $key, $value := .Values.serviceMonitor.additionalLabels }}
{{- range $key, $value := .Values.podMonitor.additionalLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ include "chart.name" . }}
podMetricsEndpoints:
- port: metrics
- path: "/metrics"
- path: {{ .Values.podMonitor.endpoint }}}}
interval: {{ .Values.podMonitor.interval }}
{{- if .Values.podMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.podMonitor.scrapeTimeout }}
{{- end }}
{{- with .Values.podMonitor.relabelings }}
relabelings: {{ toYaml . | nindent 8 }}
{{- end }}
{{- end }}
17 changes: 16 additions & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
image:
repository: docmarr/kubernetes-multicooker
tag: "1.0.2"
tag: "1.0.3"
pullPolicy: Always

nameOverride: ""
@@ -30,3 +30,18 @@ nodeSelector: {}
tolerations: []

affinity: {}

podMonitor:
enabled: true
endpoint: "/metrics"
interval: 30s
scrapeTimeout: 10s
namespace: monitoring
additionalLabels:
release: "kube-prometheus-stack"
relabelings:
- sourceLabels: [__meta_kubernetes_pod_node_name]
separator: ;
targetLabel: instance
replacement: $1
action: replace
43 changes: 25 additions & 18 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -19,48 +19,55 @@ import (
"k8s.io/client-go/tools/clientcmd"
)

var f config.StartupFlags
var (
prometheusNamespace = "multicooker"
pressureThresholdExceededTotal,
pressureRecoveredTotal,
pressureThresholdExceeded,
pressureEnabled prometheus.Gauge
f config.StartupFlags
)

func init() {
flag.StringVar(&f.KubeConfig, "kubeconfig", "", "file path to kubeconfig")
flag.Float64Var(&f.TaintThreshold, "taint-threshold", 25, "pressure threshold value")
flag.Float64Var(&f.EvictThreshold, "evict-threshold", 50, "pressure threshold value")
flag.StringVar(&f.EvictBackoff, "evict-backoff", "10m", "time to wait between evicting Pods")
flag.StringVar(&f.MinPodAge, "min-pod-age", "5m", "minimum age of Pods to be evicted")
flag.StringVar(&f.NodeName, "node-name", "", "current node name")
flag.IntVar(&f.MetricsPort, "metrics-port", 8080, "port for prometheus metrics endpoint")
flag.IntVar(&f.TargetMetric, "target-metric", 3, "target metric to use / 10,60,300 for pressure; and 1,5,15 for avarage/")
flag.BoolVar(&f.UseAvarage, "use-avarage", false, "use loadavg instead of proc/pressure/cpu")
flag.Parse()

prometheusNamespace := "multicooker"
pressureThresholdExceeded = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: prometheusNamespace,
Name: fmt.Sprintf("pressure_threshold_exceeded_%s", f.NodeName),
Name: "pressure_threshold_exceeded",
Help: "cpu pressure is currently above (1) or below (0) threshold",
})
pressureThresholdExceededTotal = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: prometheusNamespace,
Name: fmt.Sprintf("pressure_threshold_exceeded_total_%s", f.NodeName),
Name: "pressure_threshold_exceeded_total",
Help: "number of times the pressure threshold was exceeded",
})
pressureRecoveredTotal = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: prometheusNamespace,
Name: fmt.Sprintf("pressure_recovered_total_%s", f.NodeName),
Name: "pressure_recovered_total",
Help: "number of times the pressure on the node recovered",
})
pressureEnabled = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: prometheusNamespace,
Name: fmt.Sprintf("enabled_%s", f.NodeName),
Name: "enabled",
Help: "multicooker is enabled (1) or disabled (0)",
})
)
}

func main() {
prometheus.MustRegister(pressureThresholdExceeded)
prometheus.MustRegister(pressureThresholdExceededTotal)
prometheus.MustRegister(pressureRecoveredTotal)
prometheus.MustRegister(pressureEnabled)

flag.StringVar(&f.KubeConfig, "kubeconfig", "", "file path to kubeconfig")
flag.Float64Var(&f.TaintThreshold, "taint-threshold", 25, "pressure threshold value")
flag.Float64Var(&f.EvictThreshold, "evict-threshold", 50, "pressure threshold value")
flag.StringVar(&f.EvictBackoff, "evict-backoff", "10m", "time to wait between evicting Pods")
flag.StringVar(&f.MinPodAge, "min-pod-age", "5m", "minimum age of Pods to be evicted")
flag.StringVar(&f.NodeName, "node-name", "", "current node name")
flag.IntVar(&f.MetricsPort, "metrics-port", 8080, "port for prometheus metrics endpoint")
flag.IntVar(&f.TargetMetric, "target-metric", 3, "target metric to use / 10,60,300 for pressure; and 1,5,15 for avarage/")
flag.BoolVar(&f.UseAvarage, "use-avarage", false, "use loadavg instead of proc/pressure/cpu")
flag.Parse()

if f.NodeName == "" {
panic("-node-name not set")
}