For self-healing I want to be able to call a function on a specific pod instance from outside the kube cluster.
So... I have 2 networks, non-kube, and my kube-cluster. My kube-cluster contains one service, myapp and has 8 replicas spread across 4 nodes. If each of these pods was given a VIP 10.1.1.x where x is from 1 to 8, I want to be able to from any app running in non-kube, be able to call any of the API methods exposed in myapp, but forcing a particular replica.
E.g. myapp has one REST GET method,
whatismyvip()
And from a console app running in non-kube I want to be able to ensure I get the following output, by calling the above method on the right pod.
10.1.1.4
10.1.1.6
10.1.1.8
10.1.1.2
10.1.1.5
Why would I want to do something like this? Well, generally the errors that are generated in the kube-cluster service are server errors due to bad data / configuration, rather than the system "going down", i.e. 500 errors, and so I want the client to be smart enough to go
"ok, i got an error from 10.1.1.2, i will try 10.1.1.3"
I'd prefer to do this natively in kubernetes (even if it means custom IngressController) rather than sidecar service mesh, Envoys et al.
Create a loadbalanced service that fronts your replicaset of 8 pods. Define a liveness HTTP probe that pings the whatismyvip()
HTTP endpoint.
The host kubelet will restart the pod if you get any unexpected HTTP status codes.
define a liveness HTTP request
Otherwise if what you mean by forcing a particular replica is that you wish to direct your request into a specific pod from outside the cluster, then perhaps a custom solution might be better. Each see if 2 X pods on each node might have a clusterIP service fronting them. Then use a loadbalanced service fronting a custom app that proxies your request for a specific replica or set of pods based on your request.
E.g. a URL query string parameter that targets clusterIP service A, B, C, or D.
https://customrouterapp/whatismyvip?replicaset=B