Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Custom Compute Class with nodeAffinity or podAntiAffinity

Hi friends,

I would like to know if there is already a possibility to use Custom Compute Class together with nodeAffinity, or if this feature is still limited to nodeSelector only. Currently, our infrastructure is largely based on nodeAffinity, so this functionality would be highly useful.

Best regards,
Leonardo Lima

0 2 291
2 REPLIES 2

You can use Custom Compute Class with either a nodeSelector or with nodeAffinity, but beware that you must you use requiredDuringScheduling... if you want to autoscale.  If you use preferredDuringScheduling..., then the workload will only be scheduled on a matching node if the node already exists.

In our scenario, we will use NodePools that will be created previously, each NodePool will have a NodeLabel called "class" (values like "general_computing" and "mem_optimized").

Today the biggest question is how GKE will behave, since in the Custom Compute Class documentation, there is nothing mentioning that it is possible to use these features (nodeAffinity)

 Here is an example of how we use this configuration in our Replicaset/Pod

 

  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
          - matchExpressions:
              - key: node.ourSystem.io/class
                operator: In
                values:
                  - general_computing
                  - mem_optimized
      preferredDuringSchedulingIgnoredDuringExecution:
        - weight: 100
          preference:
            matchExpressions:
              - key: node.ourSystem.io/capacity-type
                operator: In
                values:
                  - SPOT

 

What we would like is to continue using it this way, what would be the way to do that? Create a Custom Compute Class with the same name as the labels? Or add a matchExpressions to "cloud.google.com/compute-class" ? 

Thanks a lot!! 

Top Labels in this Space
Top Solution Authors