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 / mini-qa.py
Last active June 6, 2024 16:35
Experiment with Langchain, OpenAI, and Datastax AstraDB (vector database) for custom LLM Q&A bot in Python
#!/usr/bin/env python3
# Reference: https://www.youtube.com/watch?v=yfHHvmaMkcA (Tutorial - some dated libs fixed in here)
# set constants
ASTRA_DB_APPLICATION_TOKEN="<< YOUR APP TOKEN (starts with AstraCS:) >>"
ASTRA_DB_SECURE_BUNDLE_PATH="<< FULL PATH TO YOUR ASTRA DB BUNDLE >>"
ASTRA_DB_CLIENT_ID="<< YOUR ASTRA DB CLIENT ID >>"
ASTRA_DB_CLIENT_SECRET="<< YOUR ASTRA DB CLIENT SECRET >>"
ASTRA_DB_KEYSPACE="search"
@mikesparr
mikesparr / cloudbuild-dev-push.yaml
Created August 21, 2020 03:52
Google Cloud Build config for push to develop branch
steps:
# Build image and push to GCR
- name: 'gcr.io/cloud-builders/docker'
id: Build
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/$_SERVICE_NAME:$SHORT_SHA'
- '.'
# TODO: look into [images]
@mikesparr
mikesparr / 01-architecting-solutions.md
Last active May 26, 2024 15:40
Study Guide for GCP Professional Cloud Architect exam (notes from refresher course)

Architecting for the cloud

  • Architect solutions to be scalable and reilient
  • Business requirements involve lowering costs / enhancing user experience
  • Keep an eye on technical needs during development and operation

3 Major Questions To Ask

  1. Where is the company coming from
@mikesparr
mikesparr / gcp-netbox-managed.sh
Last active May 23, 2024 17:51
Experiment setting up Netbox on Google Cloud Platform leveraging managed services
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://docs.netbox.dev/en/stable/installation/3-netbox/
# - https://github.com/netbox-community/netbox-docker/wiki/
# - https://hub.docker.com/r/netboxcommunity/netbox
# - https://cloud.google.com/sql/docs/postgres/configure-private-ip
# - https://cloud.google.com/sql/docs/postgres/create-instance
# - https://cloud.google.com/sql/docs/postgres/create-manage-databases#gcloud
@mikesparr
mikesparr / gcp-aws-site-to-site-vpn.sh
Last active April 21, 2024 13:49
Example site to site VPN between Google Cloud Platform (GCP) and Amazon Web Services (AWS)
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/architecture/build-ha-vpn-connections-google-cloud-aws
# - https://cloud.google.com/vpc/docs/private-service-connect
#####################################################################
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
@mikesparr
mikesparr / cloud-run-nat-serial.sh
Last active April 18, 2024 03:43
Experiment on Google Cloud with Cloud Run, Cloud NAT, Private Google Access, and Secure Web Proxy with NAT only for external requests
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/sdk/gcloud/reference/compute/networks/create
# - https://cloud.google.com/sdk/gcloud/reference/compute/networks/subnets/create
# - https://cloud.google.com/vpc/docs/configure-private-google-access
# - https://cloud.google.com/network-connectivity/docs/router/how-to/create-router-vpc-network#gcloud
# - https://cloud.google.com/nat/docs/set-up-manage-network-address-translation
# - https://cloud.google.com/nat/docs/using-nat-rules
@mikesparr
mikesparr / gcp-gae-cr-private.sh
Last active April 15, 2024 21:18
Example Google Cloud Platform (GCP) serverless apps communicating via private network
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/run/docs/securing/private-networking#from-other-services
# - https://cloud.google.com/run/docs/securing/private-networking#from-vpc
# - https://cloud.google.com/appengine/docs/flexible/disable-external-ip
# - https://cloud.google.com/dns/docs/records#adding_or_removing_a_record
# - https://cloud.google.com/vpc/docs/configure-private-google-access
# - https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-go-service
@mikesparr
mikesparr / gcp-global-lb-multi-region-cr-ce.sh
Last active April 12, 2024 04:26
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 / cloud-next-24-demo.sh
Last active April 8, 2024 03:57
Snippets from my Cloud Next '24 demo talk "Hello Gateway, Goodbye Ingress" in Las Vegas April 9, 2024
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/kubernetes-engine/docs/concepts/gateway-api
# - https://cloud.google.com/kubernetes-engine/docs/how-to/container-native-load-balancing
# - https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/
# - https://cloud.google.com/gemini/docs/quickstart
# - https://cloud.google.com/kubernetes-engine/docs/best-practices/rbac
# - https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster#group_authentication
@mikesparr
mikesparr / gcp-secure-web-proxy-1.sh
Created March 29, 2024 18:35
Experiment using Google Cloud Secure Web Proxy and Cloud NAT
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/secure-web-proxy/docs/initial-setup-steps
# - https://cloud.google.com/certificate-manager/docs/deploy-google-managed-regional
# - https://cloud.google.com/secure-web-proxy/docs/quickstart
# - https://cloud.google.com/secure-web-proxy/docs/enable-tls-inspection (OPTIONAL)
#####################################################################