<p>If I have to deploy a workload on Kubernetes and also have to expose it as a service, I have to create a Deployment/Pod and a Service. If the Kubernetes offering is from Cloud and we are creating a LoadBalancer service, it makes sense to create the the service first before the workload as the url creation for the service takes time. But in case the Kubernetes deployed on non-cloud platform there is no point in creating the Service before the workload.
So why I have to create a service first then the workload?</p>

Aditya Bhuyan
<p>There is no requirement to create a service before a deployment or vice versa. You can create the deployment before the service or the service before the deployment.</p>
<p>If you create the deployment before the service, then the application packaged in the deployment will not be accessible externally until you create the LoadBalancer.</p>
<p>Conversely, if you create the LoadBalancer first, the traffic for the application will not be routed to the application as it hasn't been created yet, giving 503s to the caller.</p>
<p>You are declaring to Kubernetes how you want the state of the infrastructure to be. e.g. &quot;I want a deployment and a service&quot;. Kubernetes will go off and create those, but they may not necessarily end up being creating in a predictable order. For example, LoadBalancers take a while to assign IPs from your Cloud provider, so even though the resource is created in the cluster, it's not actually getting any traffic.</p>
