Activation (wake up)
When a Knative Service is scaled to zero, it has no Pods running to receive traffic, so it's sleeping. 😴 How do we wake up the Serviceby scaling it up to handle traffic?
This is done by activator component. How does it do that:
- When a KService is scaled to zero, its Kubernetes Service is pointed to the IP
- After receiving request,
activatorwill buffer (hold onto) the request
- Then, it will look at request’s hostname to find which KService it is for.
- Then, it will scale up the Kubernetes Deployment and wait for a Pod to become ready.
- In the meanwhile, it updates Kubernetes Service to point to Pod IP addresses (so that activator gets out of the network path if the KService is awake).
- Finally, activator proxies the request to the started podP
Activation in action
Deploy an app, wait for it to scale to 0 Pods.
Look at Endpoints objects of the deployed Revision, it is pointing to the IP address of the activator Pod:
$ kubectl get endpoints NAME ENDPOINTS AGE hello-tcz5c 10.0.2.11:8012 2m23s
$ kubectl get pods -n knative-serving -o=wide NAME STATUS IP AGE activator-7688586ccb-gl9qx Running 10.0.2.11 58s
Now wake up 🌞 the Service, by making a request.
You'll see that Endpoints of the revision is now updated with the pod IPs:
$ kubectl get endpoints NAME ENDPOINTS AGE hello-tcz5c 10.0.3.12:8012 7s
$ kubectl get pods -o=wide NAME STATUS IP AGE hello-tcz5c-deployment-689d8 Running 10.0.3.12 58s