Skip to content

Latest commit

 

History

History
55 lines (35 loc) · 2.13 KB

README.md

File metadata and controls

55 lines (35 loc) · 2.13 KB

Pod Watcher

A controller based on the Kubernetes sample controller that watches for pods being scheduled (i.e. the PodScheduled condition type).

If the pod contains a certain annotation, the controller will

  • Lookup the node that the pod is scheduled on (.spec.nodeName)
  • Lookup the node's information (hostname, provider ID, cloud provider name, availability zone)
  • Annotate the pod with the node's information

The pod can utilize this information by mounting the annotation as a volume using the downward API. Refer to demo.yaml for more info on how this is done.

Sample providerID:

aws:///ap-southeast-1a/i-06fbbd699deb4abcd

The container image for the pod-watcher is available at ghcr.io/kwkoo/pod-watcher:0.1.

Note: The node information is cached when the controller starts up. If nodes are added after the controller has started, the controller will not know about those nodes.

Installation

  1. Login to OpenShift using oc login

  2. Build and install the pod-watcher:

    make deploy
    
  3. Deploy the demo app:

    make deploydemo
    
  4. After the demo has been deployed, access the demo app with:

    curl http://$(oc get -n demo route/demo -o jsonpath='{.spec.host}')
    

The demo app should print out information about the node that the pod is deployed on.

Resources