<p>I am trying to deploy an application to Google Cloud Platform.
I have my back-end and my front-end running in separate docker containers, each project have his own Docker-Compose and Dockerfile , I am using a container for my Postgres database. I deployed my containers to Dockerhub, and I created Kubernetes services and deployments. (using Kubernetes Kompose: so I converted my docker-compose to deployments.yaml files first) </p>

<p>Now I want to deploy my application to Google Cloud Platform </p>

<ul>
<li><p>I created a cluster </p></li>
<li><p>I created two separate deployments for my front-end and my back-end</p>

<pre><code>kubectl run backendapp --image=docker.io/[dockerhub username]/backendapp --port=9000
kubectl run frontendapp --image=docker.io/[dockerhub username]/frontendapp --port=3000
</code></pre></li>
</ul>

<p>When I access through the external IP address to my front-end, it seems working (there are an interface) and it is impossible to get to my back-end through the external IP.</p>

<p>So my questions are:</p>

<ul>
<li>what are the correct steps to follow after running my Kubernetes services and 
dockerizing my application in order to deploy it on Google Cloud Platform?</li>
<li>how to link my front-end and my back-end services once deployed?</li>
<li>should I create a deployment for my database also in Google Cloud Platform?</li>
</ul>

<p>This is  the description of my backend service </p>

<pre><code>&gt; Name:                     backendapp Namespace:                default
&gt; Labels:                   run=backendapp Annotations:             
&gt; &lt;none&gt; Selector:                 run=backendapp Type:                 
&gt; LoadBalancer IP:                       10.111.73.214 Port:            
&gt; &lt;unset&gt;  9000/TCP TargetPort:               9000/TCP NodePort:        
&gt; &lt;unset&gt;  32449/TCP Endpoints:                 Session Affinity:       
&gt; None External Traffic Policy:  Cluster Events:                  
&gt; &lt;none&gt;
</code></pre>

<p>and this is the description for my frontend service</p>

<pre><code>Name:                     frontendapp
Namespace:                default
Labels:                   run=frontendapp
Annotations:              &lt;none&gt;
Selector:                 run=frontendapp
Type:                     LoadBalancer
IP:                       10.110.133.172
Port:                     &lt;unset&gt;  3000/TCP
TargetPort:               3000/TCP
NodePort:                 &lt;unset&gt;  30016/TCP
Endpoints:                
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   &lt;none&gt;
</code></pre>

<p>I am able to acces my frontend service via</p>

<blockquote>
  <p>clusterIp:Nodeport
  But I am unable to do so with the backend </p>
</blockquote>

Ennar.ch
<blockquote>
  <p>what are the correct steps to follow after running my Kubernetes
  services and dockerizing my application in order to deploy it on
  Google Cloud Platform?</p>
</blockquote>

<p>After you created a cluster in GCP, you need to create deployments and services for your front-end and back-end applications. You can read GKE documentation to understand how to create <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app" rel="nofollow noreferrer">Deployment</a> and <a href="https://cloud.google.com/kubernetes-engine/docs/quickstart" rel="nofollow noreferrer">Services</a> </p>

<blockquote>
  <p>how to link my front-end and my back-end services once deployed?</p>
</blockquote>

<p>PODs in Kubernetes communicate using Services, they also use Services for exposing themselves to the outer world. In GCP, you can use LoadBalancer for sharing HTTP/HTTPS traffic and TCP traffic. For more information about it, you can look through Codelab <a href="https://codelabs.developers.google.com/codelabs/gcp-infra-gke/index.html?index=..%2F..%2Fcloud#0" rel="nofollow noreferrer">Kubernetes, GKE, and Load Balancing</a> example.</p>

<blockquote>
  <p>should I create a deployment for my database also in Google Cloud
  Platform?</p>
</blockquote>

<p>If you want to locate database in Kubernetes, you need to add deployment and service for it. If you don't, you need to configure the access from your applications to the database outside Kubernetes.</p>
