I'm trying to create a deployment along with a service and then access the service immediately as soon as the rollout is complete:
> kubectl create -f my-deployment.yaml
> kubectl create -f my-service.yaml
> kubectl rollout status deployment/my-deployment --watch --timeout 10m # This usually takes ~30 seconds
deployment "my-deployment" successfully rolled out
> curl "my-service" # This happens inside a pod, so the service DNS name should be available
Sometimes this works, but there seems to be a race condition -- if the curl command happens too quickly, it seems the socket fails to connect and I get a connection timeout.
This seems like the behavior I would get if there were no ready pods, as per this question: What happens when a service receives a request but has no ready pods?
I expected that the completion of the rollout meant that the service was guaranteed to be ready to go. Is this not the case? Is there some Kubernetes command to "wait" for the service to be available? (I notice that services don't have conditions, so you can't do kubectl wait...)
所有评论(0)