Change JupyterHub user pod name

I’m deploying JupyterHub on Kubernetes. Authentication is integrated with Azure AD, and users log in using their email address (AAA@xxx.com) and password. I want each user pod to be named jupyter-AAA (i.e., drop everything after @). How should I write this in values.yaml?
I’ve already set hub.config.AzureAdOAuthenticator.username_claim: “upn”, but I think I still need to add something in hub.extraConfig.

You can subclass the authenticator and override normalize_username, something like

hub:
  extraConfig:
    authenticator-custom-config: |
      from oauthenticator.xxx import XxxAuthenticator

      class CustomAuthenticator(XxxAuthenticator):
          def normalize_username(self, username):
              modified_username = ...
              return modified_username

      c.JupyterHub.authenticator_class = CustomAuthenticator
2 Likes

Thank you for your reply!
I configured it as shown below, but when I log in using Azure AD credentials, the user pod name becomes the email address, and it looks like the extraConfig setting isn’t taking effect.


extraConfig:
  authenticator-custom-config: |
    from oauthenticator.azuread import AzureAdOAuthenticator
    class CustomAuthenticator(AzureAdOAuthenticator):
        def normalize_username(self, username):
            modified_username = username.split('@')[0]
            return modified_username
    c.JupyterHub.authenticator_class = CustomAuthenticator