Skip to content

Instantly share code, notes, and snippets.

# for chart version 2.3.41
datadog:
logLevel: DEBUG
kubeStateMetricsEnabled: false
leaderElection: true
collectEvents: true
processAgent:
enabled: true
dogstatsd:
nonLocalTraffic: true
@madsonic
madsonic / update-terragrunt-0.23.sh
Last active February 18, 2021 09:08
terragrunt 0.23 migration script
#!/usr/bin/env bash
# 0.23.0 terragrunt migration script
# behaviour of find_in_parent_folders() has changed to use absolute path
# https://github.com/gruntwork-io/terragrunt/releases/tag/v0.23.0
# this has been test on macOS
# you might need to change some flags for certain distro of the commands used here
git stash save -u
@madsonic
madsonic / dumps.sh
Last active February 17, 2021 03:31
mysql commands
# dump as per normal
# column statistics should be off by default
mysqldump -p -u <user> -h <host> --all-databases --comments --dump-date --column-statistics=0 > dump.sql
# replace rdsadmin user with your master user
sed -i -e 's/DEFINER=`rdsadmin`@`localhost`/DEFINER=`<masteruser>`@`%`/g' dump.sql
# one liner if you need to pipe to a remote host without a dump file as output
# this method wont work if password input is required
mysqldump -p -u <user> -h <host> \
@madsonic
madsonic / docker-hub-rate-limit.sh
Last active December 14, 2020 10:02
check docker hub rate limit balance
# annonymous
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" \
| jq -r .token) && curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest \
| grep 'RateLimit'
# authenticated
# note that there should be no output
# https://docs.docker.com/docker-hub/download-rate-limit/#i-dont-see-any-ratelimit-headers
TOKEN=$(curl --user 'username:password' "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token) \
&& curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest \
@madsonic
madsonic / kubectl-jq
Last active March 25, 2020 14:14
kubectl-jq
# conditional expr
# select(.metadata.name == "abc") single test
# select(.metadata.name|test("abc.")) regex test
# final pipe expr prints in defined json shape
k get deploy --all-namespaces -o json | \
jq '.items[] | select(.metadata.name|test("abc.") | not) | {"name":.metadata.name,"podSpec":.spec.template.spec}'
@madsonic
madsonic / datadog logs
Last active March 19, 2020 03:26
datadog cheatsheet
# docs are too subtle and sparing with obvious use cases
# search on tag
tag: value
# exclusion
-tag: my-value
# search on facet
@facetname: value
@madsonic
madsonic / gist:7a649276564b514cc413466b633c7520
Created March 4, 2020 02:56
elastic beanstalk operations
# update version
aws elasticbeanstalk update-environment --application-name <name> --environment-name <env> --version-label <version>
# update env var
aws elasticbeanstalk update-environment --environment-name my-env \
--option-settings Namespace=aws:elasticbeanstalk:application:environment,OptionName=PARAM1,Value=ParamValue
@madsonic
madsonic / gist:90bbd8a68447150226963723b88f9dfe
Created March 2, 2020 23:10
aws rds certificate rotation
# rotate without restart if current connections are non SSL
for db in "db1" "db2"; do
aws rds modify-db-instance \
--db-instance-identifier "$db" \
--ca-certificate-identifier "rds-ca-2019" \
--apply-immediately \
--no-certificate-rotation-restart
done
# viewing certs
@madsonic
madsonic / brew
Created December 5, 2019 07:05
brew install specific version
brew uninstall kubernetes-cli
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d09d97241b17a5e02a25fc51fc56e2a5de74501c/Formula/kubernetes-cli.rb
brew pin kubernetes-cli
@madsonic
madsonic / .spec.containers.command
Last active May 28, 2021 09:32
more readable container commands
command:
- "/bin/sh"
- "-c"
args:
- |
echo hello
i=0
while ((i<5))
do
echo hello${i}