我为kubernetes和skaffold以及dockerfile开发了yaml文件。我的Skaffold部署在我的本地机器上工作得很好。
现在,我需要在我的Google Cloud项目中的k8s集群中实现相同的部署,由GitHub存储库中的新标记触发。我发现我必须使用Google Cloud Build,但我不知道如何从cloudbuild.yaml文件执行Skaffold。
发布于 2021-02-26 02:51:14
在https://github.com/GoogleCloudPlatform/cloud-builders-community中有一个skaffold图像
要使用它,请执行以下步骤:
git clone https://github.com/GoogleCloudPlatform/cloud-builders-community的skaffold目录
cd cloud-builders-community/skaffoldgcloud builds submit --config cloudbuild.yaml .然后,在您的cloudbuild.yaml中,可以基于以下步骤添加一个步骤:
- id: 'Skaffold run'
name: 'gcr.io/$PROJECT_ID/skaffold:alpha' # https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/skaffold
env:
- 'CLOUDSDK_COMPUTE_ZONE=us-central1-a'
- 'CLOUDSDK_CONTAINER_CLUSTER=[YOUR_CLUSTER_NAME]'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud container clusters get-credentials [YOUR_CLUSTER_NAME] --region us-central1-a --project [YAOUR_PROJECT_NAME]
if [ "$BRANCH_NAME" == "master" ]
then
skaffold run
fihttps://stackoverflow.com/questions/66373742
复制相似问题