k8s native config mgmt

This commit is contained in:
tim
2024-07-26 20:09:19 -04:00
parent 0786ec898b
commit 5051461eeb
6 changed files with 130 additions and 0 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
venv
**secret**
!/bin/secret-push
!/conf/mock/.secret-mock.toml
dexorder.toml
logging.toml

48
bin/config-push Executable file
View File

@@ -0,0 +1,48 @@
#!/bin/bash
if [ "$1" == "" ]; then
echo 'usage: config-push {config_name} [secret_name]'
exit 1
fi
CONFIG=$1
shift
if [ "$1" != "" ]; then
KEY=backend-$1
else
KEY=backend
fi
DEXO="conf/dexorder-$CONFIG.toml"
if [ ! -f "$DEXO" ]; then
DEXO="conf/$CONFIG/dexorder-$CONFIG.toml"
fi
if [ ! -f "$DEXO" ]; then
DEXO=
else
DEXO="--from-file dexorder.toml=$DEXO"
fi
LOG="conf/logging-$CONFIG.toml"
if [ ! -f "$LOG" ]; then
LOG="conf/$CONFIG/logging-$CONFIG.toml"
fi
if [ ! -f "$LOG" ]; then
LOG=
else
LOG="--from-file logging.toml=$LOG"
fi
META="conf/metadata-$CONFIG.json"
if [ ! -f "$META" ]; then
META="conf/$CONFIG/metadata-$CONFIG.json"
fi
if [ ! -f "$META" ]; then
META=
else
META="--from-file metadata.json=$META"
fi
# shellcheck disable=SC2086
kubectl create configmap "$KEY" $DEXO $LOG $META --dry-run=client -o yaml | kubectl apply -f -

27
bin/secret-push Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
if [ "$1" == "" ]; then
echo 'usage: secret-push {config_name} [secret_name]'
exit 1
fi
CONFIG=$1
shift
if [ "$1" != "" ]; then
KEY=backend-$1
else
KEY=backend
fi
FILE="conf/dexorder-$CONFIG.toml"
if [ ! -f "$FILE" ]; then
FILE="conf/$CONFIG/dexorder-$CONFIG.toml"
fi
if [ ! -f "$FILE" ]; then
echo Could not find config file for $1
exit 1;
fi
kubectl create secret generic "$KEY" --from-file ".secret.toml=$FILE" --dry-run=client -o yaml | kubectl apply -f -

View File

@@ -0,0 +1,6 @@
metadata='metadata.json' # mounted from a ConfigMap in the k8s yaml
rpc_url = '${rpc_urls.finaldata}'
account = ''
ws_url = ''
redis_url = ''
ohlc_dir = '/ohlc'

View File

@@ -0,0 +1,20 @@
# https://docs.python.org/3/library/logging.config.html#logging-config-dictschema
version=1
[loggers.'']
level='INFO'
handlers=['console',]
[loggers.dexorder]
level='DEBUG'
[handlers.console]
class='logging.StreamHandler'
formatter='notime'
stream='ext://sys.stdout'
[formatters.notime]
# https://docs.python.org/3/library/logging.html#logrecord-attributes
format='%(levelname)s %(name)s %(message)s'
# https://docs.python.org/3/library/time.html#time.strftime
datefmt='%Y-%m-%d %H:%M:%S'

View File

@@ -0,0 +1,28 @@
{
"42161": {
"t": [
{
"a": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"n": "Wrapped Ether",
"s": "WETH",
"d": 18
},
{
"a": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"n": "USD Coin (Arbitrum Native)",
"s": "USDC",
"d": 6
}
],
"p": [
{
"a": "0xC6962004f452bE9203591991D15f6b388e09E8D0",
"b": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"q": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"f": 500,
"e": 1,
"d": 12
}
]
}
}