I have a set of http server instances. We can assume a simple apache or nginx instances. However, the set of instances comprises of two sub-sets, (1) instances that runs in an infrastructure that fed by green energy (2) infra. that runs on regular grid energy. The two runs the SAME software stack, say kubernetes. Also, it can run in the same WAN if not LAN, i.e., same datacenter.
I want to load-balance traffic to the first resource set, the green set, when I have green energy available. Lets assume I have an optimized mechanism that knows when I have enough green-energy to run a workload. How can I use clusterDNS to allow traffic to the set of pods that are fed by green-energy. In other words I want to have the clusterDNS to biased toward a specific resource set. Also, I want to know how can populate instances (and exclude) dynamically to the green-energy pods sets?
I tired to look at https://github.com/kubernetes/kubernetes/tree/release-1.2/examples/cluster-dns/README.html but it is not available and I wonder if you can share some ideas on how to tackle this using kubernetes.
You need a rediness probe on your Green pods. Cluster DNS will only work within a single cluster, so you will have to put both your nginx pods (green and grid) behind a single service, and use the DNS name of that service to talk to it. Then if one of the pods fails a readiness probe, all traffic directed to the cluster DNS name will get sent to the others.
Example nginx pod with readiness probe: https://github.com/kubernetes/kubernetes/blob/master/test/e2e/testing-manifests/kubectl/pod-with-readiness-probe.yaml