1
0
Fork 0

Fix SSL on Kubernetes

This commit is contained in:
Joao Gilberto Magalhaes 2022-08-26 11:38:02 -05:00
parent 0d16c117cb
commit 68eea939a3
8 changed files with 194 additions and 57 deletions

View file

@ -0,0 +1,2 @@
{"10.152.183.62": {"creation_timestamp": "08/24/22 02:59:44", "resource_version": "72517156", "namespace": "parking", "easyhaproxy.valida-me_8080.host": "valida.me", "easyhaproxy.valida-me_8080.port": "80", "easyhaproxy.valida-me_8080.localport": 8080, "easyhaproxy.valida-me_8080.redirect": "{\"www.valida.me\": \"https://valida.me\"}", "easyhaproxy.www-valida-me_8080.host": "www.valida.me", "easyhaproxy.www-valida-me_8080.port": "80", "easyhaproxy.www-valida-me_8080.localport": 8080, "easyhaproxy.www-valida-me_8080.redirect": "{\"www.valida.me\": \"https://valida.me\"}"},
"10.152.183.215": {"creation_timestamp": "08/26/22 03:06:01", "resource_version": "72522999", "namespace": "default", "easyhaproxy.host2-local_8080.host": "host2.local", "easyhaproxy.host2-local_8080.port": "80", "easyhaproxy.host2-local_8080.localport": 8080, "easyhaproxy.host2-local_8080.clone_to_ssl": "true"}}

View file

@ -23,7 +23,7 @@ def test_container_env_customerrors():
os.environ['HAPROXY_CUSTOMERRORS'] = ''
def test_container_env_sslmode():
os.environ['EASYHAPROXY_SSL_MODE'] = 'strict'
os.environ['EASYHAPROXY_SSL_MODE'] = 'STRICT'
try:
assert {
"customerrors": False,

View file

@ -423,6 +423,83 @@ def test_parser_ssl_letsencrypt():
assert expected_file.read() == haproxy_config
assert ["test.example.org"] == cfg.letsencrypt_hosts
def test_parser_finds_services_clone_to_ssl_raw():
line_list = load_fixture("services-clone-to-ssl")
result = {
"customerrors": False,
"letsencrypt": {
"email": LETSENCRYPT_EMAIL
},
"stats": {
"port": 0
}
}
if os.path.exists(CERT_FILE):
os.remove(CERT_FILE)
cfg = easymapping.HaproxyConfigGenerator(result)
parsed_object = [
{
"health-check":"",
"hosts":{
"host2.local":{
"containers":[
"10.152.183.215:8080"
],
"letsencrypt": False,
"redirect_ssl": False
},
"valida.me":{
"containers":[
"10.152.183.62:8080"
],
"letsencrypt": False,
"redirect_ssl": False
},
"www.valida.me":{
"containers":[
"10.152.183.62:8080"
],
"letsencrypt": False,
"redirect_ssl": False
}
},
"mode":"http",
"port":"80",
"redirect":{
}
},
{
"health-check":"ssl",
"hosts":{
"host2.local":{
"containers":[
"10.152.183.215:8080"
],
"letsencrypt": False,
"redirect_ssl": False
}
},
"mode":"http",
"port":"443",
"redirect":{
},
"ssl": True
}
]
processed = list(cfg.parse(line_list))
assert parsed_object == processed
assert [] == cfg.letsencrypt_hosts
#test_parser_finds_services_raw()
#test_parser_tcp()
#test_parser_multiple_hosts()