I am running a kubernetes cluster on AWS-ec2 and I would like to have the pod (container) know during runtime which region it's running on, how can this be done?
Take a look at AWS Instance Metadata:
[...] instance metadata is available from your running instance, you do not need to use the Amazon EC2 console or the AWS CLI. This can be helpful when you're writing scripts to run from your instance
You can query the region of a given container querying the metadata from inside during runtime. Like this:
curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone
placement/availability-zone: The Availability Zone in which the instance launched.
There are a few suggestions in this similar question: Inject node labels into Kubernetes pod
Options:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With