Skip to content

Instantly share code, notes, and snippets.

View mesmacosta's full-sized avatar
🏠
Working from home

Marcelo Costa mesmacosta

🏠
Working from home
View GitHub Profile
# Change the placeholder {tag-central-project-id}
export GOOGLE_CLOUD_PROJECT={tag-central-project-id}
export SA_NAME=terraform-dc-resources-sa
# Create Service Account
gcloud iam service-accounts create $SA_NAME \
--display-name "Service Account to create DC Resources" \
--project $GOOGLE_CLOUD_PROJECT
# Add Tag Template Owner role
def _get_secrets_manager_property(property_name):
client = secretmanager.SecretManagerServiceClient()
project_id = os.environ.get('DATACATALOG_PROJECT_ID')
secret_path = client.secret_version_path(project_id, property_name, 'latest')
response = client.access_secret_version(secret_path)
return response.payload.data.decode('UTF-8')
def sync(event, context):
"""Sync PostgreSQL metadata with Google Data Catalog
"""
try:
# Log out the message that triggered the function
logging.info('This Function was triggered by messageId {} published at {}'.
format(context.event_id, context.timestamp))
logging.info('Starting sync logic.')
function upsert_cloud_function() {
local topic_name=$1
local project_id=$2
local project_number=$3
local service_account_name=$4
cat <<EOF >.env.yaml
DATACATALOG_PROJECT_ID: $DATACATALOG_PROJECT_ID
DATACATALOG_PROJECT_NUMBER: "$project_number"
DATACATALOG_LOCATION_ID: $DATACATALOG_LOCATION_ID
version: "3"
services:
zookeeper-1:
image: confluentinc/cp-zookeeper:latest
environment:
ZOOKEEPER_SERVER_ID: 1
ZOOKEEPER_CLIENT_PORT: 22181
ZOOKEEPER_TICK_TIME: 2000
ZOOKEEPER_INIT_LIMIT: 5
ZOOKEEPER_SYNC_LIMIT: 2
#!/usr/bin/env bash
export ATLAS_SERVER_HEAP="-Xms15360m -Xmx15360m -XX:MaxNewSize=5120m -XX:MetaspaceSize=100M -XX:MaxMetaspaceSize=512m"
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto
export MANAGE_LOCAL_HBASE=true
export MANAGE_LOCAL_SOLR=true
cd /opt/kafka/kafka_2.11-1.0.0/
# Get external IP
external_ip_address=$(curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip)
function create_cloud_scheduler() {
local topic_name=$1
gcloud scheduler jobs create pubsub gcs-run-postgresql-connector \
--schedule "$CRON_SCHEDULE" \
--topic $topic_name \
--message-body "sync"
}
curl --request POST \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--data '' \
"https://meshconfig.googleapis.com/v1alpha1/projects/${PROJECT_ID}:initialize"
export PILOT_POD_IP=$(kubectl -n istio-system get pod -l istio=pilot -o jsonpath='{.items[0].status.podIP}')
export POLICY_POD_IP=$(kubectl -n istio-system get pod -l istio=mixer -o jsonpath='{.items[0].status.podIP}')
export TELEMETRY_POD_IP=$(kubectl -n istio-system get pod -l istio-mixer-type=telemetry -o jsonpath='{.items[0].status.podIP}')
echo "Pilot: $PILOT_POD_IP"
echo "Istio-Policy (mixer): $POLICY_POD_IP"
echo "Istio-Telemetry (mixer): $TELEMETRY_POD_IP"
HELM_DIR="istio-${ISTIO_VERSION}/install/kubernetes/helm/istio"
helm template istio-remote $HELM_DIR \
set -euo pipefail
source ./scripts/env.sh
function join_by { local IFS="$1"; shift; echo "$*"; }
ALL_CLUSTER_CIDRS=$(gcloud container clusters list --format='value(clusterIpv4Cidr)' | sort | uniq)
ALL_CLUSTER_CIDRS=$(join_by , $(echo "${ALL_CLUSTER_CIDRS}"))
ALL_CLUSTER_NETTAGS=$(gcloud compute instances list --format='value(tags.items.[0])' | sort | uniq)
ALL_CLUSTER_NETTAGS=$(join_by , $(echo "${ALL_CLUSTER_NETTAGS}"))