Issue
I am trying to setup a CI/CD pipeline on GCP. I would like following:
- new modification in Github is used as a trigger
- use
gcloud builds submit --config=cloud_build.yaml
to build a new docker image that contain the modification from git (mainly new python packages and python code) and push the image in ContainerRegistry - use
gcloud deployment-manager deployments
create xxx -- template pipeline.jinja --properties xxx` to deploy and run my container (it is a jupyter notebook)
I have the 2 last steps setup and working (gcloud
and gcloud deployment-manager
).
My question is how can I do that with one script ? I would line to have the pipeline fully automated. Some of the test I would like to implement is to test that python packages are installed properly will be done on the container after the deployment.
What is the best practices on GCP ? I was thinking that I could use gcloud deployment-manager
inside gcloud builds
but didn't really find documentation up to know how to do that. For the deployment, I have a lot of variables to pass to setup network, machine type and other parameters and I can only do it using jinja script.
Solution
What is the best practices on GCP ? I was thinking that I could use gcloud deployment-manager inside gcloud builds but didn't really find documentation up to know how to do that
Cloud Build provides and maintains pre-built images of builders that you can reference in your build steps to execute your tasks.
You can trigger the deployment manager using the gcr.io/cloud-builders/gcloud
(doc) builder:
# Build images
[...]
# Load/Generate your Jinja templates
[...]
# Deploy
- name: 'gcr.io/cloud-builders/gcloud'
id: Deploy your application
args: ['deployment-manager', 'deployments', 'create', 'your-template']
However, there are more conventional ways to deploy containerized application within a GKE cluster:
- via
gcr.io/cloud-builders/kubectl
to directly deploy application via well-defined Kubernetes manifests; - via Helm tool builder to package and deploy Kubernetes applications starting from custom templates.
Disclaimer: Comments and opinions are my own and not the views of my employer.
Answered By - vdenotaris Answer Checked By - Mary Flores (PHPFixing Volunteer)