kubectl run mysql-client --image=mysql:5.7 -it --rm --restart=Never -- /bin/bash
mysql -h mysql-service -uroot -proot_password -e 'SHOW databases;'
OR
mysql -h mysql-service -uroot -proot_password
| # HAProxy TCP Binary Check for Postgres Replica Instance | |
| # Copyright (C) "2021" Matous Jan Fialka, <https://mjf.cz/> | |
| # Released under the terms of "The MIT License" | |
| # https://www.postgresql.org/docs/current/protocol-message-formats.html | |
| backend postgres | |
| bind :5432 |
| #import random, math | |
| outputdebug = False | |
| def debug(msg): | |
| if outputdebug: | |
| print (msg) | |
| class Node(): | |
| def __init__(self, key): |
| # haproxy postgresql master check | |
| # | |
| # haproxy listen: 5432 | |
| # pg, instance #1 listen: 5432 (master node) | |
| # pg, instance #2 listen: 5432 (replica node) | |
| # external failover, promoting replica to master in case of failure | |
| # passwordless auth for user web | |
| # template1 database is accessible by user web | |
| # | |
| # haproxy will pass connection to postgresql master node: |
| SELECT table, | |
| formatReadableSize(sum(bytes)) as size, | |
| min(min_date) as min_date, | |
| max(max_date) as max_date | |
| FROM system.parts | |
| WHERE active | |
| GROUP BY table |
| # Sample haproxy postgresql master check | |
| # | |
| # haproxy listen: 5431 | |
| # pg, instance #1 listen: 5432 (master node) | |
| # pg, instance #2 listen: 5433 (replica node) | |
| # external failover, promoting replica to master in case of failure | |
| # passwordless auth for user web | |
| # template1 database is accessible by user web | |
| # | |
| # haproxy will pass connection to postgresql master node: |
| environment: | |
| SERVER_NAME: "myserver.doma.in" | |
| # Dummy key, cert | |
| SSL_KEY: |- | |
| -----BEGIN RSA PRIVATE KEY----- | |
| MIICXQIBAAKBgQD272jYrLm8Ph5QpMWFcWUO9Ua1EviykalP+tkMIg12yZ3GvezF | |
| y8aayxdztB5vu68jqMeg6mOJlscWqFUhmAxj4mDknYenVzVX2CKzCgHlGninTKxY | |
| 61rXDaDZVpSZ+XIESJkaB0z9HHYtrSLr0coKmq4cT5TRptOnkpDlJxIRaQIDAQAB | |
| AoGATcTYoGTFmiN2KK+8BWrRCQT2X9C5woNdb3LxKIEQ/HhC2HS4PRMQWW/c0vPH | |
| IilZ30EoneUztAFochpRtWLNg4lJoLy04X/eNjEiC/imp0KSwWXmnuLhDcWcb0+M |
| #!/bin/bash | |
| OUTDIR=. | |
| while read -r db ; do | |
| while read -r table ; do | |
| if [ "$db" == "system" ]; then | |
| echo "skip system db" | |
| continue 2; |
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| type Item struct{ | |
| Id int | |
| Name string | |
| Qty int |
| kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod |