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
watch -n 1 gcloud container clusters list
watch -n 1 gcloud container clusters list
# Variables
INSTANCE_IP=$(curl -s api.ipify.org)
INSTANCE_CIDR=$INSTANCE_IP/32
ARRAY=("https-api-remote-k8s-local" "ssh-external-to-master-remote-k8s-local" "ssh-external-to-node-remote-k8s-local")
for item in ${ARRAY[@]}
do
echo "Updating firewall-rule $item source-range to $INSTANCE_CIDR"
gcloud compute firewall-rules update $item --source-ranges=$INSTANCE_CIDR
## Setting variables for GKE
export CLUSTER_NAME="central"
export CLUSTER_ZONE="us-central1-b"
export CLUSTER_KUBECONFIG=$WORK_DIR/$CLUSTER_NAME.context
# Variables for remote kops cluster
export REMOTE_CLUSTER_NAME_BASE="remote"
export REMOTE_CLUSTER_NAME=$REMOTE_CLUSTER_NAME_BASE.k8s.local
Set up tmux panes in Cloud Shell
You are going to configure three Cloud Shell panes so that you can issue commands in one pane and watch the effects on the two clusters in the other panes.
Split the session screen with the tmux utility built-into Cloud Shell by typing <Ctrl>+b, then %. You should see 2 panes in the Cloud Shell.
Dual tmux panes
Any time you interact with tmux, you'll start with the <Ctrl>+b combination, which signals a command to tmux.
Switch to the left-hand pane by typing:
export GCLOUD_EMAIL=$(gcloud config get-value account)
cd $LAB_DIR
ssh-keygen -t rsa -b 4096 \
-C "$GCLOUD_EMAIL" \
-N '' \
-f $HOME/.ssh/id_rsa.acm
kubectx gke
kubectl create secret generic git-creds \
--namespace=config-management-system \
git init
git add .
git commit -m "Initial config repo commit"
gcloud source repos create anthos_config
git config credential.helper gcloud.sh
git remote add origin https://source.developers.google.com/p/$PROJECT_ID/r/anthos_config
git push origin master
export GCLOUD_EMAIL=$(gcloud config get-value account)
echo $GCLOUD_EMAIL
echo $USER
git config --global user.email "$GCLOUD_EMAIL"
git config --global user.name "$USER"
edit config-management-operator.yaml
export LAB_DIR=$HOME/acm-lab
mkdir $LAB_DIR
cd $LAB_DIR
gsutil cp gs://config-management-release/released/latest/config-management-operator.yaml config-management-operator.yaml