content_image/814093.jpg content_image/814096.jpg
Now that we have the images for our Pod, the final step is to deploy the controller by using a Deployment. We can see the main parts of the Deployment in Example 22-5 (the full version can be found in our example repository). 

apiVersion : apps/v1 kind : Deployment # .... spec : template : # ... spec : serviceAccountName : config-watcher-controller containers : - name : kubeapi-proxy image : k8spatterns/kubeapi-proxy - name : config-watcher image : k8spatterns/curl-jq # ... command : - "sh" - "/watcher/config-watcher-controller.sh" volumeMounts : - mountPath : "/watcher" name : config-watcher-controller volumes : - name : config-watcher-controller configMap : name : config-watcher-controller 

ServiceAccount with proper permissions for watching events and restarting Pods 

<img src='content_image/814093.jpg'>

Ambassador  container for proxying localhost to the Kubeserver API 

Main container holding all tools and mounting the controller script 

Startup command calling the controller script 

Volume mapped to the ConfigMap holding our script 

Mount of the ConfigMap-backed volume into the main Pod 

<img src='content_image/814096.jpg'>

As you can see, we mount the config-watcher-controller-script  from the Con‐ figMap we have created previously and directly use it as the startup command for the primary container. For simplicity reasons, we omitted any liveness and readiness checks as well as resource limit declarations. Also, we need a ServiceAccount config- 

