This repository serves as the provider of a Terraform and Kubernetes Application which deploys the necessary infrastructure to provide a pangeo-forge Bakery on Google Cloud
You will need:
- A bucket for the terraform state, whose name is updated in
terraform/providers.tf
- You can create this by using the instructions here https://cloud.google.com/storage/docs/creating-buckets
- Terraform
- Google Cloud tools
- Make
- Depends on your distro of linux. Please see your disto docs.
- Kubectl
- docker
- https://docs.docker.com/get-docker/
- ensure you are in the docker group
- groupadd -aG docker
- reboot
- Lens (The Kubernetes IDE) - Optional
- https://k8slens.dev/#download
- Optional but makes debugging much much easier
- Helm
need a project set up with these APIs enabled:
- Kubernetes Engine API
- Cloud Storage API
- This will setup the relevant environment variables to install the bakery
- Fill it out with your own values
- init
- Authenticates with Google Cloud to setup the default application credentials for use by later stages
- install
- Provisions the cluster and storage infrastructure in Google Cloud
- test
- Registers a test recipe against the prefect cloud instance for use by your agent(s)
- destroy
- destroys all infrastructure from the last run of "make deploy"
- generatebakeryyaml
- Generates a bakery definition YAML
- Run
make init
to log in to Google Cloud - Run
make deploy
to set up the infrastructure against your Google Cloud account - Get a cup of tea whilst Prefect sorts itself out, this may take about 10 minutes.
- Run
make test-flow
to register the test flow against your new Prefect agent - Test infrastructure according to the procedure described in Testing section below.
- Run
make init
to ensure you are logged in to Google Cloud - Run
make deploy
to re-run terraform against your environment.- NOTE: The Terraform configuration is designed to be idempotent, so you should normally see "No changes. Your infrastructure matches the configuration."
- Test infrastructure according to the procedure described in Testing section below.
- Execute
make test-flow
to register the test flow against your new Prefect agent
Note:
make test-flow
DOES NOT run the flow. It only registers it. To run the flow, continue with the remaining steps, below.
- Login to the Prefect Cloud UI at https://cloud.prefect.io/
- From your Prefect project homepage, select
FLOWS
. - In the displayed table of flows, select the test flow, either by name or date.
- From the flow details page, use either the
RUN
orQUICK RUN
buttons to initiate a test run of this flow. - Introspect further details about this run using the Debugging instructions, below.
- Open Lens and add your cluster (this will leverage your updated kubectl config).
- To view pods in your namespace navigate to Workloads > Pods.
- From the Namespace: dropdown at the top right of the table, select the namespace you specified when deploying.
- Verify your Prefect agent pod is healthy.
- Get the info needed to access the Grafana instance with
make get-grafana-admin
. - In Lens, navigate to Network > Services.
- From the Namespace: dropdown at the top right of the table, select
loki-stack
. - Select
loki-stack-granafa
from the displayed table. Within Connection > Ports, click the80:3000/TCP
link and use usernameadmin
and the password obtained in step 1. - Browsing logs
-
Return to the main page and select the Explore icon on the left.
-
From the dropdown next to Explore in the top left of the page, select Loki, then click Log Browser.
Register and run a test flow according to the procedure described in Testing section above, before proceeding to step 3.
-
Use
make getinfo
to view a list of flow runs. -
Select the flow run of interest and a set of Loki search terms will be provided.
-
Enter the search term in the Log Browser bar and click Shift+Enter.
-
To include additional search terms you can add `| "" to the exising string.
-
- Once your flow is running and the Dask cluster pods have been created the Dask dashboard can be accessed at http://localhost:8787 once
make getinfo
has been run.
- Run
make init
to ensure you are logged in to Google Cloud - Run
make destroy
to destroy any infrastructure instantiated by terraform in the install step.
- The Prefect agent pod in the cluster uses the cluster's own Google Managed Identity (CLUSTER_SERVICE_ACCOUNT_NAME) to access storage
- The Prefect flow registration uses the STORAGE_SERVICE_ACCOUNT_NAME to access the storage and plant the files
- To apply tags to a resource, add them in
terraform/tags.tf
- Tags MUST BE lowercase letters,dash,underscore or numbers
- To generate a bakery YAML file, run
make generatebakeryyaml
. - The resulting YAML can be added to the bakery definition repo here https://github.com/pangeo-forge/bakery-database/blob/main/bakeries.yaml