Before you install vRealize Operations Management Pack for Kubernetes, you must deploy the cAdvisor DaemonSet on the cluster. Based on the Kubernetes settings, you must create a cAdvisor YAML definition.

Here are a few points to consider when you create a cAdvisor YAML definition:

  • Containers running on hostPort must be accessible on your cluster. For example, the sample YAML definition on hostPort given below has port 31194 as the hostPort. So, the cluster must allow a connection on port 31194.

    If the containers running on hostPort are not accessible, verify with hostNetwork. A sample YAML definition on hostNetwork specific to Tanzu Kubernetes Grid Integrated (TKGI) is provided in Sample cAdvisor YAML Definition on HostPort.

  • The docker path configured in the volume must be correct.
    Note: The docker path can be different based on your settings.
  • All the nodes must have sufficient CPU and memory to run DaemonSets.
  • You must use the hostPort defined in the YAML definition as the cAdvisor port when you create an adapter instance.

  • Verify that the Kubernetes Clusters available in the TKGI Environment have the cAdvisor DaemonSet configured on port 31194.

Sample cAdvisor YAML Definition on HostPort

apiVersion: apps/v1 # apps/v1beta2 in Kube 1.8, extensions/v1beta1 in Kube < 1.8
kind: DaemonSet
metadata:
  name: cadvisor
  namespace: kube-system 
  labels:
    app: cadvisor
  annotations:
      seccomp.security.alpha.kubernetes.io/pod: 'docker/default'
spec:
  selector:
    matchLabels:
      app: cadvisor
  template:
    metadata:
      labels:
        app: cadvisor
        version: v0.31.0
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: cadvisor
        image: google/cadvisor:v0.31.0
        resources:
          requests:
            memory: 250Mi
            cpu: 250m
          limits:
            cpu: 400m
        volumeMounts:
        - name: rootfs
          mountPath: /rootfs
          readOnly: true
        - name: var-run
          mountPath: /var/run
          readOnly: true
        - name: sys
          mountPath: /sys
          readOnly: true
        - name: docker
          mountPath: /var/lib/docker  #Mouting Docker volume  
          readOnly: true
        - name: disk
          mountPath: /dev/disk
          readOnly: true
        ports:
          - name: http
            containerPort: 8080 #Port exposed 
            hostPort : 31194 #Host's port - Port to expose your cAdvisor DaemonSet on each node
            protocol: TCP
      automountServiceAccountToken: false
      terminationGracePeriodSeconds: 30
      volumes:
      - name: rootfs
        hostPath:
          path: /
      - name: var-run
        hostPath:
          path: /var/run
      - name: sys
        hostPath:
          path: /sys
      - name: docker
        hostPath:
          path: /var/lib/docker #Docker path in Host System
      - name: disk
        hostPath:
          path: /dev/disk

Sample cAdvisor YAML Definition on HostNetwork

apiVersion: apps/v1beta2 # apps/v1beta2 in Kube 1.8, extensions/v1beta1 in Kube < 1.8
kind: DaemonSet
metadata:
  name: vrops-cadvisor
  namespace: kube-system
  labels:
    app: vrops-cadvisor
spec:
  selector:
    matchLabels:
      name: vrops-cadvisor
  template:
    metadata:
      labels:
        name: vrops-cadvisor
        version: v0.31.0
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      hostNetwork: true
      containers:
      - name: vrops-cadvisor
        image: google/cadvisor:v0.31.0
        imagePullPolicy: Always
        volumeMounts:
        - name: rootfs
          mountPath: /rootfs
          readOnly: true
        - name: var-run
          mountPath: /var/run
          readOnly: false
        - name: sys
          mountPath: /sys
          readOnly: true
        - name: docker
          mountPath: /var/lib/docker #Mouting Docker volume
          readOnly: true
        - name: docker-sock
          mountPath: /var/run/docker.sock
          readOnly: true
        - name: containerd-sock
          mountPath: /var/run/containerd.sock
          readOnly: true
        - name: disk
          mountPath: /dev/disk
          readOnly: true
        ports:
        - name: http
          containerPort: 31194 #Port exposed
          hostPort: 31194  #Host's port - Port to expose your cAdvisor DaemonSet on each node
          protocol: TCP
        securityContext:
          capabilities:
            drop:
            - ALL
            add:
            - NET_BIND_SERVICE
        args:
          - --port=31194
          - --profiling
          - --housekeeping_interval=1s
      terminationGracePeriodSeconds: 30
      volumes:
      - name: rootfs
        hostPath:
          path: /
      - name: var-run
        hostPath:
          path: /var/run
      - name: sys
        hostPath:
          path: /sys
      - name: docker
        hostPath:
          path: /var/vcap/store/docker/docker #Docker path in Host System
      - name: docker-sock  
        hostPath:
          path: /var/vcap/sys/run/docker/docker.sock
      - name: containerd-sock
        hostPath:
          path: /var/run/docker/containerd/docker-containerd.sock
      - name: disk
        hostPath:
          path: /dev/disk