<p>Using Kubernetes -- Gogle Container Enginer setup , Within the Same google cloud Cluster, I am having the Front end Service -> nginx + Angular JS and REST API service --> NodeJS API. I don't want to expose NodeJS API KubeCTL Service public domain. So, 'ServiceType' is set to only 'ClusterIP' . How do we infer this NODE_API_SERIVCE_HOST , NODE_API_SERIVCE_PORT --  {SVCNAME}_SERVICE_HOST and {SVCNAME}_SERVICE_PORT -- inside AngularJS program. </p>

<pre><code> (function() {
'use strict';

angular
    .module('mymodule', [])
    .config(["RestangularProvider", function(RestangularProvider) {
      var apiDomainHost = process.env.NODE_API_SERVICE_HOST;
      var apiDomainPort = process.env.NODE_API_SERVICE_PORT;
      RestangularProvider.setBaseUrl('https://'+apiDomainHost+':'+apiDomainPort+'/node/api/v1');        }]);
 })();
</code></pre>

<p>Then this will not work ( ReferenceError: process is not defined ) , as these angularjs code is executed at the client side. </p>

<p>My docker file is simple to inherit the nginx stop / start controls.</p>

<pre><code>FROM nginx
COPY public/angular-folder /usr/share/nginx/html/projectSubDomainName
</code></pre>

<p>Page 43 of 62 in <a href="http://www.slideshare.net/carlossg/scaling-docker-with-kubernetes" rel="nofollow">http://www.slideshare.net/carlossg/scaling-docker-with-kubernetes</a>, explains that can we invoke the Command sh </p>

<pre><code> "containers": {
     {
      "name":"container-name",
      "command": {
        "sh" , "sudo nginx Command-line parameters
    'https://$NODE_API_SERVICE_HOST:$NODE_API_SERVICE_PORT/node/api/v1'"
 }
 }
 }
</code></pre>

<p>Is this sustainable for the PODs restart? IF so, how do I get this variable in AngularJS?</p>

<blockquote>
  <p>Then this will not work ( ReferenceError: process is not defined ) , as these angularjs code is executed at the client side.</p>
</blockquote>

<p>If the client is outside the cluster, the only way it will be able to access the NodeJS API is if you expose it to the client's network, which is probably the public internet. If you're concerned about the security implications of that, there are a number of different ways to authenticate the service, such as using <a href="http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html" rel="nofollow">nginx auth_basic</a>.</p>

<blockquote>
<pre><code>"containers": {
   {
    "name":"container-name",
    "command": {
      "sh" , "sudo nginx Command-line parameters
   'https://$NODE_API_SERVICE_HOST:$NODE_API_SERVICE_PORT/node/api/v1'"
 }
 }
 }
</code></pre>
  
  <p>Is this sustainable for the PODs restart? IF so, how do I get this variable in AngularJS?</p>
</blockquote>

<p>Yes, service IP &amp; port is stable, even across pod restarts. As for how to communicate the NODE_API_SERVICE_{HOST,PORT} variables to the client, you will need to inject them from a process running server side (within your cluster) into the response (e.g. directly into the JS code, or as a JSON response).</p>
