问题
I'm using the "Workloads" service of Kubernetes Engine of Google Cloud Platform to deploy my application.
Once you click on deploy I can see in "Cloud Build" what command GCP has launched:
The current build command is: build -t gcr.io/ma...g:9e4dab3 -d Dockerfile
Is there a way to change the build command ? Like: build -t gcr.io/ma...g:9e4dab3 -d Dockerfile --build-arg APP_ENV=dev
回答1:
Workloads is a beta feature, and doesn't include any option to add or modify the build command you can open a feature request for this functionality.
As a workaround you can create your image directly and storing it on Container Registry by using Cloud build with all parameters necessaries for your image.
Additionally you can create a build to automate this process, For example:
steps:
#Building Red Velvet Image
- name: 'gcr.io/cloud-builders/docker'
id: build-redvelvet
args:
- build
- --tag=${_RV}:$SHORT_SHA
- --tag=${_RV}:latest
- --build-arg APP_ENV=dev
- .
dir: 'redvelvet/'
#Pushing Red Velvet Image
- name: 'gcr.io/cloud-builders/docker'
id: push-redvelvet
args:
- push
- ${_RV}
#Deploying to GKE
- name: "gcr.io/cloud-builders/gke-deploy"
id: deploy-gke
args:
- run
- --filename=something.yaml
- --location=${_COMPUTE_ZONE}
- --cluster=${_CLUSTER_NAME}
#Update Red Velvet Image
- name: 'gcr.io/cloud-builders/kubectl'
id: update-redvelvet
args:
- set
- image
- deployment/redvelvet-deployment
- redvelvet=${_RV}:$SHORT_SHA
env:
- 'CLOUDSDK_COMPUTE_ZONE=${_COMPUTE_ZONE}'
- 'CLOUDSDK_CONTAINER_CLUSTER=${_CLUSTER_NAME}'
waitFor:
- deploy-gke
substitutions:
_RV: gcr.io/${PROJECT_ID}/redvelvet
_CLUSTER_NAME: something
_COMPUTE_ZONE: us-central1
来源:https://stackoverflow.com/questions/65532820/kubernetes-engine-gcp-how-to-change-arguments