I'm trying to create multiple deployments using Cloud Build and Cloud Deploy in GKE cluster. Below is my cloudbuild.yaml
steps:
- name: "gcr.io/cloud-builders/gcloud"
entrypoint: 'bash'
args:
- '-c'
- |
while IFS= read -r deplname; do
sed -i "s/service/$$deplname/g" ./test/deployment.yaml
release_name=$$(echo "build-$$RANDOM")
gcloud deploy releases create $$release_name --project=PROJECT_ID --region=us-central1 --delivery-pipeline=test-cloud-deploy --source=. --images=test-cloud-deploy=us-central1-docker.pkg.dev/PROJECT_ID/cicd-test/test-image:v1
done < ./consumer_names.txt
options:
logging: CLOUD_LOGGING_ONLY
my consumer_names.txt
looks like,
deployment-name1
deployment-name2
deployment.yaml
looks like,
apiVersion: apps/v1
kind: Deployment
metadata:
name: service
spec:
selector:
matchLabels:
app: service
template:
metadata:
labels:
app: service
spec:
containers:
- name: service
image: nginx
ports:
- containerPort: 80
But it's creating only one deployment that is deployment-name1
not second. Is there any way to create multiple deployments using cloud build and cloud deploy ?