This directory contains a Kubernetes chart to deploy a GCP Night King service. The Night King service is a service that restarts preempted GCE instances.

It uses Google Cloud Pub/Sub for reporting instance preemption.

When a machine is about to be preempted, if it should be restarted, it should publish a Pub/Sub message to a known topic. The Night King service subscribes to the Pub/Subtopic and tries to restart instances accordingly, once they are terminated.

Chart Details

This chart will do the following:

  • Install a service (K8s Deployment) that listens on a Pub/Sub subscription for instance preemption messages and resurrects preempted instances once they are terminated.

Running The Night King service

The service is implemented in Go, and prebuilt Docker images are provided. In either case, you’ll need to have Google Cloud SDK authorization set up for the service to be able to receive messages from Google Pub/Sub and use the GCE Compute API.

The Docker bind-mount is useful to share your host Google Cloud credentials – feel free to use other methods to obtain appropriate Google Cloud credentials inside Docker.

There are multiple ways to have the service running “in production” (e.g., not in the foreground of your dev-machine terminal).

You can use whatever method fits your environment (deployment-setup contributions are welcome). See below details for already-supprted methods.

Tell us about a new Kubernetes application


Never miss a thing! Sign up for our newsletter to stay updated.


Discover and learn about everything Kubernetes