pryorda / vmware_exporter

VMWare vCenter Exporter for Prometheus
BSD 3-Clause "New" or "Revised" License
513 stars 195 forks source link

Issues getting data from multiple vcenters #319

Open b-arik opened 2 years ago

b-arik commented 2 years ago

I've got vmware_exporter deployed in kubernetes. I'm able to get data from this vcenter when specifying the env variables inside configMap file as per below.

apiVersion: v1 
kind: ConfigMap
metadata:
  name: vmware-exporter
  namespace: vmware-exporter
data:
  VSPHERE_HOST: "vcenter_host"
  VSPHERE_USER: "vcenter_username"
  VSPHERE_IGNORE_SSL: "True"
  VSPHERE_COLLECT_HOSTS: "True"
  VSPHERE_COLLECT_DATASTORES: "True"
  VSPHERE_COLLECT_VMS: "True"

But having issues when using config.yml. I've got it configured as below in my deployment, mounting the config.yml file to /opt/vmware_exporter/config.yml and I can see this file when I ssh to my pod.

apiVersion: v1 
kind: ConfigMap
metadata:
  name: vmware-exporter
  namespace: vmware-exporter  
config.yml: |
    default:
      VSPHERE_HOST: "vcenter_host1"
      VSPHERE_USER: "vc-vmware-readonly"
      VSPHERE_IGNORE_SSL: "True"
      VSPHERE_COLLECT_HOSTS: "True"
      VSPHERE_COLLECT_DATASTORES: "True"
      VSPHERE_COLLECT_VMS: "True"

    vizvc1:
      VSPHERE_HOST: "vcenter_host2"
      VSPHERE_USER: "vcenter_username"
      VSPHERE_IGNORE_SSL: "True"
      VSPHERE_COLLECT_HOSTS: "True"
      VSPHERE_COLLECT_DATASTORES: "True"
      VSPHERE_COLLECT_VMS: "True"

Mounting the file from configMap to /opt/vmware_exporter/config.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: vmware-exporter
  namespace: vmware-exporter
spec:
  selector:
    matchLabels:
      app: vmware-exporter
  template:
    metadata:
      labels:
        app: vmware-exporter
        release: vmware-exporter
      annotations:
        prometheus.io/path: "/metrics"
        prometheus.io/port: "9272"
        prometheus.io/scrape: "true"
    spec:
      containers:
      - name: vmware-exporter
        image: "pryorda/vmware_exporter"
        imagePullPolicy: Always
        securityContext:
          runAsUser: 1000
        envFrom:
          - configMapRef:
              name: vmware-exporter
          - secretRef:
              name: vmware-exporter-password 
        ports:
        - containerPort: 9272
          name: http
        volumeMounts:
        - name: vcenter-config
          mountPath: /opt/vmware_exporter/config.yml
          subPath: config.yml
      volumes:
        - name: vcenter-config
          configMap:
            name: vmware-exporter
            items:
              - key: config.yml
                path: config.yml

How can I override the entrypoint using the file I mounted in the pod? Thanks

shqnayaz commented 1 year ago

Hi @b-arik , Have you fixed your trouble ? appreciate if you can share your working config file for fetching multiple vcenters I am in a same situation trying to add multiple vcenters to the vmware-exporter

Thanks,