无法识别“ filebeat-kubernetes.yaml”:版本“ extensions / v1beta1”中与种类“ DaemonSet”不匹配

时间:2019-10-05 20:51:09

标签: kubernetes filebeat daemonset

我正在尝试在此文档中使用k8s 1.16在minikube上运行FileBeat https://www.elastic.co/guide/en/beats/filebeat/7.4/running-on-kubernetes.html

我已按照指示下载清单文件

new someClass()

以下yaml文件的内容

someFunc

当我尝试部署步骤时,

const someFunc = () => new someClass().getOrSetWhatever()

我得到输出+错误:

configmap / filebeat-config已创建 已创建clusterrolebinding.rbac.authorization.k8s.io/filebeat 创建了clusterrole.rbac.authorization.k8s.io/filebeat 已创建serviceaccount / filebeat 错误:无法识别“ filebeat-kubernetes.yaml”:版本“ extensions / v1beta1”中与“ DaemonSet”类型不匹配

1 个答案:

答案 0 :(得分:3)

我们可以看到there

  默认情况下,在v1.16中,扩展,v1beta1,apps / v1beta1或apps / v1beta2将不再提供

DaemonSet ,Deployment,StatefulSet和ReplicaSet资源。迁移到apps / v1 API

您需要更改apiVersion

apiVersion: extensions/v1beta1 -> apiVersion: apps/v1

然后还有另一个错误

missing required field "selector" in io.k8s.api.apps.v1.DaemonSetSpec;

所以我们必须添加选择器字段

spec:
  selector:
    matchLabels:
      k8s-app: filebeat

编辑的DaemonSet yaml:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: filebeat
  namespace: kube-system
  labels:
    k8s-app: filebeat
spec:
  selector:
    matchLabels:
      k8s-app: filebeat
  template:
    metadata:
      labels:
        k8s-app: filebeat
    spec:
      serviceAccountName: filebeat
      terminationGracePeriodSeconds: 30
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
      - name: filebeat
        image: docker.elastic.co/beats/filebeat:7.4.0
        args: [
          "-c", "/etc/filebeat.yml",
          "-e",
        ]
        env:
        - name: ELASTICSEARCH_HOST
          value: elasticsearch
        - name: ELASTICSEARCH_PORT
          value: "9200"
        - name: ELASTICSEARCH_USERNAME
          value: elastic
        - name: ELASTICSEARCH_PASSWORD
          value: changeme
        - name: ELASTIC_CLOUD_ID
          value:
        - name: ELASTIC_CLOUD_AUTH
          value:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        securityContext:
          runAsUser: 0
          # If using Red Hat OpenShift uncomment this:
          #privileged: true
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - name: config
          mountPath: /etc/filebeat.yml
          readOnly: true
          subPath: filebeat.yml
        - name: data
          mountPath: /usr/share/filebeat/data
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
        - name: varlog
          mountPath: /var/log
          readOnly: true
      volumes:
      - name: config
        configMap:
          defaultMode: 0600
          name: filebeat-config
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers
      - name: varlog
        hostPath:
          path: /var/log
      # data folder stores a registry of read status for all files, so we don't send everything again on a Filebeat pod restart
      - name: data
        hostPath:
          path: /var/lib/filebeat-data
          type: DirectoryOrCreate

让我知道这是否对您有帮助。