From eb47c664cad511cc5c62b9b6f658ea127fb35004 Mon Sep 17 00:00:00 2001 From: Oleg Strokachuk Date: Tue, 5 Oct 2021 13:04:42 +0300 Subject: [PATCH 1/6] Prometheus metrics: Allow to use ServiceMonitor --- build/Makefile | 24 +++++++- build/README.md | 21 +++++-- build/includes/kind.mk | 4 ++ build/includes/minikube.mk | 8 ++- build/prometheus-stack.yaml | 37 ++++++++++++ install/helm/agones/templates/controller.yaml | 9 ++- .../agones/templates/service-monitor.yaml | 56 +++++++++++++++++++ install/helm/agones/templates/service.yaml | 5 +- .../agones/templates/service/allocation.yaml | 49 +++++++++++++++- install/helm/agones/values.yaml | 10 ++++ install/yaml/install.yaml | 10 +++- site/content/en/docs/Guides/metrics.md | 20 ++----- .../docs/Installation/Install Agones/helm.md | 6 ++ 13 files changed, 231 insertions(+), 28 deletions(-) create mode 100644 build/prometheus-stack.yaml create mode 100644 install/helm/agones/templates/service-monitor.yaml diff --git a/build/Makefile b/build/Makefile index c1966e9d36..e1f789da4b 100644 --- a/build/Makefile +++ b/build/Makefile @@ -319,10 +319,11 @@ install: CRD_CLEANUP := true install: LOG_LEVEL := "debug" install: EXTERNAL_IP ?= $(shell $(DOCKER_RUN) kubectl get services agones-allocator -n agones-system -o jsonpath='{.status.loadBalancer.ingress[0].ip}') install: FEATURE_GATES ?= $(ALPHA_FEATURE_GATES) +install: SERVICE_MONITOR := false install: HELM_ARGS ?= install: $(ensure-build-image) install-custom-pull-secret $(DOCKER_RUN) \ - helm upgrade --install --atomic --namespace=agones-system \ + helm upgrade --install --atomic --wait --timeout 5m --namespace=agones-system \ --create-namespace \ --set agones.image.tag=$(VERSION),agones.image.registry=$(REGISTRY) \ --set agones.image.controller.pullPolicy=$(IMAGE_PULL_POLICY),agones.image.sdk.alwaysPull=$(ALWAYS_PULL_SIDECAR) \ @@ -333,6 +334,7 @@ install: $(ensure-build-image) install-custom-pull-secret --set agones.crds.cleanupOnDelete=$(CRD_CLEANUP) \ --set agones.featureGates=$(FEATURE_GATES) \ --set agones.allocator.service.loadBalancerIP=$(EXTERNAL_IP) \ + --set agones.metrics.serviceMonitor.enabled=$(SERVICE_MONITOR) \ $(HELM_ARGS) \ agones $(mount_path)/install/helm/agones/ @@ -553,6 +555,26 @@ uninstall-grafana: $(ensure-build-image) $(DOCKER_RUN) helm uninstall grafana --namespace=metrics $(DOCKER_RUN) kubectl delete -f $(mount_path)/build/grafana/ +# setup prometheus-stack in the current cluster by default Persistent Volume Claims are requested. +setup-prometheus-stack: PVC ?= true +setup-prometheus-stack: PV_SIZE ?= 64Gi +setup-prometheus-stack: SCRAPE_INTERVAL=30s +setup-prometheus-stack: PASSWORD ?= admin +setup-prometheus-stack: + $(DOCKER_RUN) helm repo add prometheus-community https://prometheus-community.github.io/helm-charts + $(DOCKER_RUN) helm repo update + $(DOCKER_RUN) helm upgrade prometheus-stack prometheus-community/kube-prometheus-stack --install --wait --version 19.0.2 \ + --namespace monitoring --create-namespace \ + --set prometheus.server.global.scrape_interval=$(SCRAPE_INTERVAL) \ + --set prometheus.server.persistentVolume.enabled=$(PVC) \ + --set prometheus.server.persistentVolume.size=$(PV_SIZE) \ + --set grafana.adminPassword=$(PASSWORD) \ + $(HELM_ARGS) -f $(mount_path)/build/prometheus-stack.yaml + +uninstall-prometheus-stack: $(ensure-build-image) + $(DOCKER_RUN) \ + helm uninstall prometheus-stack --namespace=monitoring + helm-repo-update: $(DOCKER_RUN) helm repo update diff --git a/build/README.md b/build/README.md index bd656ee7da..0d571aba33 100644 --- a/build/README.md +++ b/build/README.md @@ -46,6 +46,7 @@ Table of Contents * [make test-e2e-failure](#make-test-e2e-failure) * [make setup-prometheus](#make-setup-prometheus) * [make setup-grafana](#make-setup-grafana) + * [make setup-prometheus-stack](#make-setup-prometheus-stack) * [make prometheus-portforward](#make-prometheus-portforward) * [make grafana-portforward](#make-grafana-portforward) * [make controller-portforward](#make-controller-portforward) @@ -76,6 +77,7 @@ Table of Contents * [make minikube-install](#make-minikube-install) * [make minikube-setup-prometheus](#make-minikube-setup-prometheus) * [make minikube-setup-grafana](#make-minikube-setup-grafana) + * [make minikube-setup-prometheus-stack](#make-minikube-setup-prometheus) * [make minikube-prometheus-portforward](#make-minikube-prometheus-portforward) * [make minikube-grafana-portforward](#make-minikube-grafana-portforward) * [make minikube-test-e2e](#make-minikube-test-e2e) @@ -88,6 +90,7 @@ Table of Contents * [make kind-install](#make-kind-install) * [make kind-setup-prometheus](#make-kind-setup-prometheus) * [make kind-setup-grafana](#make-kind-setup-grafana) + * [make kind-setup-prometheus-stack](#make-kind-setup-prometheus-stack) * [make kind-prometheus-portforward](#make-kind-prometheus-portforward) * [make kind-grafana-portforward](#make-kind-grafana-portforward) * [make kind-test-e2e](#make-kind-test-e2e) @@ -485,7 +488,7 @@ Run controller failure portion of the end-to-end tests. #### `make setup-prometheus` -Install Prometheus server using [Prometheus Community](https://prometheus-community.github.io/helm-charts) +Install Prometheus server using [Prometheus Community](https://prometheus-community.github.io/helm-charts) chart into the current cluster. By default all exporters and alertmanager is disabled. @@ -500,7 +503,7 @@ Run helm repo update to get the mose recent charts. #### `make setup-grafana` -Install Grafana server using [grafana community](https://grafana.github.io/helm-charts) chart into +Install Grafana server using [grafana community](https://grafana.github.io/helm-charts) chart into the current cluster and setup [Agones dashboards with Prometheus datasource](./grafana/). You can set your own password using the `PASSWORD` environment variable. @@ -671,6 +674,11 @@ Use this instead of `make setup-prometheus`, as it disables Persistent Volume Cl Installs grafana into the Kubernetes cluster. Use this instead of `make setup-grafana`, as it disables Persistent Volume Claim. +#### `make minikube-setup-prometheus-stack` + +Installs prometheus-stack into the Kubernetes cluster. +Use this instead of `make setup-prometheus-stack`, as it disables Persistent Volume Claim. + #### `make minikube-prometheus-portforward` The minikube version of [`make prometheus-portforward`](#make-prometheus-portforward) to setup @@ -722,14 +730,19 @@ Use this instead of `make setup-prometheus`, as it disables Persistent Volume Cl Installs grafana into the Kubernetes cluster. Use this instead of `make setup-grafana`, as it disables Persistent Volume Claim. +#### `make kind-setup-prometheus-stack` + +Installs prometheus-stack into the Kubernetes cluster. +Use this instead of `make setup-prometheus-stack`, as it disables Persistent Volume Claim. + #### `make kind-prometheus-portforward` -The minikube version of [`make prometheus-portforward`](#make-prometheus-portforward) to setup +The kind version of [`make prometheus-portforward`](#make-prometheus-portforward) to setup port forwarding to the prometheus deployment. #### `make kind-grafana-portforward` -The minikube version of [`make grafana-portforward`](#make-grafana-portforward) to setup +The kind version of [`make grafana-portforward`](#make-grafana-portforward) to setup port forwarding to the grafana deployment. diff --git a/build/includes/kind.mk b/build/includes/kind.mk index 58ec71f54d..93ed3deac3 100644 --- a/build/includes/kind.mk +++ b/build/includes/kind.mk @@ -66,6 +66,10 @@ kind-setup-prometheus: kind-setup-grafana: $(MAKE) setup-grafana DOCKER_RUN_ARGS="--network=host" PVC=false +kind-setup-prometheus-stack: + $(MAKE) setup-prometheus-stack DOCKER_RUN_ARGS="--network=host" PVC=false \ + HELM_ARGS="--set prometheus.server.resources.requests.cpu=0,prometheus.server.resources.requests.memory=0" + # kind port forwarding controller web kind-controller-portforward: $(MAKE) controller-portforward DOCKER_RUN_ARGS="--network=host" diff --git a/build/includes/minikube.mk b/build/includes/minikube.mk index 49962f13dd..fd881405b5 100644 --- a/build/includes/minikube.mk +++ b/build/includes/minikube.mk @@ -67,13 +67,19 @@ minikube-setup-prometheus: DOCKER_RUN_ARGS="--network=host -v $(minikube_cert_mount)" \ PVC=false HELM_ARGS="--set server.resources.requests.cpu=0,server.resources.requests.memory=0" - # grafana on minkube with dashboards and prometheus datasource installed. # we have to disable PVC as it's not supported on minkube. minikube-setup-grafana: $(MAKE) setup-grafana \ DOCKER_RUN_ARGS="--network=host -v $(minikube_cert_mount)" +# prometheus-stack on minkube +# we have to disable PVC as it's not supported on minkube. +minikube-setup-prometheus-stack: + $(MAKE) setup-prometheus-stack \ + DOCKER_RUN_ARGS="--network=host -v $(minikube_cert_mount)" \ + PVC=false HELM_ARGS="--set prometheus.server.resources.requests.cpu=0,prometheus.server.resources.requests.memory=0" + # minikube port forwarding minikube-controller-portforward: $(MAKE) controller-portforward DOCKER_RUN_ARGS="--network=host -v $(minikube_cert_mount)" diff --git a/build/prometheus-stack.yaml b/build/prometheus-stack.yaml new file mode 100644 index 0000000000..67fe92da20 --- /dev/null +++ b/build/prometheus-stack.yaml @@ -0,0 +1,37 @@ +# disabled all not necessary chart +defaultRules: + enabled: false +alertmanager: + enabled: false +kubeApiServer: + enabled: false +kubelet: + enabled: false +kubeControllerManager: + enabled: false +coreDns: + enabled: false +kubeDns: + enabled: false +kubeEtcd: + enabled: false +kubeScheduler: + enabled: false +kubeProxy: + enabled: false +kubeStateMetrics: + enabled: false +nodeExporter: + enabled: false + +prometheusOperator: + enabled: true +prometheus: + enabled: true + prometheusSpec: + # allow discovery of third party service monitor + serviceMonitorSelectorNilUsesHelmValues: false +grafana: + enabled: true + adminUser: admin + adminPassword: admin diff --git a/install/helm/agones/templates/controller.yaml b/install/helm/agones/templates/controller.yaml index d3a3e11e3f..c2b8180f90 100644 --- a/install/helm/agones/templates/controller.yaml +++ b/install/helm/agones/templates/controller.yaml @@ -42,7 +42,7 @@ spec: {{- end }} {{- if and (.Values.agones.metrics.prometheusServiceDiscovery) (.Values.agones.metrics.prometheusEnabled) }} prometheus.io/scrape: "true" - prometheus.io/port: {{ .Values.agones.controller.http.port | quote }} + prometheus.io/port: "8080" prometheus.io/path: "/metrics" {{- end }} {{- if .Values.agones.controller.annotations }} @@ -129,10 +129,15 @@ spec: fieldPath: metadata.namespace - name: CONTAINER_NAME value: "agones-controller" + ports: + - name: webhooks + containerPort: 8081 + - name: http + containerPort: 8080 livenessProbe: httpGet: path: /live - port: {{ .Values.agones.controller.http.port }} + port: http initialDelaySeconds: {{ .Values.agones.controller.healthCheck.initialDelaySeconds }} periodSeconds: {{ .Values.agones.controller.healthCheck.periodSeconds }} failureThreshold: {{ .Values.agones.controller.healthCheck.failureThreshold }} diff --git a/install/helm/agones/templates/service-monitor.yaml b/install/helm/agones/templates/service-monitor.yaml new file mode 100644 index 0000000000..612e9d8443 --- /dev/null +++ b/install/helm/agones/templates/service-monitor.yaml @@ -0,0 +1,56 @@ +{{- if and (.Values.agones.metrics.prometheusEnabled) (.Values.agones.metrics.serviceMonitor.enabled) }} +# Copyright 2018 Google LLC All Rights Reserved. +# +# 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 +# +# http://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: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: agones-controller-monitor + namespace: {{ .Release.Namespace }} + labels: + agones.dev/role: controller + app: {{ template "agones.name" . }} + chart: {{ template "agones.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + selector: + matchLabels: + agones.dev/role: controller + endpoints: + - port: web + path: /metrics + interval: {{ .Values.agones.metrics.serviceMonitor.interval }} + relabelings: + - sourceLabels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape] + action: keep + regex: "true" + - sourceLabels: [__meta_kubernetes_pod_annotation_prometheus_io_path] + action: replace + targetLabel: __metrics_path__ + regex: (.+) + - sourceLabels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port] + action: replace + regex: ([^:]+)(?::\d+)?;(\d+) + replacement: $1:$2 + targetLabel: __address__ + - action: labelmap + regex: __meta_kubernetes_pod_label_(.+) + - sourceLabels: [__meta_kubernetes_namespace] + action: replace + targetLabel: kubernetes_namespace + - sourceLabels: [__meta_kubernetes_pod_name] + action: replace + targetLabel: kubernetes_pod_name +{{- end }} diff --git a/install/helm/agones/templates/service.yaml b/install/helm/agones/templates/service.yaml index 81691d4cea..31ccbb8792 100644 --- a/install/helm/agones/templates/service.yaml +++ b/install/helm/agones/templates/service.yaml @@ -29,6 +29,7 @@ spec: ports: - name: webhooks port: 443 - targetPort: 8081 + targetPort: webhooks - name: web - port: {{ .Values.agones.controller.http.port }} \ No newline at end of file + port: {{ .Values.agones.controller.http.port }} + targetPort: http diff --git a/install/helm/agones/templates/service/allocation.yaml b/install/helm/agones/templates/service/allocation.yaml index 84301adcb1..615008a9d3 100644 --- a/install/helm/agones/templates/service/allocation.yaml +++ b/install/helm/agones/templates/service/allocation.yaml @@ -63,7 +63,54 @@ spec: {{ toYaml .Values.agones.allocator.service.loadBalancerSourceRanges | indent 4 }} {{- end }} {{- end }} - +{{- if .Values.agones.allocator.service2.enabled }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.agones.allocator.service2.name }} + namespace: {{ .Release.Namespace }} + labels: + multicluster.agones.dev/role: allocator + app: {{ template "agones.name" . }} + chart: {{ template "agones.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if .Values.agones.allocator.service2.annotations }} + annotations: +{{ toYaml .Values.agones.allocator.service2.annotations | indent 4 }} +{{- end }} +spec: + selector: + multicluster.agones.dev/role: allocator + ports: + - port: {{ .Values.agones.allocator.service2.http.port }} + name: {{ .Values.agones.allocator.service2.http.portName }} + targetPort: 8080 + protocol: TCP +{{- end }} +{{- if and (.Values.agones.metrics.prometheusEnabled) (.Values.agones.metrics.serviceMonitor.enabled) }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: agones-allocator-monitor + namespace: {{ .Release.Namespace }} + labels: + multicluster.agones.dev/role: allocator + app: {{ template "agones.name" . }} + chart: {{ template "agones.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + selector: + matchLabels: + multicluster.agones.dev/role: allocator + endpoints: + - port: {{ .Values.agones.allocator.service2.http.portName }} + path: /metrics + interval: {{ .Values.agones.metrics.serviceMonitor.interval }} +{{- end }} --- # Deploy pods to run the agones-allocator code apiVersion: apps/v1 diff --git a/install/helm/agones/values.yaml b/install/helm/agones/values.yaml index 910ed40244..5678c0ee46 100644 --- a/install/helm/agones/values.yaml +++ b/install/helm/agones/values.yaml @@ -22,6 +22,9 @@ agones: stackdriverEnabled: false stackdriverProjectID: "" stackdriverLabels: "" + serviceMonitor: + enabled: false + interval: 30s rbacEnabled: true registerServiceAccounts: true registerWebhooks: true @@ -163,6 +166,13 @@ agones: port: 443 portName: grpc targetPort: 8443 + service2: + name: agones-allocator-service + annotations: {} + http: + enabled: true + port: 8080 + portName: http disableSecretCreation: false generateTLS: true generateClientTLS: true diff --git a/install/yaml/install.yaml b/install/yaml/install.yaml index 1a0e51e9be..e3f4480856 100644 --- a/install/yaml/install.yaml +++ b/install/yaml/install.yaml @@ -13150,9 +13150,10 @@ spec: ports: - name: webhooks port: 443 - targetPort: 8081 + targetPort: webhooks - name: web port: 8080 + targetPort: http --- # Source: agones/templates/service/allocation.yaml # Copyright 2019 Google LLC All Rights Reserved. @@ -13311,10 +13312,15 @@ spec: fieldPath: metadata.namespace - name: CONTAINER_NAME value: "agones-controller" + ports: + - name: webhooks + containerPort: 8081 + - name: http + containerPort: 8080 livenessProbe: httpGet: path: /live - port: 8080 + port: http initialDelaySeconds: 3 periodSeconds: 3 failureThreshold: 3 diff --git a/site/content/en/docs/Guides/metrics.md b/site/content/en/docs/Guides/metrics.md index 99037a5d73..c7b4f77d00 100644 --- a/site/content/en/docs/Guides/metrics.md +++ b/site/content/en/docs/Guides/metrics.md @@ -19,25 +19,15 @@ If you are running a [Prometheus](https://prometheus.io/) instance you just need ### Prometheus Operator -If you have [Prometheus operator](https://github.com/coreos/prometheus-operator) installed in your cluster, make sure to add a [`ServiceMonitor`](https://github.com/coreos/prometheus-operator/blob/v0.17.0/Documentation/api.md#servicemonitorspec) to discover Agones metrics as shown below: +If you have [Prometheus operator](https://github.com/coreos/prometheus-operator) installed in your cluster, just enable ServiceMonitor installation in values: ```yaml -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - name: agones - labels: - app: agones -spec: - selector: - matchLabels: - agones.dev/role: controller - endpoints: - - port: web +agones: + metrics: + serviceMonitor: + enabled: true ``` -Finally include that `ServiceMonitor` in your [Prometheus instance CRD](https://github.com/coreos/prometheus-operator/blob/v0.17.0/Documentation/user-guides/getting-started.md#include-servicemonitors), this is usually done by adding a label to the `ServiceMonitor` above that is matched by the prometheus instance of your choice. - ### Stackdriver We support the [OpenCensus Stackdriver exporter](https://opencensus.io/exporters/supported-exporters/go/stackdriver/). diff --git a/site/content/en/docs/Installation/Install Agones/helm.md b/site/content/en/docs/Installation/Install Agones/helm.md index 1792815279..7d515b71d7 100644 --- a/site/content/en/docs/Installation/Install Agones/helm.md +++ b/site/content/en/docs/Installation/Install Agones/helm.md @@ -190,6 +190,8 @@ The following tables lists the configurable parameters of the Agones chart and t | Parameter | Description | Default | | --------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ---------------------- | +| `agones.metrics.serviceMonitor.enabled` | Enables ServiceMonitor installation for metrics auto-discovery with prometheus-operator | `false` | +| `agones.metrics.serviceMonitor.interval` | Default scraping interval for ServiceMonitor | `30s` | | `agones.allocator.service.name` | Service name for the allocator | `agones-allocator` | | `agones.allocator.service.serviceType` | The [Service Type][service] of the HTTP Service | `LoadBalancer` | | `agones.allocator.service.loadBalancerIP` | The [Load Balancer IP][loadBalancer] of the Agones allocator load balancer. Only works if the Kubernetes provider supports this option. | \`\` | @@ -201,6 +203,10 @@ The following tables lists the configurable parameters of the Agones chart and t | `agones.allocator.service.grpc.enabled` | If true the [allocator service][allocator] will respond to [gRPC requests][grpc-requests] | `true` | | `agones.allocator.service.grpc.port` | The port that is exposed externally by the [allocator service][allocator] for [gRPC requests][grpc-requests] | `443` | | `agones.allocator.service.grpc.targetPort` | The port that is used by the allocator pod to listen for [gRPC requests][grpc-requests]. Note that the allocator server cannot bind to low numbered ports. | `8443` | +| `agones.allocator.service2.name` | Second Service name for the allocator | `agones-allocator-service` | +| `agones.allocator.service2.annotations` | [Annotations][annotations] added to the Agones allocator second Service | `{}` | +| `agones.allocator.service2.http.port` | The port that is exposed externally by the [allocator service][allocator] for http requests | `8080` | +| `agones.allocator.service2.http.portName` | The name of exposed port | `http` | | | | | {{% /feature %}} From 1d9867f688b69a69fb637bd6c4f39887435944fb Mon Sep 17 00:00:00 2001 From: Oleg Strokachuk Date: Thu, 14 Oct 2021 23:59:22 +0300 Subject: [PATCH 2/6] 2262 fix review notes --- build/Makefile | 2 +- build/README.md | 10 ++++++++++ site/content/en/docs/Guides/metrics.md | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/build/Makefile b/build/Makefile index e1f789da4b..77d0cb76a5 100644 --- a/build/Makefile +++ b/build/Makefile @@ -323,7 +323,7 @@ install: SERVICE_MONITOR := false install: HELM_ARGS ?= install: $(ensure-build-image) install-custom-pull-secret $(DOCKER_RUN) \ - helm upgrade --install --atomic --wait --timeout 5m --namespace=agones-system \ + helm upgrade --install --atomic --wait --namespace=agones-system \ --create-namespace \ --set agones.image.tag=$(VERSION),agones.image.registry=$(REGISTRY) \ --set agones.image.controller.pullPolicy=$(IMAGE_PULL_POLICY),agones.image.sdk.alwaysPull=$(ALWAYS_PULL_SIDECAR) \ diff --git a/build/README.md b/build/README.md index 0d571aba33..186efedb30 100644 --- a/build/README.md +++ b/build/README.md @@ -510,6 +510,16 @@ You can set your own password using the `PASSWORD` environment variable. See [`make minikube-setup-grafana`](#make-minikube-setup-grafana) and [`make kind-setup-grafana`](#make-kind-setup-grafana) to run the installation on Minikube or Kind. +#### `make setup-prometheus-stack` + +Install Prometheus-stack using [Prometheus Community](https://prometheus-community.github.io/helm-charts) chart into the current cluster. + +By default only prometheus and grafana will installed, all exporters and alertmanager is disabled. + +You can use this to collect Agones [Metrics](../site/content/en/docs/Guides/metrics.md) using ServiceMonitor. + +See [`make minikube-setup-prometheus-stack`](#make-minikube-setup-prometheus-stack) and [`make kind-setup-prometheus-stack`](#make-kind-setup-prometheus-stack) to run the installation on Minikube or Kind. + #### `make prometheus-portforward` Sets up port forwarding to the diff --git a/site/content/en/docs/Guides/metrics.md b/site/content/en/docs/Guides/metrics.md index c7b4f77d00..43ce9dd4a5 100644 --- a/site/content/en/docs/Guides/metrics.md +++ b/site/content/en/docs/Guides/metrics.md @@ -17,6 +17,7 @@ We plan to support multiple exporters in the future via environment variables an If you are running a [Prometheus](https://prometheus.io/) instance you just need to ensure that metrics and kubernetes service discovery are enabled. (helm chart values `agones.metrics.prometheusEnabled` and `agones.metrics.prometheusServiceDiscovery`). This will automatically add annotations required by Prometheus to discover Agones metrics and start collecting them. (see [example](https://github.com/prometheus/prometheus/tree/main/documentation/examples/kubernetes-rabbitmq)) +{{% feature publishVersion="1.19.0" %}} ### Prometheus Operator If you have [Prometheus operator](https://github.com/coreos/prometheus-operator) installed in your cluster, just enable ServiceMonitor installation in values: @@ -28,6 +29,7 @@ agones: enabled: true ``` +{{% /feature %}} ### Stackdriver We support the [OpenCensus Stackdriver exporter](https://opencensus.io/exporters/supported-exporters/go/stackdriver/). From 3c758f0bc1a60617b92c9938cd283db196cce2b1 Mon Sep 17 00:00:00 2001 From: Oleg Strokachuk Date: Fri, 15 Oct 2021 00:06:47 +0300 Subject: [PATCH 3/6] 2262 rename service2 to serviceInternal --- .../helm/agones/templates/service/allocation.yaml | 14 +++++++------- install/helm/agones/values.yaml | 2 +- .../en/docs/Installation/Install Agones/helm.md | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/install/helm/agones/templates/service/allocation.yaml b/install/helm/agones/templates/service/allocation.yaml index 615008a9d3..2bdf5cce4a 100644 --- a/install/helm/agones/templates/service/allocation.yaml +++ b/install/helm/agones/templates/service/allocation.yaml @@ -63,12 +63,12 @@ spec: {{ toYaml .Values.agones.allocator.service.loadBalancerSourceRanges | indent 4 }} {{- end }} {{- end }} -{{- if .Values.agones.allocator.service2.enabled }} +{{- if .Values.agones.allocator.serviceInternal.enabled }} --- apiVersion: v1 kind: Service metadata: - name: {{ .Values.agones.allocator.service2.name }} + name: {{ .Values.agones.allocator.serviceInternal.name }} namespace: {{ .Release.Namespace }} labels: multicluster.agones.dev/role: allocator @@ -76,16 +76,16 @@ metadata: chart: {{ template "agones.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} -{{- if .Values.agones.allocator.service2.annotations }} +{{- if .Values.agones.allocator.serviceInternal.annotations }} annotations: -{{ toYaml .Values.agones.allocator.service2.annotations | indent 4 }} +{{ toYaml .Values.agones.allocator.serviceInternal.annotations | indent 4 }} {{- end }} spec: selector: multicluster.agones.dev/role: allocator ports: - - port: {{ .Values.agones.allocator.service2.http.port }} - name: {{ .Values.agones.allocator.service2.http.portName }} + - port: {{ .Values.agones.allocator.serviceInternal.http.port }} + name: {{ .Values.agones.allocator.serviceInternal.http.portName }} targetPort: 8080 protocol: TCP {{- end }} @@ -107,7 +107,7 @@ spec: matchLabels: multicluster.agones.dev/role: allocator endpoints: - - port: {{ .Values.agones.allocator.service2.http.portName }} + - port: {{ .Values.agones.allocator.serviceInternal.http.portName }} path: /metrics interval: {{ .Values.agones.metrics.serviceMonitor.interval }} {{- end }} diff --git a/install/helm/agones/values.yaml b/install/helm/agones/values.yaml index 78dc19063f..e8b205467a 100644 --- a/install/helm/agones/values.yaml +++ b/install/helm/agones/values.yaml @@ -166,7 +166,7 @@ agones: port: 443 portName: grpc targetPort: 8443 - service2: + serviceInternal: name: agones-allocator-service annotations: {} http: diff --git a/site/content/en/docs/Installation/Install Agones/helm.md b/site/content/en/docs/Installation/Install Agones/helm.md index cd477f2ebe..a18613770e 100644 --- a/site/content/en/docs/Installation/Install Agones/helm.md +++ b/site/content/en/docs/Installation/Install Agones/helm.md @@ -199,10 +199,10 @@ The following tables lists the configurable parameters of the Agones chart and t | --------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ---------------------- | | `agones.metrics.serviceMonitor.enabled` | Enables ServiceMonitor installation for metrics auto-discovery with prometheus-operator | `false` | | `agones.metrics.serviceMonitor.interval` | Default scraping interval for ServiceMonitor | `30s` | -| `agones.allocator.service2.name` | Second Service name for the allocator | `agones-allocator-service` | -| `agones.allocator.service2.annotations` | [Annotations][annotations] added to the Agones allocator second Service | `{}` | -| `agones.allocator.service2.http.port` | The port that is exposed within cluster by the [allocator service][allocator] for http requests | `8080` | -| `agones.allocator.service2.http.portName` | The name of exposed port | `http` | +| `agones.allocator.serviceInternal.name` | Second Service name for the allocator | `agones-allocator-service` | +| `agones.allocator.serviceInternal.annotations` | [Annotations][annotations] added to the Agones allocator second Service | `{}` | +| `agones.allocator.serviceInternal.http.port` | The port that is exposed within cluster by the [allocator service][allocator] for http requests | `8080` | +| `agones.allocator.serviceInternal.http.portName` | The name of exposed port | `http` | | | | | {{% /feature %}} From f7e9dfb02ed70869fe8352d456c68e28794f8b8c Mon Sep 17 00:00:00 2001 From: Oleg Strokachuk Date: Tue, 19 Oct 2021 11:38:40 +0300 Subject: [PATCH 4/6] Fix review notes --- site/content/en/docs/Guides/metrics.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/site/content/en/docs/Guides/metrics.md b/site/content/en/docs/Guides/metrics.md index 43ce9dd4a5..6658124a47 100644 --- a/site/content/en/docs/Guides/metrics.md +++ b/site/content/en/docs/Guides/metrics.md @@ -17,6 +17,31 @@ We plan to support multiple exporters in the future via environment variables an If you are running a [Prometheus](https://prometheus.io/) instance you just need to ensure that metrics and kubernetes service discovery are enabled. (helm chart values `agones.metrics.prometheusEnabled` and `agones.metrics.prometheusServiceDiscovery`). This will automatically add annotations required by Prometheus to discover Agones metrics and start collecting them. (see [example](https://github.com/prometheus/prometheus/tree/main/documentation/examples/kubernetes-rabbitmq)) +{{% feature expiryVersion="1.19.0" %}} +### Prometheus Operator + +### Prometheus Operator + +If you have [Prometheus operator](https://github.com/coreos/prometheus-operator) installed in your cluster, make sure to add a [`ServiceMonitor`](https://github.com/coreos/prometheus-operator/blob/v0.17.0/Documentation/api.md#servicemonitorspec) to discover Agones metrics as shown below: + +```yaml +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: agones + labels: + app: agones +spec: + selector: + matchLabels: + agones.dev/role: controller + endpoints: + - port: web +``` + +Finally include that `ServiceMonitor` in your [Prometheus instance CRD](https://github.com/coreos/prometheus-operator/blob/v0.17.0/Documentation/user-guides/getting-started.md#include-servicemonitors), this is usually done by adding a label to the `ServiceMonitor` above that is matched by the prometheus instance of your choice. + +{{% /feature %}} {{% feature publishVersion="1.19.0" %}} ### Prometheus Operator From a11b710039f21830efac446025fa5e0811a6714a Mon Sep 17 00:00:00 2001 From: Oleg Strokachuk Date: Tue, 19 Oct 2021 11:41:15 +0300 Subject: [PATCH 5/6] Remove unnecessary header --- site/content/en/docs/Guides/metrics.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/site/content/en/docs/Guides/metrics.md b/site/content/en/docs/Guides/metrics.md index 6658124a47..47ee226a76 100644 --- a/site/content/en/docs/Guides/metrics.md +++ b/site/content/en/docs/Guides/metrics.md @@ -20,8 +20,6 @@ If you are running a [Prometheus](https://prometheus.io/) instance you just need {{% feature expiryVersion="1.19.0" %}} ### Prometheus Operator -### Prometheus Operator - If you have [Prometheus operator](https://github.com/coreos/prometheus-operator) installed in your cluster, make sure to add a [`ServiceMonitor`](https://github.com/coreos/prometheus-operator/blob/v0.17.0/Documentation/api.md#servicemonitorspec) to discover Agones metrics as shown below: ```yaml From f3c4feba16716197b5cc85173109713d6a8e3e09 Mon Sep 17 00:00:00 2001 From: Oleg Strokachuk Date: Wed, 20 Oct 2021 23:47:58 +0300 Subject: [PATCH 6/6] Fix review notes --- .../agones/templates/service/allocation.yaml | 14 ++++++------- install/helm/agones/values.yaml | 4 ++-- install/yaml/install.yaml | 21 +++++++++++++++++++ .../docs/Installation/Install Agones/helm.md | 9 ++++---- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/install/helm/agones/templates/service/allocation.yaml b/install/helm/agones/templates/service/allocation.yaml index 2bdf5cce4a..bd28c552b3 100644 --- a/install/helm/agones/templates/service/allocation.yaml +++ b/install/helm/agones/templates/service/allocation.yaml @@ -63,12 +63,11 @@ spec: {{ toYaml .Values.agones.allocator.service.loadBalancerSourceRanges | indent 4 }} {{- end }} {{- end }} -{{- if .Values.agones.allocator.serviceInternal.enabled }} --- apiVersion: v1 kind: Service metadata: - name: {{ .Values.agones.allocator.serviceInternal.name }} + name: {{ .Values.agones.allocator.serviceMetrics.name }} namespace: {{ .Release.Namespace }} labels: multicluster.agones.dev/role: allocator @@ -76,19 +75,18 @@ metadata: chart: {{ template "agones.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} -{{- if .Values.agones.allocator.serviceInternal.annotations }} +{{- if .Values.agones.allocator.serviceMetrics.annotations }} annotations: -{{ toYaml .Values.agones.allocator.serviceInternal.annotations | indent 4 }} +{{ toYaml .Values.agones.allocator.serviceMetrics.annotations | indent 4 }} {{- end }} spec: selector: multicluster.agones.dev/role: allocator ports: - - port: {{ .Values.agones.allocator.serviceInternal.http.port }} - name: {{ .Values.agones.allocator.serviceInternal.http.portName }} + - port: {{ .Values.agones.allocator.serviceMetrics.http.port }} + name: {{ .Values.agones.allocator.serviceMetrics.http.portName }} targetPort: 8080 protocol: TCP -{{- end }} {{- if and (.Values.agones.metrics.prometheusEnabled) (.Values.agones.metrics.serviceMonitor.enabled) }} --- apiVersion: monitoring.coreos.com/v1 @@ -107,7 +105,7 @@ spec: matchLabels: multicluster.agones.dev/role: allocator endpoints: - - port: {{ .Values.agones.allocator.serviceInternal.http.portName }} + - port: {{ .Values.agones.allocator.serviceMetrics.http.portName }} path: /metrics interval: {{ .Values.agones.metrics.serviceMonitor.interval }} {{- end }} diff --git a/install/helm/agones/values.yaml b/install/helm/agones/values.yaml index 2c1aa44593..0c9b6cbcf3 100644 --- a/install/helm/agones/values.yaml +++ b/install/helm/agones/values.yaml @@ -167,8 +167,8 @@ agones: port: 443 portName: grpc targetPort: 8443 - serviceInternal: - name: agones-allocator-service + serviceMetrics: + name: agones-allocator-metrics-service annotations: {} http: enabled: true diff --git a/install/yaml/install.yaml b/install/yaml/install.yaml index eb97cd6eaa..3e344097f1 100644 --- a/install/yaml/install.yaml +++ b/install/yaml/install.yaml @@ -13191,6 +13191,27 @@ spec: protocol: TCP type: LoadBalancer --- +# Source: agones/templates/service/allocation.yaml +apiVersion: v1 +kind: Service +metadata: + name: agones-allocator-metrics-service + namespace: agones-system + labels: + multicluster.agones.dev/role: allocator + app: agones + chart: agones-1.19.0-dev + release: agones-manual + heritage: Helm +spec: + selector: + multicluster.agones.dev/role: allocator + ports: + - port: 8080 + name: http + targetPort: 8080 + protocol: TCP +--- # Source: agones/templates/controller.yaml # Copyright 2018 Google LLC All Rights Reserved. # diff --git a/site/content/en/docs/Installation/Install Agones/helm.md b/site/content/en/docs/Installation/Install Agones/helm.md index 1db87f6345..a98209d57d 100644 --- a/site/content/en/docs/Installation/Install Agones/helm.md +++ b/site/content/en/docs/Installation/Install Agones/helm.md @@ -198,12 +198,11 @@ The following tables lists the configurable parameters of the Agones chart and t | Parameter | Description | Default | | --------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ---------------------- | | `agones.serviceaccount.sdk.annotations` | A map of namespaces to maps of [Annotations][annotations] added to the Agones SDK service account for the specified namespaces | `{}` | -| `agones.metrics.serviceMonitor.enabled` | Enables ServiceMonitor installation for metrics auto-discovery with prometheus-operator | `false` | | `agones.metrics.serviceMonitor.interval` | Default scraping interval for ServiceMonitor | `30s` | -| `agones.allocator.serviceInternal.name` | Second Service name for the allocator | `agones-allocator-service` | -| `agones.allocator.serviceInternal.annotations` | [Annotations][annotations] added to the Agones allocator second Service | `{}` | -| `agones.allocator.serviceInternal.http.port` | The port that is exposed within cluster by the [allocator service][allocator] for http requests | `8080` | -| `agones.allocator.serviceInternal.http.portName` | The name of exposed port | `http` | +| `agones.allocator.serviceMetrics.name` | Second Service name for the allocator | `agones-allocator-metrics-service` | +| `agones.allocator.serviceMetrics.annotations` | [Annotations][annotations] added to the Agones allocator second Service | `{}` | +| `agones.allocator.serviceMetrics.http.port` | The port that is exposed within cluster by the [allocator service][allocator] for http requests | `8080` | +| `agones.allocator.serviceInternal.http.portName` | The name of exposed port | `http` | | | | | {{% /feature %}}