--disable-copyfile stops AppleDouble ._ files with extended OS info from being tarred.
tar --disable-copyfile -cvzf ./target.tar.gz ./something| # All entites in k8s can be inspected with describe | |
| kubectl -n $NAMESPACE describe pod $POD |
| # All entities in k8s can be listed with get | |
| kubectl -n $NS get pod |
| gcloud container clusters get-credentials $CLUSTER --zone europe-west2-a --project $PROJECT | |
| kubectl config get-clusters | |
| echo Current context: $(kubectl config current-context) | |
| kubectl get ns |
Switching between Node.js version on macOS and pinning the one installed.
# Node 12 -> 14
brew unpin node@12
brew uninstall --force --ignore-dependencies node
brew install node@14
brew pin node@14
# Node 14 -> 12
Bash to a running docker container, dump Postrgres, copy the dump from the container, restore it to a local db.
# Get the name of the container
docker ps
# Bash to it
docker exec -it <DB CONTAINER NAME> /bin/bash
# Create a compressed dump| import ( | |
| "regexp" | |
| ) | |
| // The original W3C email regular expression taken from: | |
| // https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email) | |
| // It is modified to include a domain zone at the end (in JavaScript it works fine without modifications). | |
| // This expression doesn't support addresses with UTF characters. | |
| var emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\\.[a-zA-Z]{2,}$") |
| ```bash | |
| # Get credentials from GCP | |
| gcloud container clusters get-credentials $CLUSTER --zone $ZONE --project $PROJECT | |
| echo Current context: $(kubectl config current-context) | |
| SOURCE="<POD>:/tmp/dump.sql" | |
| TARGET="./$CLUSTER.dump.compressed.sql" | |
| # Create a dump inside a container running in k8s | |
| kubectl exec -n $NAMESPACE --stdin --tty $POD -c $CONTAINER -- pg_dump -f /tmp/dump.sql -F c -Z 9 -U <USER> <DATABSE> |
| to_timestamp(timestamp_in_milliseconds::numeric/1000) |