Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 解析YAML文件/etc/prometheus/prometheus.yml:YAML:line 20:在此上下文中不允许映射值;_Kubernetes_Yaml_Prometheus - Fatal编程技术网

Kubernetes 解析YAML文件/etc/prometheus/prometheus.yml:YAML:line 20:在此上下文中不允许映射值;

Kubernetes 解析YAML文件/etc/prometheus/prometheus.yml:YAML:line 20:在此上下文中不允许映射值;,kubernetes,yaml,prometheus,Kubernetes,Yaml,Prometheus,我正在将一个新的prometheus pod部署到一个现有的名称空间中,我准备了clusterRole配置和configMap,在我在kubernetes中创建部署之前,一切都正常。 pod创建后崩溃,k8s日志显示此错误 err="error loading config from \"/etc/prometheus/prometheus.yml\": couldn't load configuration (--config.file=\"/etc/prometheus/prometheus

我正在将一个新的prometheus pod部署到一个现有的名称空间中,我准备了clusterRole配置和configMap,在我在kubernetes中创建部署之前,一切都正常。 pod创建后崩溃,k8s日志显示此错误

err="error loading config from \"/etc/prometheus/prometheus.yml\": couldn't load configuration (--config.file=\"/etc/prometheus/prometheus.yml\"): parsing YAML file /etc/prometheus/prometheus.yml: yaml: line 20: mapping values are not allowed in this context"
有人知道怎么解决这个问题吗

这是我的部署YAML文件

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: prometheus-deployment
  namespace: default
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: prometheus-server
    spec:
      containers:
        - name: prometheus
          image: prom/prometheus
          args:
            - "--config.file=/etc/prometheus/prometheus.yml" 
            - "--storage.tsdb.path=/prometheus" 
            - "--web.console.libraries=/usr/share/prometheus/console_libraries" 
            - "--web.console.templates=/usr/share/prometheus/consoles"
          ports:
            - containerPort: 9090
          volumeMounts:
            - name: prometheus-config-volume
              mountPath: /etc/prometheus/
            - name: prometheus-storage-volume
              mountPath: /prometheus/
      volumes:
        - name: prometheus-config-volume
          configMap:
            defaultMode: 420
            name: prometheus-server-conf

        - name: prometheus-storage-volume
          emptyDir: {}
这是k8s的错误日志


level=info ts=2019-11-08T08:59:43.155Z caller=main.go:296 msg="no time or size retention was set so using the default time retention" duration=15d
level=info ts=2019-11-08T08:59:43.156Z caller=main.go:332 msg="Starting Prometheus" version="(version=2.13.1, branch=HEAD, revision=6f92ce56053866194ae5937012c1bec40f1dd1d9)"
level=info ts=2019-11-08T08:59:43.156Z caller=main.go:333 build_context="(go=go1.13.1, user=root@88e419aa1676, date=20191017-13:15:01)"
level=info ts=2019-11-08T08:59:43.156Z caller=main.go:334 host_details="(Linux 4.15.0 #1 SMP Sun Jun 23 23:02:01 PDT 2019 x86_64 prometheus-deployment-6568ff7b6b-jvfsl (none))"
level=info ts=2019-11-08T08:59:43.156Z caller=main.go:335 fd_limits="(soft=1048576, hard=1048576)"
level=info ts=2019-11-08T08:59:43.156Z caller=main.go:336 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2019-11-08T08:59:43.161Z caller=main.go:657 msg="Starting TSDB ..."
level=info ts=2019-11-08T08:59:43.161Z caller=web.go:450 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2019-11-08T08:59:43.191Z caller=head.go:514 component=tsdb msg="replaying WAL, this may take awhile"
level=info ts=2019-11-08T08:59:43.192Z caller=head.go:562 component=tsdb msg="WAL segment loaded" segment=0 maxSegment=1
level=info ts=2019-11-08T08:59:43.192Z caller=head.go:562 component=tsdb msg="WAL segment loaded" segment=1 maxSegment=1
level=info ts=2019-11-08T08:59:43.193Z caller=main.go:672 fs_type=EXT4_SUPER_MAGIC
level=info ts=2019-11-08T08:59:43.193Z caller=main.go:673 msg="TSDB started"
level=info ts=2019-11-08T08:59:43.193Z caller=main.go:743 msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml
level=info ts=2019-11-08T08:59:43.193Z caller=main.go:526 msg="Stopping scrape discovery manager..."
level=info ts=2019-11-08T08:59:43.193Z caller=main.go:540 msg="Stopping notify discovery manager..."
level=info ts=2019-11-08T08:59:43.193Z caller=main.go:562 msg="Stopping scrape manager..."
level=info ts=2019-11-08T08:59:43.193Z caller=manager.go:814 component="rule manager" msg="Stopping rule manager..."
level=info ts=2019-11-08T08:59:43.193Z caller=manager.go:820 component="rule manager" msg="Rule manager stopped"
level=info ts=2019-11-08T08:59:43.193Z caller=main.go:536 msg="Notify discovery manager stopped"
level=info ts=2019-11-08T08:59:43.193Z caller=main.go:522 msg="Scrape discovery manager stopped"
level=info ts=2019-11-08T08:59:43.193Z caller=main.go:556 msg="Scrape manager stopped"
level=info ts=2019-11-08T08:59:43.193Z caller=notifier.go:602 component=notifier msg="Stopping notification manager..."
level=info ts=2019-11-08T08:59:43.194Z caller=main.go:727 msg="Notifier manager stopped"
level=error ts=2019-11-08T08:59:43.194Z caller=main.go:736 err="error loading config from \"/etc/prometheus/prometheus.yml\": couldn't load configuration (--config.file=\"/etc/prometheus/prometheus.yml\"): parsing YAML file /etc/prometheus/prometheus.yml: yaml: line 20: mapping values are not allowed in this context"

错误表明
/etc/prometheus/prometheus.yml
的内容格式不正确。确保该文件包含有效的YAML应该可以解决您的问题


根据您的部署判断,prometheus服务器confConfigMap安装在
/etc/prometheus/
上,因此该ConfigMap中键
prometheus.yml
下的任何内容都可能是罪魁祸首。

您显示了一个kubernetes YAML文件,但是,错误在
prometheus.yml
中,因此您应该显示它。@flyx prometheus.yml是从prometheus映像中提交的:/etc/prometheus/prometheus.yml不在我的本地机器中。您的配置意味着
prometheus.yml
来自configMap
prometheus服务器配置。