Skip to content

Commit

Permalink
feat: metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mikouaj committed Jun 7, 2024
1 parent b1d2b44 commit 70a4491
Show file tree
Hide file tree
Showing 24 changed files with 473 additions and 189 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ COPY internal/controller/ internal/controller/
COPY internal/util/ internal/util/
COPY internal/webhook/ internal/webhook/
COPY internal/config/ internal/config/
COPY internal/metrics/ internal/metrics/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
Expand Down
4 changes: 3 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/google/kube-startup-cpu-boost/internal/boost"
"github.com/google/kube-startup-cpu-boost/internal/config"
"github.com/google/kube-startup-cpu-boost/internal/controller"
"github.com/google/kube-startup-cpu-boost/internal/metrics"
"github.com/google/kube-startup-cpu-boost/internal/util"
boostWebhook "github.com/google/kube-startup-cpu-boost/internal/webhook"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
Expand All @@ -60,8 +61,9 @@ func main() {
os.Exit(1)
}
ctrl.SetLogger(config.Logger(cfg.ZapDevelopment, cfg.ZapLogLevel))
tlsOpts := []func(*tls.Config){}
metrics.Register()

tlsOpts := []func(*tls.Config){}
webhookServer := webhook.NewServer(webhook.Options{
TLSOpts: tlsOpts,
Port: 9443,
Expand Down
39 changes: 0 additions & 39 deletions config/certmanager/certificate.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions config/certmanager/kustomization.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions config/certmanager/kustomizeconfig.yaml

This file was deleted.

46 changes: 20 additions & 26 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
# Adds namespace to all resources.
namespace: kube-startup-cpu-boost-system
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namespace: kube-startup-cpu-boost-system
namePrefix: kube-startup-cpu-boost-

# Labels to add to all resources and selectors.
#labels:
#- includeSelectors: true
# pairs:
# someName: someValue

resources:
- ../crd
- ../rbac
- ../manager
- ../internalcert
- ../webhook

# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
# [PROMETHEUS] To enable prometheus metrics collection, uncomment the following line
# NOTE: check resources inside prometheus folder to select desired collection method
#- ../prometheus

patchesStrategicMerge:
# Protect the /metrics endpoint by putting it behind auth.
# If you want your controller-manager to expose the /metrics
# endpoint w/o any authn/z, please comment the following line.
- manager_auth_proxy_patch.yaml

- manager_config_patch.yaml

# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
- manager_webhook_patch.yaml
patches:
- path: manager_config_patch.yaml
- path: manager_webhook_patch.yaml

# Uncomment below for development
# Uncomment below for local development
#- manager_config_dev_patch.yaml
50 changes: 0 additions & 50 deletions config/default/manager_auth_proxy_patch.yaml

This file was deleted.

14 changes: 14 additions & 0 deletions config/default/manager_config_dev_patch.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
14 changes: 14 additions & 0 deletions config/default/manager_config_patch.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
14 changes: 14 additions & 0 deletions config/default/manager_webhook_patch.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
29 changes: 0 additions & 29 deletions config/default/webhookcainjection_patch.yaml

This file was deleted.

35 changes: 35 additions & 0 deletions config/prometheus/gmp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Google Managed Prometheus collection
apiVersion: monitoring.googleapis.com/v1
kind: PodMonitoring
metadata:
labels:
control-plane: controller-manager
app.kubernetes.io/name:
app.kubernetes.io/instance: controller-manager-metrics-monitor
app.kubernetes.io/component: metrics
app.kubernetes.io/created-by: kube-startup-cpu-boost
app.kubernetes.io/part-of: kube-startup-cpu-boost
app.kubernetes.io/managed-by: kustomize
name: controller-manager-metrics-monitor
namespace: system
spec:
selector:
matchLabels:
control-plane: controller-manager
endpoints:
- port: 8080
interval: 30s
21 changes: 20 additions & 1 deletion config/prometheus/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Uncomment the desired metrics collection method
resources:
- monitor.yaml
# For Google Managed Prometheus PodMonitoring
- gmp.yaml

# For Prometheus ServiceMonitor
#- monitor.yaml
20 changes: 14 additions & 6 deletions config/prometheus/monitor.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Prometheus Monitor Service (Metrics)
apiVersion: monitoring.coreos.com/v1
Expand All @@ -15,12 +28,7 @@ metadata:
namespace: system
spec:
endpoints:
- path: /metrics
port: https
scheme: https
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
tlsConfig:
insecureSkipVerify: true
- targetPort: 8080
selector:
matchLabels:
control-plane: controller-manager
12 changes: 0 additions & 12 deletions config/samples/autoscaling_v1alpha1_startupcpuboost.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions config/samples/kustomization.yaml

This file was deleted.

Loading

0 comments on commit 70a4491

Please sign in to comment.