Heartbeat error "error when creating "heartbeat-kubernetes.yaml": Deployment in version "v1" cannot be handled as a Deployment: unable to parse quantity's suffix" when deploying on kubernetes

Hello everyone, i'm trying to deploy heartbeat on kubernetes to monitor kubernetes pods and services. i used the elastic official documentation yaml file.

this is the full configuration file

apiVersion: v1
kind: ConfigMap
metadata:
  name: heartbeat-deployment-config
  namespace: kube-system
  labels:
    k8s-app: heartbeat
data:
  heartbeat.yml: |-
    heartbeat.autodiscover:
    #  # Autodiscover pods
      providers:
        - type: kubernetes
          resource: pod
          scope: cluster
          node: ${NODE_NAME}
          hints.enabled: true
    #
    #  # Autodiscover services
      providers:
        - type: kubernetes
          resource: service
          scope: cluster
          node: ${NODE_NAME}
          hints.enabled: true
    
      # Autodiscover nodes
      providers:
        - type: kubernetes
          resource: node
          node: ${NODE_NAME}
          scope: cluster
          templates:
            # Example, check SSH port of all cluster nodes:
            - condition: ~
              config:
                - hosts:
                    - ${data.host}:22
                  name: ${data.kubernetes.node.name}
                  schedule: '@every 10s'
                  timeout: 5s
                  type: tcp

    processors:
      - add_cloud_metadata:

    cloud.id: ${ELASTIC_CLOUD_ID}
    cloud.auth: ${ELASTIC_CLOUD_AUTH}

    output.elasticsearch:
      hosts: ['https://10.112.100.121:30883']
      username: "elastic"
      password: "*********"
      ssl.verification_mode: none
---
# Deploy singleton instance in the whole cluster for some unique data sources, like kube-state-metrics
apiVersion: apps/v1
kind: Deployment
metadata:
  name: heartbeat
  namespace: kube-system
  labels:
    k8s-app: heartbeat
spec:
  selector:
    matchLabels:
      k8s-app: heartbeat
  template:
    metadata:
      labels:
        k8s-app: heartbeat
    spec:
      serviceAccountName: heartbeat
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
      - name: heartbeat
        image: docker.elastic.co/beats/heartbeat:7.17.6
        args: [
          "-c", "/etc/heartbeat.yml",
          "-e",
        ]
        env:
       
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        securityContext:
          runAsUser: 0
        resources:
          limits:
            memory: 1536mi
          requests:
            # for synthetics, 2 full cores is a good starting point for relatively consistent perform of a single concurrent check
            # For lightweight checks as low as 100m is fine
            cpu: 2000m 
            # A high value like this is encouraged for browser based monitors. 
            # Lightweight checks use substantially less, even 128Mi is fine for those.
            memory: 1536Mi 
        volumeMounts:
        - name: config
          mountPath: /etc/heartbeat.yml
          readOnly: true
          subPath: heartbeat.yml
        - name: data
          mountPath: /usr/share/heartbeat/data
      volumes:
      - name: config
        configMap:
          defaultMode: 0600
          name: heartbeat-deployment-config
      - name: data
        hostPath:
          path: /var/lib/heartbeat-data
          type: DirectoryOrCreate

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: heartbeat
subjects:
- kind: ServiceAccount
  name: heartbeat
  namespace: kube-system
roleRef:
  kind: ClusterRole
  name: heartbeat
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: heartbeat
  namespace: kube-system
subjects:
  - kind: ServiceAccount
    name: heartbeat
    namespace: kube-system
roleRef:
  kind: Role
  name: heartbeat
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: heartbeat-kubeadm-config
  namespace: kube-system
subjects:
  - kind: ServiceAccount
    name: heartbeat
    namespace: kube-system
roleRef:
  kind: Role
  name: heartbeat-kubeadm-config
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: heartbeat
  labels:
    k8s-app: heartbeat
rules:
- apiGroups: [""]
  resources:
  - nodes
  - namespaces
  - pods
  - services
  verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
  resources:
    - replicasets
  verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: heartbeat
  # should be the namespace where heartbeat is running
  namespace: kube-system
  labels:
    k8s-app: heartbeat
rules:
  - apiGroups:
      - coordination.k8s.io
    resources:
      - leases
    verbs: ["get", "create", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: heartbeat-kubeadm-config
  namespace: kube-system
  labels:
    k8s-app: heartbeat
rules:
  - apiGroups: [""]
    resources:
      - configmaps
    resourceNames:
      - kubeadm-config
    verbs: ["get"]
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: heartbeat
  namespace: kube-system
  labels:
    k8s-app: heartbeat
---



and it gives this error error when creating "heartbeat-kubernetes.yaml": Deployment in version "v1" cannot be handled as a Deployment: unable to parse quantity's suffix

and everything else is deployed:

configmap/heartbeat-deployment-config configured
clusterrolebinding.rbac.authorization.k8s.io/heartbeat unchanged
rolebinding.rbac.authorization.k8s.io/heartbeat unchanged
rolebinding.rbac.authorization.k8s.io/heartbeat-kubeadm-config unchanged
clusterrole.rbac.authorization.k8s.io/heartbeat unchanged
role.rbac.authorization.k8s.io/heartbeat unchanged
role.rbac.authorization.k8s.io/heartbeat-kubeadm-config unchanged
serviceaccount/heartbeat unchanged

i think there's a problem in the deployment .

thank you for taking the time to read :smiley:

Hi @alexander2,

Thanks for reporting the issue to us! I'm really sorry for the inconvenience.

You're right, there was a syntax error in our docs template and, while we fixed it for 8.4, we didn't include the fix for 7.17 docs.

I've created this PR to include in 7.17: [7.17](backport #32801) Update HB k8s template to use <Mi> metric by mergify[bot] · Pull Request #33121 · elastic/beats · GitHub, so template will be fixed for the next release. If you'd like to be able to use it now, you'll need to change metric value:

limits:
            memory: 1536mi

To:

limits:
            memory: 1536Mi

Hope that helps.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.