Remove obsolete files
This commit is contained in:
parent
3a0b33041c
commit
d8f1931f19
6 changed files with 0 additions and 230 deletions
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
function log() {
|
|
||||||
# ARGS:
|
|
||||||
# - loglevel
|
|
||||||
# - app
|
|
||||||
# - message
|
|
||||||
echo [$2] $(date +"$EASYHAPROXY_DATEFORMAT") [$1]: $3
|
|
||||||
}
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
source /scripts/functions.sh
|
|
||||||
|
|
||||||
cd /scripts
|
|
||||||
|
|
||||||
RELOAD="true"
|
|
||||||
|
|
||||||
if [[ "$EASYHAPROXY_DISCOVER" == "static" ]]; then
|
|
||||||
CONTROL_FILE="/etc/haproxy/haproxy.cfg"
|
|
||||||
touch ${CONTROL_FILE}
|
|
||||||
cp ${CONTROL_FILE} ${CONTROL_FILE}.old
|
|
||||||
python3 static.py /etc/haproxy/easyconfig.yml > ${CONTROL_FILE}
|
|
||||||
else
|
|
||||||
CONTROL_FILE="/tmp/.docker_data"
|
|
||||||
touch ${CONTROL_FILE}
|
|
||||||
mv ${CONTROL_FILE} ${CONTROL_FILE}.old
|
|
||||||
touch ${CONTROL_FILE}
|
|
||||||
|
|
||||||
case "$EASYHAPROXY_DISCOVER" in
|
|
||||||
docker)
|
|
||||||
CONTAINERS=$(docker ps -q | sort | uniq)
|
|
||||||
LABEL_PATH=".Config.Labels"
|
|
||||||
|
|
||||||
for container in ${CONTAINERS}; do
|
|
||||||
docker inspect --format "{{ json $LABEL_PATH }}" ${container} | xargs -I % echo ${container}=% >> ${CONTROL_FILE}
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
|
|
||||||
swarm)
|
|
||||||
CONTAINERS=$(docker node ps $(docker node ls -q) --format "{{ .Name }}" --filter desired-state=running | cut -d. -f1 | sort | uniq)
|
|
||||||
LABEL_PATH=".Spec.Labels"
|
|
||||||
|
|
||||||
for container in ${CONTAINERS}; do
|
|
||||||
docker service inspect --format "{{ json $LABEL_PATH }}" ${container} | xargs -I % echo ${container}=% >> ${CONTROL_FILE}
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
|
|
||||||
kubernetes)
|
|
||||||
python3 /scripts/k8s.py > ${CONTROL_FILE}
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
log "error" "CONF_CHECK" "EASYHAPROXY_DISCOVER should be 'static', 'docker', 'swarm' or kubernetes. I got '$EASYHAPROXY_DISCOVER' instead."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if cmp -s ${CONTROL_FILE} ${CONTROL_FILE}.old ; then
|
|
||||||
RELOAD="false"
|
|
||||||
else
|
|
||||||
python3 swarm.py > /etc/haproxy/haproxy.cfg
|
|
||||||
log "info" "CONF_CHECK" "New configuration found"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if cmp -s ${CONTROL_FILE} ${CONTROL_FILE}.old ; then
|
|
||||||
RELOAD="false"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -z "$1" ]]; then
|
|
||||||
log "info" "CONF_CHECK" "Initial configuration. Skip certbot."
|
|
||||||
else
|
|
||||||
/scripts/certbot.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If Certbot reloads successfully will create the file /tmp/force-reload
|
|
||||||
if [ -f /tmp/force-reload ]; then
|
|
||||||
log "info" "CONF_CHECK" "New certificates found..."
|
|
||||||
RELOAD="true"
|
|
||||||
rm /tmp/force-reload
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -z "$1" ]]; then
|
|
||||||
log "info" "CONF_CHECK" "Starting haproxy..."
|
|
||||||
/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg $(ls /etc/haproxy/conf.d/*.cfg 2>/dev/null | xargs -I{} echo -f {}) -p /run/haproxy.pid -S /var/run/haproxy.sock &
|
|
||||||
|
|
||||||
elif [[ "$RELOAD" == "true" ]]; then
|
|
||||||
log "info" "CONF_CHECK" "Reloading..."
|
|
||||||
/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg $(ls /etc/haproxy/conf.d/*.cfg 2>/dev/null | xargs -I{} echo -f {}) -p /run/haproxy.pid -x /var/run/haproxy.sock -sf $(cat /run/haproxy.pid) &
|
|
||||||
fi
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
source /scripts/functions.sh
|
|
||||||
|
|
||||||
/usr/sbin/haproxy -v
|
|
||||||
|
|
||||||
if [ -z "$EASYHAPROXY_DATEFORMAT" ]; then
|
|
||||||
export EASYHAPROXY_DATEFORMAT="%Y-%m-%d %H:%M:%S %Z"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$EASYHAPROXY_REFRESH_CONF" ]; then
|
|
||||||
export EASYHAPROXY_REFRESH_CONF=10
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
cat banner.txt
|
|
||||||
echo Release: $RELEASE_VERSION
|
|
||||||
echo
|
|
||||||
echo "Environment"
|
|
||||||
env | sort | grep 'HAPROXY' | xargs -I{} echo " - {} "
|
|
||||||
echo
|
|
||||||
|
|
||||||
/scripts/haproxy-reload.sh initial
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
sleep $EASYHAPROXY_REFRESH_CONF
|
|
||||||
log "info" "CONF_CHECK" "Heartbeat."
|
|
||||||
/scripts/haproxy-reload.sh
|
|
||||||
done
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
from kubernetes import client, config
|
|
||||||
from kubernetes.client.rest import ApiException
|
|
||||||
import json
|
|
||||||
|
|
||||||
# https://github.com/kubernetes-client/python/tree/master/kubernetes/docs
|
|
||||||
|
|
||||||
|
|
||||||
# Fix error:
|
|
||||||
# raise MaxRetryError(_pool, url, error or ResponseError(cause))
|
|
||||||
# urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='10.152.183.1', port=443): Max retries exceeded with url: /api/v1/namespaces/parking/services/parking-valida-me (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))
|
|
||||||
|
|
||||||
def main():
|
|
||||||
config.load_incluster_config()
|
|
||||||
|
|
||||||
api_instance = client.CoreV1Api()
|
|
||||||
v1 = client.NetworkingV1Api()
|
|
||||||
|
|
||||||
ret = v1.list_ingress_for_all_namespaces(watch=False)
|
|
||||||
|
|
||||||
discover = {}
|
|
||||||
for i in ret.items:
|
|
||||||
if i.metadata.annotations['kubernetes.io/ingress.class'] != "easyhaproxy-ingress":
|
|
||||||
continue
|
|
||||||
|
|
||||||
data = {}
|
|
||||||
#ingress_name = i.metadata.name
|
|
||||||
data["creation_timestamp"] = i.metadata.creation_timestamp.strftime("%x %X")
|
|
||||||
data["resource_version"] = i.metadata.resource_version
|
|
||||||
data["namespace"] = i.metadata.namespace
|
|
||||||
for rule in i.spec.rules:
|
|
||||||
rule_data = {}
|
|
||||||
port_number = rule.http.paths[0].backend.service.port.number
|
|
||||||
definition = rule.host.replace(".", "-")
|
|
||||||
rule_data["easyhaproxy.%s_%s.host" % (definition, port_number)] = rule.host
|
|
||||||
rule_data["easyhaproxy.%s_%s.port" % (definition, port_number)] = "80"
|
|
||||||
rule_data["easyhaproxy.%s_%s.localport" % (definition, port_number)] = port_number
|
|
||||||
service_name = rule.http.paths[0].backend.service.name
|
|
||||||
try:
|
|
||||||
api_response = api_instance.read_namespaced_service(service_name, i.metadata.namespace)
|
|
||||||
cluster_ip = api_response.spec.cluster_ip
|
|
||||||
except ApiException as e:
|
|
||||||
cluster_ip = None
|
|
||||||
# print("Exception when calling CoreV1Api->read_namespaced_service: %s\n" % e)
|
|
||||||
|
|
||||||
if cluster_ip is not None:
|
|
||||||
if cluster_ip not in discover.keys():
|
|
||||||
discover[cluster_ip] = data
|
|
||||||
discover[cluster_ip].update(rule_data)
|
|
||||||
|
|
||||||
for k in discover.keys():
|
|
||||||
print("%s=%s" % (k, json.dumps(discover[k])))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
import yaml
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from easymapping import HaproxyConfigGenerator
|
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
|
||||||
print("You need to pass the easyconfig.yml path")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as content_file:
|
|
||||||
parsed = yaml.load(content_file.read(), Loader=yaml.FullLoader)
|
|
||||||
|
|
||||||
cfg = HaproxyConfigGenerator(parsed)
|
|
||||||
print(cfg.generate())
|
|
||||||
|
|
||||||
path = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
with open(path + "/letsencrypt_hosts.txt", 'w') as fp:
|
|
||||||
fp.write('\n'.join(cfg.letsencrypt_hosts))
|
|
||||||
|
|
||||||
exit(0)
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import os
|
|
||||||
from easymapping import HaproxyConfigGenerator
|
|
||||||
|
|
||||||
with open("/tmp/.docker_data", 'r') as content_file:
|
|
||||||
line_list = content_file.readlines()
|
|
||||||
|
|
||||||
result = {
|
|
||||||
"customerrors": True if os.getenv("HAPROXY_CUSTOMERRORS") == "true" else False,
|
|
||||||
"ssl_mode": os.getenv("EASYHAPROXY_SSL_MODE", "default")
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.getenv("HAPROXY_PASSWORD"):
|
|
||||||
result["stats"] = {
|
|
||||||
"username": os.getenv("HAPROXY_USERNAME") if os.getenv("HAPROXY_USERNAME") else "admin",
|
|
||||||
"password": os.getenv("HAPROXY_PASSWORD"),
|
|
||||||
"port": os.getenv("HAPROXY_STATS_PORT") if os.getenv("HAPROXY_STATS_PORT") else "1936",
|
|
||||||
}
|
|
||||||
|
|
||||||
result["lookup_label"] = os.getenv("EASYHAPROXY_LABEL_PREFIX") if os.getenv("EASYHAPROXY_LABEL_PREFIX") else "easyhaproxy"
|
|
||||||
if (os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL")):
|
|
||||||
result["letsencrypt"] = {
|
|
||||||
"email": os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cfg = HaproxyConfigGenerator(result)
|
|
||||||
print(cfg.generate(line_list))
|
|
||||||
|
|
||||||
path = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
with open(path + "/letsencrypt_hosts.txt", 'w') as fp:
|
|
||||||
fp.write('\n'.join(cfg.letsencrypt_hosts))
|
|
||||||
# print(jsonStr)
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue