0

我正在关注此文档https://docs.microsoft.com/en-us/azure/aks/tutorial-kubernetes-monitor使用以下 yaml 文件在 AKS 上配置监控解决方案

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
 name: omsagent
spec:
 template:
  metadata:
   labels:
    app: omsagent
    agentVersion: 1.4.0-12
    dockerProviderVersion: 10.0.0-25
  spec:
   containers:
     - name: omsagent
       image: "microsoft/oms"
       imagePullPolicy: Always
       env:
       - name: WSID
         value: <WSID>
       - name: KEY
         value: <KEY>
       securityContext:
         privileged: true
       ports:
       - containerPort: 25225
         protocol: TCP
       - containerPort: 25224
         protocol: UDP
       volumeMounts:
        - mountPath: /var/run/docker.sock
          name: docker-sock
        - mountPath: /var/opt/microsoft/omsagent/state/containerhostname
          name: container-hostname
        - mountPath: /var/log
          name: host-log
        - mountPath: /var/lib/docker/containers/
          name: container-log
       livenessProbe:
        exec:
         command:
         - /bin/bash
         - -c
         - ps -ef | grep omsagent | grep -v "grep"
        initialDelaySeconds: 60
        periodSeconds: 60
   nodeSelector:
    beta.kubernetes.io/os: linux
   # Tolerate a NoSchedule taint on master that ACS Engine sets.
   tolerations:
    - key: "node-role.kubernetes.io/master"
      operator: "Equal"
      value: "true"
      effect: "NoSchedule"
   volumes:
    - name: docker-sock
      hostPath:
       path: /var/run/docker.sock
    - name: container-hostname
      hostPath:
       path: /etc/hostname
    - name: host-log
      hostPath:
       path: /var/log
    - name: container-log
      hostPath:
       path: /var/lib/docker/containers/

这失败并出现错误

error: error converting YAML to JSON: yaml: line 65: mapping values are not allowed in this context

我已经使用 yaml 验证器验证了该文件在语法上是正确的,不知道有什么问题?

这是 kubernetes 1.7 版 这也发生在 1.9 版

4

1 回答 1

0

该 yaml 文件对我有用:

[root@jasoncli@jasonye aksoms]# vi oms-daemonset.yaml
[root@jasoncli@jasonye aksoms]# kubectl create -f oms-daemonset.yaml 
daemonset "omsagent" created
[root@jasoncli@jasonye aksoms]# kubectl get daemonset
NAME       DESIRED   CURRENT   READY     UP-TO-DATE   AVAILABLE   NODE SELECTOR                 AGE
omsagent   1         1         0         1            0           beta.kubernetes.io/os=linux   1m

请使用此命令检查您的kubectl客户端版本,这kubectl version是我的输出:

[root@jasoncli@jasonye aksoms]# kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.5", GitCommit:"cce11c6a185279d037023e02ac5249e14daa22bf", GitTreeState:"clean", BuildDate:"2017-12-07T16:16:03Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.7", GitCommit:"8e1552342355496b62754e61ad5f802a0f3f1fa7", GitTreeState:"clean", BuildDate:"2017-09-28T23:56:03Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

您可以运行以下命令在本地az aks install-cli安装客户端。kubectl

更多关于安装 kubernetes 命令行客户端的信息,请参考这篇文章

于 2018-03-06T10:04:13.550 回答