What is “Reflection”?
Reflection is a concept that is available in most (if not all) programming languages. It simply refers to the ability of an object of some type to reveal important information about itself. For example, its name, its parent class, and any metadata that it happens to contain. In Cloud and DevOps arenas, the same concept holds. For example, if you are logged into an AWS EC2 instance, you can easily get a wealth of information about that particular instance (its reflection) by issuing a GET request to http://169.254.169.254/latest/meta-data/ from within the instance itself.
Why Do We Need an Object’s Reflection?
An object here is used as a generic term to refer to the unit of work. So, in a programming language, an object is an instance of a class, in your on-prem infrastructure, the object may be a physical or virtual host, in a cloud environment, it is the instance, and in Kubernetes, it’s the Pod.
In this article, we are interested in Kubernetes, so Pod and object may be used interchangeably.
There are many use cases where you need the metadata of a Pod, especially if that Pod is part of a stateless application where Pods are dynamic by nature. Let’s see some possible scenarios:
You need the IP address of the Pod to identify whether or not it was the source of suspicious traffic that was detected on your network.
The application running inside the container needs to know the namespace in which the Pod is running, perhaps because it is programmed to behave differently depending on the environment where it is running, conveyed by the namespace.
You need to know the current resource limit (CPU and memory) imposed on the container. You can further use this data to automatically adjust the heap size of a Java application when it starts, for example.
For More information visit: https://www.magalix.com/blog/kubernetes-patterns-the-reflection-pattern
Top comments (0)