This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl auth can-i list secrets --namespace dev --as dave |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# foo.service | |
[Unit] | |
Description=do something | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/bin/script1 | |
ExecStart=/usr/bin/script2 | |
[Install] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -exuo pipefail | |
# An example hook script to verify what is about to be committed. | |
# Called by "git commit" with no arguments. The hook should | |
# exit with non-zero status after issuing an appropriate message if | |
# it wants to stop the commit. | |
# | |
# To enable this hook, rename this file to "pre-commit". | |
# do some validation here e.g. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create dockerconfigjson from scratch | |
cat <<EOF >> dockerconfigjson | |
{ | |
"auths": { | |
"https://index.docker.io/v1/": { | |
"auth": "$(base64 --input=credfile)" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create dockerconfigjson from scratch | |
cat <<EOF >> dockerconfigjson | |
{ | |
"auths": { | |
"https://index.docker.io/v1/": { | |
"auth": "$(base64 --input=credfile)" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# manual | |
certbot --help all | |
# Add Certbot PPA | |
sudo apt-get update -y | |
sudo apt-get install -y software-properties-common | |
sudo add-apt-repository universe | |
sudo add-apt-repository ppa:certbot/certbot | |
sudo apt-get update -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTANCE_CONNECTION_NAME: <projname>:<region>:<db-instance-name> (myproject:us-central1:myinstance) | |
# tcp socket | |
/cloud_sql_proxy -instances=<INSTANCE_CONECTION_NAME>=tcp:<port-number> \ | |
-crendential_file=<PATH_TO_KEY_FILE> | |
psql "host=127.0.0.1 sslmode=disable dbname=<DB_NAME> user=<USER_NAME>" | |
# unix socket | |
sudo mkdir /cloudsql; sudo chmod 777 /cloudsql | |
# service account based (explicit instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo '{"facility": "testfacility", "short_message": "test message"}' | nc -w 2 -u <endpoint> <port> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# customise output format with go template | |
kubectl ... -o go-template --template="{{range .items}}{{range .spec.containers}}{{.image}} {{end}}{{end}}" | |
kubectl get deploy -o go-template --template='{{range .items}}{{printf "%s\n" .metadata.name}}{{end}}' | |
# for keys with dots or special characters | |
kubectl get secrets regcred -o "jsonpath={ .data['\.somesecret'] }" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list of commands useful for scripting | |
# there are other shorter but gives less precise command mainly for human consumption | |
# rather than scripts. those commands are not the focus of this gist | |
# accidentally tracking a large repo via git fetch | |
# and to stop tracking unused remote branches | |
git br -d -r <branch-name> | |
# to remove everything in one command | |
git br -r | xargs git br -d -r |