Skip to content

Instantly share code, notes, and snippets.

View mikesparr's full-sized avatar

Mike Sparr mikesparr

  • Montana, USA
View GitHub Profile
@mikesparr
mikesparr / gcp-sql-postgres-pgvector.sh
Created September 28, 2023 21:49
Experiment testing pgvector extension for Google Cloud SQL Postgres
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/sql/docs/postgres/create-instance
# - https://cloud.google.com/sql/docs/postgres/create-manage-databases
# - https://cloud.google.com/sql/docs/postgres/users
# - https://cloud.google.com/blog/products/databases/using-pgvector-llms-and-langchain-with-google-cloud-databases
# - https://cloud.google.com/sql/docs/postgres/extensions#miscellaneous-extensions
# - https://github.com/pgvector/pgvector
@mikesparr
mikesparr / gcp-global-lb-multi-region-cr-ce.sh
Last active January 18, 2024 00:39
Demonstrating how you can deploy Cloud Run (serverless) or Compute Engine instance groups across regions and balance with global load balancer
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/run/docs/multiple-regions
# - https://cloud.google.com/compute/docs/instance-groups/distributing-instances-with-regional-instance-groups
# - https://cloud.google.com/load-balancing/docs/https/setup-global-ext-https-compute
# - https://cloud.google.com/load-balancing/docs/backend-service#named_ports
#####################################################################
@mikesparr
mikesparr / gcp-gae-global-lb.sh
Last active August 11, 2023 03:44
Experiment load balancing an App Engine app in 2 regions
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/vpc/docs/provisioning-shared-vpc
# - https://cloud.google.com/appengine/docs/flexible/go/create-app
# - https://cloud.google.com/appengine/docs/flexible/using-shared-vpc
# - https://gist.github.com/campoy/7b44f6ec2d9e82d956d34b4989b33192
# - https://cloud.google.com/appengine/docs/standard/ingress-settings#view_ingress_settings
# - https://cloud.google.com/sdk/gcloud/reference/app/services/update
@mikesparr
mikesparr / gcp-alb-url-rewrite.sh
Last active August 8, 2023 23:48
Experiment with GCP application load balancer in front of Cloud Run service testing URL rewrite capabilities
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/run/docs/deploying#command-line
# - https://hub.docker.com/r/ealen/echo-server
# - https://cloud.google.com/load-balancing/docs/https/setup-global-ext-https-serverless
# - https://cloud.google.com/load-balancing/docs/url-map-concepts#wildcards-regx-dynamic-route
# - https://cloud.google.com/load-balancing/docs/url-map-concepts#example_url_map_workflow_with_an
#####################################################################
@mikesparr
mikesparr / gcp-datastream-mysql-gcs.sh
Last active August 4, 2023 07:13
Experiment using Datastream to implement CDC between Cloud SQL (MySQL) database and Google Cloud Storage (GCS) bucket
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/vpc/docs/create-modify-vpc-networks
# - https://cloud.google.com/sql/docs/mysql/configure-private-services-access
# - https://cloud.google.com/sql/docs/mysql/configure-private-ip
# - https://cloud.google.com/iam/docs/service-accounts-create
# - https://cloud.google.com/compute/docs/instances/startup-scripts/linux
# - https://cloud.google.com/storage/docs/discover-object-storage-gcloud
@mikesparr
mikesparr / gke-internal-ingress-path-routing.sh
Last active July 27, 2023 13:34
Experiment with Google Cloud Platform Kubernetes Engine (GKE) internal ingress fronted by self-managed web proxy server and path-based routing
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/kubernetes-engine/docs/how-to/internal-load-balance-ingress
# - https://cloud.google.com/compute/docs/containers/deploying-containers
# - https://cloud.google.com/compute/docs/containers/configuring-options-to-run-containers
# - https://cloud.google.com/sdk/gcloud/reference/compute/instance-templates/create-with-container
# - https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-docker
# - https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/
@mikesparr
mikesparr / gcp-cloud-build-cloud-sql.sh
Created May 22, 2023 21:26
Example connecting private Cloud Build pool to Cloud SQL private Postgres database on Google Cloud Platform (GCP)
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/sql/docs/postgres/configure-private-ip
# - https://cloud.google.com/build/docs/private-pools/create-manage-private-pools#gcloud
# - https://cloud.google.com/build/docs/private-pools/set-up-private-pool-to-use-in-vpc-network#setup-private-connection
#####################################################################
export PROJECT_ID=$(gcloud config get-value project)
@mikesparr
mikesparr / gcp-vpn-vpc-to-vpc.sh
Last active May 22, 2023 23:18
Example setting up Cloud VPN on Google Cloud Platform (GCP) to connect two VPCs
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/sql/docs/postgres/configure-private-ip
# - https://cloud.google.com/build/docs/private-pools/set-up-private-pool-to-use-in-vpc-network#setup-private-connection
# - https://cloud.google.com/network-connectivity/docs/vpn/how-to/creating-ha-vpn2#gcloud
# - https://cloud.google.com/network-connectivity/docs/vpn/how-to/creating-ha-vpn (optional with peering)
#####################################################################
@mikesparr
mikesparr / org-policies-gcloud-gcp.sh
Created May 19, 2023 22:16
Recommended GCP Organization Policies
#####################################################################
# ORG POLICIES (SET ON DEMO PARENT FOLDER FOR DEMO [SHOULD SET ON ORG])
# REF: https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints#how-to_guides
# REF: https://cloud.google.com/storage/docs/org-policy-constraints
#####################################################################
# disable external IPs for VMs
export IP_POLICY_FILE=policy-extip.json
cat > $IP_POLICY_FILE << EOF
{
"constraint": "constraints/compute.vmExternalIpAccess",
@mikesparr
mikesparr / cert-manager-autopilot.yaml
Created April 26, 2023 23:17
Cert Manager install script for GKE Autopilot replacing kube-system namespaced elements
# Copyright 2022 The cert-manager Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,