0

我配置为将 ArangoDB 的外部服务(用于监控 ArangoDB 指标)添加到 Prometheus 服务监视器。我还需要配置它,bearerTokenSecret因为它是连接到这个外部 ArangoDB 指标的唯一方法。但是,当我使用 terraform apply 进行部署时,我收到以下错误消息:

helm_release.arangodb-servicemonitor: Creating...
╷
│ Error: release arangodb-servicemonitor failed, and has been uninstalled due to atomic being set: Service "arangodb-servicemonitor" is invalid: spec.externalName: Invalid value: "abcd.arangodb.cloud:1234": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
│ 
│   with helm_release.arangodb-servicemonitor,
│   on prometheus.tf line 56, in resource "helm_release" "arangodb-servicemonitor":
│   56: resource "helm_release" "arangodb-servicemonitor" {
│ 
╵
make: *** [Makefile:63: apply] Error 1

错误

这是我关心的配置文件:

  1. /helm/charts/arangodb-servicemonitor/templates/service_monitor.tpl
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: arangodb-servicemonitor
  # Change this to the namespace the arangodb-servicemonitor instance is running in
  namespace: prometheus
  labels:
    serviceapp: arangodb-servicemonitor
    release: prometheus
spec:
  selector:
    matchLabels:
      # Targets arangodb service
      app: arangodb-servicemonitor
      release: prometheus
  endpoints:
    # TO DO: use an array (List) of endpoints to monitor many endpoints
    - port: metrics
      interval: 30s
      bearerTokenSecret:
        name: arangoDB-monitor-token
        key: token
  namespaceSelector:
    matchNames:
    # TO DO: use an array (List) of endpoints to monitor many endpoints
    - default
  1. /helm/charts/arangodb-servicemonitor/templates/endpoints.yaml
kind: Endpoints
apiVersion: v1
metadata:
  name: arangodb-servicemonitor
  labels:
    app: arangodb-servicemonitor
subsets:
- addresses:
  - ip: abcd.arangodb.cloud:1234
  ports: 
  - name: metrics
    port: 9000
    protocol: TCP
  1. /helm/charts/arangodb-servicemonitor/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: arangodb-servicemonitor
  namespace: prometheus
  labels:
    app: arangodb-servicemonitor
    release: prometheus
spec:
  type: ClusterIP
  externalName: abcd.arangodb.cloud:1234
  ports:
    - name: metrics
      port: 9000
      targetPort: 9000
      protocol: TCP
  type: ExternalName
  1. /helm/charts/arangodb-servicemonitor/Chart.yaml
#
#   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: v1
appVersion: "1.0.0"
description: Prometheus Service monitor
name: arangodb-servicemonitor
version: 1.0.0
  1. /terraform/kubernetes/prometheus.tf
resource "kubernetes_namespace" "prometheus" {
  metadata {
    name = "prometheus"
  }
}

resource "kubernetes_config_map" "prometheus_config" {
  metadata {
    name      = "prometheus-config"
    namespace = "prometheus"
  }

  data = {
    "prometheus.yml" = file("${path.module}/files/prometheus_config_map.yaml")
  }
  depends_on = [
    kubernetes_namespace.prometheus
  ]
}

# Values documentation: https://github.com/bitnami/charts/blob/master/bitnami/kube-prometheus/values.yaml
resource "helm_release" "prometheus" {
  name        = "prometheus"
  repository  = local.helm_repositories.bitnami
  chart       = "kube-prometheus"
  version     = "3.4.0"
  namespace   = "prometheus"
  atomic      = true
  max_history = 5

  values = [
    file("${path.module}/helm_values/security.yaml.tpl"),
    file("${path.module}/helm_values/prometheus.yaml")
  ]
  depends_on = [
    kubernetes_config_map.prometheus_config
  ]
}

# Values documentation: https://github.com/bitnami/charts/blob/master/bitnami/kube-prometheus/values.yaml
resource "helm_release" "jobs-manager-servicemonitor" {
  name        = "jobs-manager-servicemonitor"
  repository  = local.helm_repositories.local
  chart       = "jobs-manager-servicemonitor"
  version     = "1.0.1"
  namespace   = "prometheus"
  atomic      = true
  max_history = 5

  depends_on = [
    helm_release.prometheus
  ]
}

# Values documentation: https://github.com/bitnami/charts/blob/master/bitnami/kube-prometheus/values.yaml
resource "helm_release" "arangodb-servicemonitor" {
  name        = "arangodb-servicemonitor"
  repository  = local.helm_repositories.local
  chart       = "arangodb-servicemonitor"
  version     = "1.0.0"
  namespace   = "prometheus"
  atomic      = true
  max_history = 5

  depends_on = [
    helm_release.prometheus
  ]
}

你能告诉我如何解决这个错误吗?

4

0 回答 0