To deploy cAdvisor for monitoring Linux containers using the YAML file, you have to perform the following actions.
Procedure
- Create cAdvisor.yaml (Daemaonset yaml).
apiVersion: apps/v1 # 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 annotations: seccomp.security.alpha.kubernetes.io/pod: 'docker/default' spec: selector: matchLabels: app: vrops-cadvisor template: metadata: labels: app: vrops-cadvisor version: v0.33.0 spec: tolerations: - key: node-role.kubernetes.io/master effect: NoSchedule containers: - name: vrops-cadvisor image: google/cadvisor:v0.33.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
- Run
kubectl apply -f cadvisor.yaml
.Daemonset and service on your Kubernetes cluster is created.
- Run
kubectl get all -o wide
.Helps you see where the cadvisor containter is created.
- Copy the IP address of the node and the port which the cadvisor service has exposed.
- Add this as a job in prometheus.yml file in the Prometheus server.