const podElection = pods => { // Because all the pods are going to be running this code independently, we need a way to consistently find the same // node to kick things off, the easiest way to do that is convert their ips into longs and find the highest pods.sort((a, b) => { const aIpVal = ip.toLong(a.status.podIP); const bIpVal = ip.toLong(b.status.podIP); if (aIpVal < bIpVal) return -1; if (aIpVal > bIpVal) return 1; return 0; // Shouldn't get here... all pods should have different ips }); // Are we the lucky one? return pods[0].status.podIP === hostIp; }