providers/proxy: fix creation of ingress
This commit is contained in:
parent
6596bc6034
commit
05866d3544
|
@ -179,13 +179,13 @@ stages:
|
||||||
- task: CmdLine@2
|
- task: CmdLine@2
|
||||||
inputs:
|
inputs:
|
||||||
script: |
|
script: |
|
||||||
export PB_TEST_K8S=true
|
|
||||||
sudo pip install -U wheel pipenv
|
sudo pip install -U wheel pipenv
|
||||||
pipenv install --dev
|
pipenv install --dev
|
||||||
- task: CmdLine@2
|
- task: CmdLine@2
|
||||||
displayName: Run full test suite
|
displayName: Run full test suite
|
||||||
inputs:
|
inputs:
|
||||||
script: |
|
script: |
|
||||||
|
export PB_TEST_K8S=true
|
||||||
pipenv run coverage run ./manage.py test passbook -v 3
|
pipenv run coverage run ./manage.py test passbook -v 3
|
||||||
- task: CmdLine@2
|
- task: CmdLine@2
|
||||||
inputs:
|
inputs:
|
||||||
|
@ -221,7 +221,6 @@ stages:
|
||||||
- task: CmdLine@2
|
- task: CmdLine@2
|
||||||
inputs:
|
inputs:
|
||||||
script: |
|
script: |
|
||||||
export PB_TEST_K8S=true
|
|
||||||
sudo pip install -U wheel pipenv
|
sudo pip install -U wheel pipenv
|
||||||
pipenv install --dev
|
pipenv install --dev
|
||||||
- task: DockerCompose@0
|
- task: DockerCompose@0
|
||||||
|
@ -241,6 +240,7 @@ stages:
|
||||||
displayName: Run full test suite
|
displayName: Run full test suite
|
||||||
inputs:
|
inputs:
|
||||||
script: |
|
script: |
|
||||||
|
export PB_TEST_K8S=true
|
||||||
pipenv run coverage run ./manage.py test e2e -v 3 --failfast
|
pipenv run coverage run ./manage.py test e2e -v 3 --failfast
|
||||||
- task: CmdLine@2
|
- task: CmdLine@2
|
||||||
condition: always()
|
condition: always()
|
||||||
|
|
|
@ -69,7 +69,7 @@ class DeploymentReconciler(KubernetesObjectReconciler[V1Deployment]):
|
||||||
spec=V1PodSpec(
|
spec=V1PodSpec(
|
||||||
containers=[
|
containers=[
|
||||||
V1Container(
|
V1Container(
|
||||||
name=self.outpost.type,
|
name=str(self.outpost.type),
|
||||||
image=f"{self.image_base}-{self.outpost.type}:{__version__}",
|
image=f"{self.image_base}-{self.outpost.type}:{__version__}",
|
||||||
ports=container_ports,
|
ports=container_ports,
|
||||||
env=[
|
env=[
|
||||||
|
|
|
@ -56,7 +56,6 @@ class KubernetesController(BaseController):
|
||||||
documents = []
|
documents = []
|
||||||
for reconcile_key in self.reconcile_order:
|
for reconcile_key in self.reconcile_order:
|
||||||
reconciler = self.reconcilers[reconcile_key](self)
|
reconciler = self.reconcilers[reconcile_key](self)
|
||||||
reconciler.up()
|
|
||||||
documents.append(reconciler.get_reference_object().to_dict())
|
documents.append(reconciler.get_reference_object().to_dict())
|
||||||
|
|
||||||
with StringIO() as _str:
|
with StringIO() as _str:
|
||||||
|
|
|
@ -56,7 +56,10 @@ class IngressReconciler(KubernetesObjectReconciler[NetworkingV1beta1Ingress]):
|
||||||
have_hosts = [rule.host for rule in reference.spec.rules]
|
have_hosts = [rule.host for rule in reference.spec.rules]
|
||||||
have_hosts.sort()
|
have_hosts.sort()
|
||||||
|
|
||||||
have_hosts_tls = reference.spec.tls.hosts
|
have_hosts_tls = []
|
||||||
|
for tls_config in reference.spec.tls:
|
||||||
|
if tls_config:
|
||||||
|
have_hosts_tls += tls_config.hosts
|
||||||
have_hosts_tls.sort()
|
have_hosts_tls.sort()
|
||||||
|
|
||||||
if have_hosts != expected_hosts:
|
if have_hosts != expected_hosts:
|
||||||
|
@ -102,7 +105,7 @@ class IngressReconciler(KubernetesObjectReconciler[NetworkingV1beta1Ingress]):
|
||||||
)
|
)
|
||||||
return NetworkingV1beta1Ingress(
|
return NetworkingV1beta1Ingress(
|
||||||
metadata=meta,
|
metadata=meta,
|
||||||
spec=NetworkingV1beta1IngressSpec(rules=rules, tls=tls_config),
|
spec=NetworkingV1beta1IngressSpec(rules=rules, tls=[tls_config]),
|
||||||
)
|
)
|
||||||
|
|
||||||
def create(self, reference: NetworkingV1beta1Ingress):
|
def create(self, reference: NetworkingV1beta1Ingress):
|
||||||
|
|
|
@ -31,9 +31,9 @@ class TestControllers(TestCase):
|
||||||
outpost.providers.add(provider)
|
outpost.providers.add(provider)
|
||||||
outpost.save()
|
outpost.save()
|
||||||
|
|
||||||
controller = ProxyKubernetesController(outpost.pk)
|
controller = ProxyKubernetesController(outpost)
|
||||||
manifest = controller.get_static_deployment()
|
manifest = controller.get_static_deployment()
|
||||||
self.assertEqual(len(list(yaml.load_all(manifest, Loader=yaml.SafeLoader))), 3)
|
self.assertEqual(len(list(yaml.load_all(manifest, Loader=yaml.SafeLoader))), 4)
|
||||||
|
|
||||||
def test_kubernetes_controller_deploy(self):
|
def test_kubernetes_controller_deploy(self):
|
||||||
"""Test Kubernetes Controller"""
|
"""Test Kubernetes Controller"""
|
||||||
|
@ -51,5 +51,6 @@ class TestControllers(TestCase):
|
||||||
outpost.providers.add(provider)
|
outpost.providers.add(provider)
|
||||||
outpost.save()
|
outpost.save()
|
||||||
|
|
||||||
controller = ProxyKubernetesController(outpost.pk)
|
controller = ProxyKubernetesController(outpost)
|
||||||
controller.up()
|
controller.up()
|
||||||
|
controller.down()
|
||||||
|
|
Reference in a new issue