@@ -596,9 +596,12 @@ def _namespace_default(self):
596
596
'singleuser-server' ,
597
597
config = True ,
598
598
help = """
599
- The component label used to tag the user pods. This can be used to override
600
- the spawner behavior when dealing with multiple hub instances in the same
601
- namespace. Usually helpful for CI workflows.
599
+ The value of the labels app.kubernetes.io/component and component, used
600
+ to identify user pods kubespawner is to manage.
601
+
602
+ This can be used to override the spawner behavior when dealing with
603
+ multiple hub instances in the same namespace. Usually helpful for CI
604
+ workflows.
602
605
""" ,
603
606
)
604
607
@@ -655,6 +658,10 @@ def _deprecated_changed(self, change):
655
658
656
659
common_labels = Dict (
657
660
{
661
+ 'app.kubernetes.io/name' : 'jupyterhub' ,
662
+ 'app.kubernetes.io/managed-by' : 'kubespawner' ,
663
+ # app and heritage are older variants of the modern
664
+ # app.kubernetes.io labels
658
665
'app' : 'jupyterhub' ,
659
666
'heritage' : 'jupyterhub' ,
660
667
},
@@ -1878,6 +1885,7 @@ def _build_pod_labels(self, extra_labels):
1878
1885
labels = self ._build_common_labels (extra_labels )
1879
1886
labels .update (
1880
1887
{
1888
+ 'app.kubernetes.io/component' : self .component_label ,
1881
1889
'component' : self .component_label ,
1882
1890
'hub.jupyter.org/servername' : escapism .escape (
1883
1891
self .name , safe = self .safe_chars , escape_char = '-'
@@ -2102,7 +2110,17 @@ def get_pvc_manifest(self):
2102
2110
Make a pvc manifest that will spawn current user's pvc.
2103
2111
"""
2104
2112
labels = self ._build_common_labels (self ._expand_all (self .storage_extra_labels ))
2105
- labels .update ({'component' : 'singleuser-storage' })
2113
+ labels .update (
2114
+ {
2115
+ # The component label has been set to singleuser-storage, but should
2116
+ # probably have been set to singleuser-server (self.component_label)
2117
+ # as that ties it to the user pods kubespawner creates. Due to that,
2118
+ # the newly introduced label app.kubernetes.io/component gets
2119
+ # singleuser-server (self.component_label) as a value instead.
2120
+ 'app.kubernetes.io/component' : self .component_label ,
2121
+ 'component' : 'singleuser-storage' ,
2122
+ }
2123
+ )
2106
2124
2107
2125
annotations = self ._build_common_annotations (
2108
2126
self ._expand_all (self .storage_extra_annotations )
@@ -2473,6 +2491,14 @@ async def _start_watching_pods(self, replace=False):
2473
2491
return await self ._start_reflector (
2474
2492
kind = "pods" ,
2475
2493
reflector_class = PodReflector ,
2494
+ # NOTE: We monitor pods with the old component label instead of the
2495
+ # modern app.kubernetes.io/component label. A change here is
2496
+ # only non-breaking if we can assume the running pods we want
2497
+ # to monitor can be detected by either the old or modern
2498
+ # label.
2499
+ #
2500
+ # Related to https://github.com/jupyterhub/kubespawner/issues/834
2501
+ #
2476
2502
labels = {"component" : self .component_label },
2477
2503
omit_namespace = self .enable_user_namespaces ,
2478
2504
replace = replace ,
0 commit comments