配置Azure日志分析

时间:2018-03-05 16:03:13

标签: azure kubernetes yaml azure-log-analytics

我正在关注此文档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

也会发生这种情况

1 个答案:

答案 0 :(得分: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命令行客户端的更多信息,请参阅此article