Skip to content

Instantly share code, notes, and snippets.

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

Victor Yang pydevops

🏠
Working from home
View GitHub Profile
@pydevops
pydevops / private-k8s.md
Last active February 2, 2024 03:25
how to set up kubectl on laptop for private GKE cluster and on prem private cluster

HTTP tunnel

On prem k8s cluster set up with bastion vm

  1. Create a bastion vm in your data center or in cloud with connectivity set up (usually vpn) to the on prem data center.
  2. Install tinyproxy on the bastion vm and pick a random port as it would be too easy for spam bot with default 8888, set up as systemd service according to https://nxnjz.net/2019/10/how-to-setup-a-simple-proxy-server-with-tinyproxy-debian-10-buster/. Make sure it works by validating with curl --proxy http://127.0.0.1:<tinyproxy-port> https://httpbin.org/ip. And I don't use any user authentication for proxy, so I locked down the firewall rules with my laptop IP/32.
  3. Download the kubeconfig file for the k8s cluster to your laptop
  4. From your laptop, run
HTTPS_PROXY=<bastion-external-ip>:<tinyproxy-port> KUBECONFIG=my-kubeconfig kubectl get nodes
@pydevops
pydevops / gcloud-dump-networks.sh
Last active July 1, 2021 17:07
bash dump basic gcp networks
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
# For one project only
# Please make sure to run `gcloud config set project <project_id> first`
command -v gcloud >/dev/null 2>&1 || \
{ echo >&2 "I require gcloud but it's not installed. Aborting.";exit 1; }
@pydevops
pydevops / GitHub-Forking.md
Created February 11, 2019 22:09 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@pydevops
pydevops / VirtualBox Cheat Sheet
Created January 27, 2019 23:59 — forked from githubfoam/VirtualBox Cheat Sheet
VirtualBox Cheat Sheet
"VBoxManage" command is different from "sudo VBoxManage" command
VBoxManage --version
sudo apt-get dist-upgrade -y -> Debian-based linux makes sure VirtualBox Guest Additions is installed
VBoxManage list runningvms -> Find running vm to box
vagrant package --base xxxxx_1522057296984_52705 --output ubuntu1604.box --> Package running vm as vagrant box
# Download an ISO image of VirtualBox Guest Additions
@pydevops
pydevops / dict.md
Last active January 24, 2019 22:09
python refer name defined in another module

main.py

import config
globals().update(config.constants())
print(PI)

config.py

def constants():
 c={'PI':'3.14'}
@pydevops
pydevops / k8s-crd.md
Last active September 1, 2023 00:41 — forked from smileisak/operators.md
k8s crd operator

Some useful resources regarding Kubernetes Operators, CRDs, etc.

@pydevops
pydevops / firebase_demo.md
Last active November 1, 2018 22:25
set up firebase demo

Steps

  1. git clone https://github.com/pydevops/quickstart-js.git on your laptop.
  2. Insert the corresponding firebase web app config copied from firebase web console in storage/index.html
  3. Set up for development and deploy
$ brew install node # install node if you haven't
$ npm install -g firebase-tools
$ cd storage
$ firebase login
@pydevops
pydevops / gke-ingress-manged-tls.md
Last active August 10, 2023 09:20
Create a GCP managed TLS certificate for the GKE ingress

GKE ingress in a nutshell

Solution #1 (ManagedCertificate CRD in GKE)

  • GKE with Google-managed SSL certificates
    • Use ManagedCertificate CRD to create a object.
    • Associate the ManagedCertificate object to an Ingress by adding an annotation networking.gke.io/managed-certificates to the Ingress. This annotation is a comma-separated list of ManagedCertificate resources, cert1,cert2,cert3 for example.

Solution #2 (Google Cloud SSL Certificate)

Assumption

@pydevops
pydevops / bitbucket.py
Last active October 13, 2018 19:59
bitbucket clone repo
#!/usr/bin/env python
from __future__ import print_function
import json
import sys
import requests
import getpass
'''
Given the bitbucket.org user id,