Skip to content

A Kubernetes controller that annotates a pod with the information of the node it is scheduled on.

License

Notifications You must be signed in to change notification settings

kwkoo/pod-watcher-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:https:///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 https://$(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

About

A Kubernetes controller that annotates a pod with the information of the node it is scheduled on.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages