How can I get the dynamic public endpoint of my application?

My application code needs to know the public URL where the application is exposed. This public endpoint depends on the okteto namespace where the application is deployed, and also the okteto cluster where the app is running.
How can I infer the public URL programmatically?

1 Like

Okteto automatically injects the environment variables OKTETO_NAMESPACE and OKTETO_DOMAIN on every pod. For example, when a pod is created in Okteto Cloud, in the cindy namespace, the following environment variables are automatically created:

  • OKTETO_NAMESPACE=cindy
  • OKTETO_DOMAIN=cloud.okteto.net

These environment variables make it possible to infer the public endpoint of your application. For example, if your service is called api, it will be exposed on:

https://+ api+ - + ${OKTETO_NAMESPACE} + . + ${OKTETO_DOMAIN}