Skip to content

Commit

Permalink
Merge pull request #612 from zv0n/main
Browse files Browse the repository at this point in the history
Add user_namespace_labels and user_namespace_annotations for use with enable_user_namespaces
  • Loading branch information
consideRatio committed Jun 9, 2022
2 parents 616f72c + 5f1d5b4 commit 4c1d306
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,40 @@ async def async_method(self, *args, **kwargs):
""",
)

user_namespace_labels = Dict(
config=True,
help="""
Kubernetes labels that user namespaces will get (only if
enable_user_namespaces is True).
Note that these are only set when the namespaces are created, not
later when this setting is updated.
`{username}`, `{userid}`, `{servername}`, `{hubnamespace}`,
`{unescaped_username}`, and `{unescaped_servername}` will be expanded if
found within strings of this configuration. The username and servername
come escaped to follow the [DNS label
standard](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names).
""",
)

user_namespace_annotations = Dict(
config=True,
help="""
Kubernetes annotations that user namespaces will get (only if
enable_user_namespaces is True).
Note that these are only set when the namespaces are created, not
later when this setting is updated.
`{username}`, `{userid}`, `{servername}`, `{hubnamespace}`,
`{unescaped_username}`, and `{unescaped_servername}` will be expanded if
found within strings of this configuration. The username and servername
come escaped to follow the [DNS label
standard](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names).
""",
)

user_namespace_template = Unicode(
"{hubnamespace}-{username}",
config=True,
Expand Down Expand Up @@ -3010,7 +3044,11 @@ async def load_user_options(self):
)

async def _ensure_namespace(self):
ns = make_namespace(self.namespace)
ns = make_namespace(
self.namespace,
labels=self._expand_all(self.user_namespace_labels),
annotations=self._expand_all(self.user_namespace_annotations),
)
api = self.api
try:
await asyncio.wait_for(
Expand Down

0 comments on commit 4c1d306

Please sign in to comment.