Steps to deploy an application passing by docker, kubernetes and google cloud platform

6/13/2018

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)

Now I want to deploy my application to Google Cloud Platform

  • I created a cluster

  • I created two separate deployments for my front-end and my back-end

    kubectl run backendapp --image=docker.io/[dockerhub username]/backendapp --port=9000
    kubectl run frontendapp --image=docker.io/[dockerhub username]/frontendapp --port=3000

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.

So my questions are:

  • 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?
  • how to link my front-end and my back-end services once deployed?
  • should I create a deployment for my database also in Google Cloud Platform?

This is the description of my backend service

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

and this is the description for my frontend service

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

I am able to acces my frontend service via

clusterIp:Nodeport But I am unable to do so with the backend

-- Ennar.ch
docker
docker-compose
google-cloud-platform
kubernetes

1 Answer

6/14/2018

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?

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 Deployment and Services

how to link my front-end and my back-end services once deployed?

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 Kubernetes, GKE, and Load Balancing example.

should I create a deployment for my database also in Google Cloud Platform?

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.

-- Artem Golenyaev
Source: StackOverflow