简体   繁体   English

部署通过docker,kubernetes和Google Cloud Platform传递的应用程序的步骤

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

I am trying to deploy an application to Google Cloud Platform. 我正在尝试将应用程序部署到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. 我的后端和前端运行在单独的Docker容器中,每个项目都有自己的Docker-Compose和Dockerfile,我在Postgres数据库中使用了一个容器。 I deployed my containers to Dockerhub, and I created Kubernetes services and deployments. 我将容器部署到Dockerhub,并创建了Kubernetes服务和部署。 (using Kubernetes Kompose: so I converted my docker-compose to deployments.yaml files first) (使用Kubernetes Kompose:因此我首先将docker-compose转换为deployments.yaml文件)

Now I want to deploy my application to Google Cloud Platform 现在,我想将应用程序部署到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. 当我通过外部IP地址访问我的前端时,似乎可以正常工作(有一个接口),并且无法通过外部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? 在运行Kubernetes服务并对应用程序进行泊坞处理以将其部署到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? 是否也应该在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 clusterIp:Nodeport但后端无法执行此操作

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? 在运行Kubernetes服务并对应用程序进行泊坞处理以将其部署到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. 在GCP中创建集群后,您需要为前端和后端应用程序创建部署和服务。 You can read GKE documentation to understand how to create Deployment and Services 您可以阅读GKE文档以了解如何创建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. Kubernetes中的POD使用服务进行通信,它们还使用服务将自己暴露于外部世界。 In GCP, you can use LoadBalancer for sharing HTTP/HTTPS traffic and TCP traffic. 在GCP中,您可以使用LoadBalancer共享HTTP / HTTPS通信和TCP通信。 For more information about it, you can look through Codelab Kubernetes, GKE, and Load Balancing example. 有关它的更多信息,您可以浏览Codelab Kubernetes,GKE和负载平衡示例。

should I create a deployment for my database also in Google Cloud Platform? 是否也应该在Google Cloud Platform中为数据库创建部署?

If you want to locate database in Kubernetes, you need to add deployment and service for it. 如果要在Kubernetes中查找数据库,则需要为其添加部署和服务。 If you don't, you need to configure the access from your applications to the database outside Kubernetes. 如果不这样做,则需要配置从应用程序到Kubernetes外部数据库的访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM