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
# get status of a job | |
$ nomad job status -no-color kafka-broker | |
ID = kafka-broker | |
Name = kafka-broker | |
Submit Date = 2019-07-24T14:03:41-07:00 | |
Type = service | |
Priority = 50 | |
Datacenters = alpha | |
Status = dead | |
Periodic = false |
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/bash | |
apt-get update | |
apt-get install -y psmisc | |
i="0" | |
while [ $i -lt 10 ] | |
do | |
if [ $(fuser /var/lib/dpkg/lock) ]; then |
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
Here’s a bash function to make it easier to shell into kubernetes pods. Running `kubash` by itself will give you a list of pod names; | |
$ kubash <pod name # will open a bash shell on a pod with that name. It works via prefix matching so any of the following would work: | |
$ kubash railsapp-68b45f5c7b-98qqz #attach to this specific pod | |
$ kubash railsapp #attach to any railsapp-* pod | |
$ kubash ra #attach to some pod that starts with "ra" | |
/bin/kubash | |
kubash() { | |
if [ "$1" = "" ]; then |
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
apt-get update -o Acquire::Check-Valid-Until=false |
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
# Encrypt a key for use in aws secrets manager terraform state files | |
1. Encrypt a secret using the aws cli | |
$ echo "<secret>" | tr -d '\n' > secret.txt # strip the newline from the echo | |
$ aws kms encrypt --key-id alias/aws/secretsmanager --plaintext fileb://secret.txt --encryption-context "type=password,env=staging" --output text --query CiphertextBlob | pbcopy | |
2. Create the aws_kms_secrets data resource in terraform | |
data "aws_kms_secrets" "mercury" { | |
secret { | |
name = "staging_db_password" |
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
$ nc -vz -u 10.100.0.10 53 | |
Connection to 10.100.0.10 53 port [udp/domain] succeeded! | |
# nc -vz 10.100.0.10 443 | |
Connection to 10.100.0.10 443 port [tcp/*] succeeded! |
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/bash | |
echo "waiting for elasticsearch" | |
for i in {1..60}; do | |
nc_output=$(nc -zv localhost 9200 2>&1 >/dev/null) | |
[[ $nc_output == *"open"* ]] && break | |
sleep 1 | |
echo -n "." | |
done |
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
# get logs from a pod | |
$ kubectl logs -f <pod name> --namespace <namespace> | |
# get logs from a specific container in a pod | |
$ kubectl logs -f <pod name> -c <container> -n <namespace> | |
# get logs across several containers | |
$ kubectl logs -l istio=ingressgateway -n istio-system -c ingress-sds # by using label | |
# get list of pods and observe their logs |
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
# run bash in a specific container image | |
docker run -it <image> /bin/bash | |
# run bash and mount a local volume into a specific contaimer image | |
docker run -it -v $(pwd):/pki-tools/pki dprails/pki-tools /bin/bash | |
# run a x86 docker image on M1 mac | |
docker run -it --platform linux/amd64 -v $(pwd):/pki-tools/pki dprails/pki-tools /bin/bash | |
# build on m1 mac |
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
sudo apt-get remove --purge mysql-server mysql-client mysql-common | |
sudo apt-get autoremove | |
sudo apt-get autoclean | |
dpkg -l | grep mysql | |
sudo apt-get install mysql-client-core-5.6 | |
sudo apt-get update | |
sudo add-apt-repository -y ppa:ondrej/mysql-5.6 | |
sudo apt-get update | |
sudo apt-get install mysql-client-core-5.6 | |
dpkg -l | grep mysql |