简体   繁体   English

如何使用 Cloud Build 和 Skaffold 构建 kubernetes 集群并将其部署到 Google Cloud?

[英]How to build and deploy kubernetes cluster to Google Cloud using Cloud Build and Skaffold?

I am new to micro-services technologies and getting troubled with Google Cloud Build.我是微服务技术的新手,并且对 Google Cloud Build 感到困扰。 I am using Docker, Kubernetes, Ingres Nginx and skaffold and my deployment works fine in local machine.我正在使用 Docker、Kubernetes、Ingres Nginx 和 skaffold,我的部署在本地机器上运行良好。

Now I want to develop locally and build and run remotely using Cloud Platform so, here's what I have done:现在我想在本地开发并使用 Cloud Platform 远程构建和运行,所以,这是我所做的:

  • In Google Cloud, I have set up kubernetes cluster在谷歌云中,我已经设置了kubernetes 集群
  • Set local kubectl context to cloud cluster将本地 kubectl 上下文设置为云集群
  • Set up an Ingress Nginx load balancer设置Ingress Nginx负载均衡器
  • Enabled Cloud Build API (no trigger setup)启用 Cloud Build API(无触发器设置)

Here's my create deployment and skaffold yaml files look like:这是我创建的部署skaffold yaml 文件,如下所示: 在此处输入图片说明

When I run skaffold dev , it logs out: Some taggers failed.当我运行skaffold dev 时,它会注销:某些标记器失败。 Rerun with -vdebug for errors.使用 -vdebug 重新运行以查找错误。 , then it takes some time and my network bandwidth. ,然后需要一些时间和我的网络带宽。

The image does get pushed to Cloud Container Registry and I can access the app using load balancer's IP address but the Cloud Build History is still empty.该映像确实被推送到Cloud Container Registry ,我可以使用负载均衡器的 IP 地址访问该应用程序,但Cloud Build History仍然为空。 Where am I missing?我在哪里失踪?

Note: Right now I am not pushing my code to any online repository like github.注意:现在我没有将我的代码推送到任何在线存储库,如 github。

Sorry If the information I provide is insufficient, I am new to these technologies.抱歉,如果我提供的信息不够充分,我是这些技术的新手。

Cloud Build started working: Cloud Build 开始工作:

First, In Cloud Build settings, I enabled kubernetes Engine, Compute Engine and Service Accounts.首先,在 Cloud Build 设置中,我启用了 kubernetes Engine、Compute Engine 和 Service Accounts。

Then, I executed these 2 commands:然后,我执行了这两个命令:

  1. gcloud auth application-default login : As google describes it This will acquire new user credentials to use for Application Default Credentials gcloud auth application-default login :正如谷歌描述的那样这将获取新的用户凭据以用于应用程序默认凭据

  2. As mentioned in ingress nginx -> deploy -> GCE-GKE documentation, this will Initialize your user as a cluster-adminingress nginx -> deploy -> GCE-GKE文档中所述,这会将您的用户初始化为集群管理员

kubectl create clusterrolebinding cluster-admin-binding \
  --clusterrole cluster-admin \
  --user $(gcloud config get-value account)

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

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