Skip to content

Commit

Permalink
Merge pull request #668 from dolfinus/ingress_class_name
Browse files Browse the repository at this point in the history
[KubeIngressProxy] Add KubeIngressProxy.ingress_class_name
  • Loading branch information
consideRatio authored Nov 8, 2022
2 parents 49f4109 + 9027036 commit 4960fcf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion kubespawner/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ def make_ingress(
common_labels: Optional[dict] = None,
ingress_extra_labels: Optional[dict] = None,
ingress_extra_annotations: Optional[dict] = None,
ingress_class_name: Optional[str] = None,
):
"""
Returns an ingress, service, endpoint object that'll work for this service
Expand Down Expand Up @@ -833,6 +834,7 @@ def make_ingress(
kind='Ingress',
metadata=ingress_meta,
spec=V1IngressSpec(
ingress_class_name=ingress_class_name,
rules=[
V1IngressRule(
host=host,
Expand All @@ -853,7 +855,7 @@ def make_ingress(
]
),
)
]
],
),
)

Expand Down
8 changes: 8 additions & 0 deletions kubespawner/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ def _namespace_default(self):
""",
)

ingress_class_name = Unicode(
config=True,
help="""
Default value for 'ingressClassName' field in Ingress specification
""",
)

k8s_api_ssl_ca_cert = Unicode(
"",
config=True,
Expand Down Expand Up @@ -375,6 +382,7 @@ async def add_route(self, routespec, target, data):
common_labels=common_labels,
ingress_extra_labels=ingress_extra_labels,
ingress_extra_annotations=ingress_extra_annotations,
ingress_class_name=self.ingress_class_name,
)

async def ensure_object(create_func, patch_func, body, kind):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,7 @@ def test_make_ingress(target, ip):
common_labels=common_labels,
ingress_extra_labels=ingress_extra_labels,
ingress_extra_annotations=ingress_extra_annotations,
ingress_class_name='nginx',
)
)

Expand Down Expand Up @@ -2067,6 +2068,7 @@ def test_make_ingress(target, ip):
'name': 'jupyter-test',
},
'spec': {
'ingressClassName': 'nginx',
'rules': [
{
'http': {
Expand All @@ -2086,7 +2088,7 @@ def test_make_ingress(target, ip):
]
}
}
]
],
},
}

Expand Down

0 comments on commit 4960fcf

Please sign in to comment.