-
Notifications
You must be signed in to change notification settings - Fork 0
/
adn-navi.cheat
117 lines (65 loc) · 3.94 KB
/
adn-navi.cheat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
% k8s, secret
# Copy to clipboard the value of a kubernetes secret
kubectl get secret --namespace=<namespace> <secretName> -o jsonpath='{.data.<key>}' | base64 -D | pbcopy
$ namespace: kubectl get namespace --- --column 1 --header-lines 1
$ secretName: kubectl get secret --namespace=<namespace> --- --column 1 --header-lines 1
$ key: kubectl get secret <secretName> --namespace <namespace> -o jsonpath='{.data}' | jq -r '. | keys[] '
% tobs, k8s, grafana, secret
# Copy to clipboard passwword for tobs grafana admin
kubectl get secret --namespace=bench tobs-grafana -o jsonpath='{.data.admin-password}' | base64 -D | pbcopy
% tobs, k8s, secret, postgres
# Copy to clipboard passwword for tobs postgres user
kubectl get secret --namespace=bench tobs-promscale-connection -o jsonpath='{.data.PROMSCALE_DB_PASSWORD}' | base64 -D | pbcopy
% wget
# wget to stdout
wget -q -O -
% docker
# Run a container that exposes a port
docker run --rm -p 8080:<port> <image>
$ image: docker images --- --header-lines 1 --map "awk '{print $1\":\"$2}'"
% docker
# Kill a container
docker kill <container>
$ container: docker ps --- --header-lines 1 --column 1
% aws, bcc, ebpf
# Install BCC tools in Amazon Linux 2
echo "sudo amazon-linux-extras install BCC" | pbcopy
% k8s, node, pod
# Get Node where Pod is running
kubectl get pod <pod> --namespace <namespace> -o=custom-columns=NAME:.metadata.name,NODE:.spec.nodeName
$ namespace: kubectl get namespace --- --header-lines 1 --column 1
$ pod: kubectl get pod --namespace=<namespace> --- --header-lines 1 --column 1
% k8s, node, timescale, ssh
# ssh into timescale node
sshTS <dnsName>
$ nodeName: kubectl get pod tobs-timescaledb-0 --namespace bench -o=custom-columns=NODE:.spec.nodeName --no-headers
$ instanceId: kubectl get node <nodeName> -o=custom-columns=NODE:".metadata.annotations.csi\.volume\.kubernetes\.io/nodeid" --no-headers | jq -r '."ebs.csi.aws.com"'
$ dnsName: aws ec2 describe-instances --instance-ids=<instanceId> | jq -r '..|."PublicDnsName"? | select(. != null) ' | head -n 1
# One liner:
# ssh ec2-user@$(aws ec2 describe-instances --instance-ids=$(kubectl get node $(kubectl get pod tobs-timescaledb-0 --namespace bench -o=custom-columns=NODE:.spec.nodeName --no-headers) -o=custom-columns=NODE:".metadata.annotations.csi\.volume\.kubernetes\.io/nodeid" --no-headers | jq -r '."ebs.csi.aws.com"') | jq -r '..|."PublicDnsName"? | select(. != null) ' | head -n 1)
% timescale, scp
# scp ~/*.txt files from timescale node
scp ec2-user@<dnsName>:\*.txt .
$ nodeName: kubectl get pod tobs-timescaledb-0 --namespace bench -o=custom-columns=NODE:.spec.nodeName --no-headers
$ instanceId: kubectl get node <nodeName> -o=custom-columns=NODE:".metadata.annotations.csi\.volume\.kubernetes\.io/nodeid" --no-headers | jq -r '."ebs.csi.aws.com"'
$ dnsName: aws ec2 describe-instances --instance-ids=<instanceId> | jq -r '..|."PublicDnsName"? | select(. != null) ' | head -n 1
% benchmark
# Copy command to donwload benchmarkstats.sh
echo "sudo su\nwget https://gist.githubusercontent.com/alejandrodnm/e3ec3433f38186a4c54bbc01bbd34fcc/raw/a36b1022241266a75eb0a5edd9069cf882fa30cf/benchmarkstats.sh\nchmod +x benchmarkstats.sh\n./benchmarkstats.sh -i" | pbcopy
% docker, psql
# Run psql on a docker container
docker exec -it <container> psql
$ container: docker ps | rg 'timescale|postgres' --- --column 1
% docker, pgcli
# Connect pgcli to the container
pgcli -p $(docker inspect --format='{{(index (index .NetworkSettings.Ports "5432/tcp") 0).HostPort}}' <container>) -h 127.0.0.1 -u postgres
$ container: docker ps | rg 'timescale|postgres' --- --column 1
% docker
# Remove dangling volumes
docker volume rm $(docker volume ls -qf dangling=true)
% docker
# Prune everything
docker system prune -f ; docker volume prune -f ; docker rm -f -v $(docker ps -q -a)
% docker, timescale, postgres
# Runs a timescale container on 5433
docker run --rm --name ts -e POSTGRES_HOST_AUTH_METHOD=trust -p 5433:5432 timescale/timescaledb-ha:pg15