carlosedp / cluster-monitoring

Cluster monitoring stack for clusters based on Prometheus Operator
MIT License
740 stars 200 forks source link

Issue #39: Add affinity for arm/arm64 support for arm-exporter. #42

Closed geerlingguy closed 4 years ago

geerlingguy commented 4 years ago

Closes #39.

Note that this currently results in the following error when running make:

+ xargs '-I{}' sh -c 'cat {} | $(go env GOPATH)/bin/gojsontoyaml > {}.yaml; rm -f {}' -- '{}'
RUNTIME ERROR: Field does not exist: withAffinity
    arm_exporter.jsonnet:75:7-54    object <anonymous>
    main.jsonnet:36:47-68   object <anonymous>
    During manifestation

I am not an expert at jsonnet, but I'm guessing there needs to be a new util added to utils.libsonnet?

Ultimately, it needs to add the following spec.affinity in armexporter-daemonset.yaml:

    spec:                                                                                 
      affinity:                                                                           
        nodeAffinity:                                                  
          requiredDuringSchedulingIgnoredDuringExecution:              
            nodeSelectorTerms:                                         
            - matchExpressions:                                        
              - key: kubernetes.io/arch                                
                operator: In                                           
                values:                                                
                - arm                                                  
                - arm64 
geerlingguy commented 4 years ago

Here's an anti affinity config from the kube-prometheus project: https://github.com/coreos/kube-prometheus/blob/master/jsonnet/kube-prometheus/kube-prometheus-anti-affinity.libsonnet

carlosedp commented 4 years ago

The withAffinity function doesn't exist for the DaemonSet object in the API. I've built the jsonnet docs on https://ksonnetlib-docs-1-15.netlify.app/apps/v1/daemonset/. It's a little confusing and you need to get hang of it to understand.

Other than that, I'v pushed a commit to this PR with the alleged "correct" config. Can you test this out (I don't have a RPI cluster right now)?

Can you check if you gave permission to maintainer to add commits to this PR?

geerlingguy commented 4 years ago

This works perfectly!

Ended up with the configuration block:

      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/arch
                operator: In
                values:
                - arm
                - arm64

Which works correctly.

geerlingguy commented 4 years ago

@carlosedp - I've updated the branch, rebased on master. This is good to go!

carlosedp commented 4 years ago

Thanks!