def create(self): aws.create_user_role(self.user) self._init_user() helm.upgrade_release( f"config-user-{self.user.slug}", # release f"{settings.HELM_REPO}/config-user", # chart f"--namespace={self.k8s_namespace}", f"--set=Username={self.user.slug}", )
def reset_home(self): """ Reset the user's home directory. """ if settings.EKS: # On the new EKS infrastructure, the user's home directory[s] is # organised differently and on EFS. This is why we use a separate # helm chart. helm.upgrade_release( f"reset-user-efs-home-{self.user.slug}", # release f"{settings.HELM_REPO}/reset-user-efs-home", # chart f"--namespace=user-{self.user.slug}", f"--set=Username={self.user.slug}", ) else: helm.upgrade_release( f"reset-user-home-{self.user.slug}", # release f"{settings.HELM_REPO}/reset-user-home", # chart f"--namespace=user-{self.user.slug}", f"--set=Username={self.user.slug}", )
def _init_user(self): if settings.EKS: helm.upgrade_release( f"bootstrap-user-{self.user.slug}", # release f"{settings.HELM_REPO}/bootstrap-user", # chart f"--set=" + (f"Username={self.user.slug}"), ) helm.upgrade_release( f"provision-user-{self.user.slug}", # release f"{settings.HELM_REPO}/provision-user", # chart f"--namespace={self.k8s_namespace}", f"--set=" + (f"Username={self.user.slug}," f"Efsvolume={settings.EFS_VOLUME}," f"OidcDomain={settings.OIDC_DOMAIN}," f"Email={self.user.email}," f"Fullname={self.user.name},"), ) else: helm.upgrade_release( f"init-user-{self.user.slug}", # release f"{settings.HELM_REPO}/init-user", # chart f"--set=" + (f"Env={settings.ENV}," f"NFSHostname={settings.NFS_HOSTNAME}," f"EFSHostname={settings.EFS_HOSTNAME}," f"OidcDomain={settings.OIDC_DOMAIN}," f"Email={self.user.email}," f"Fullname={self.user.name}," f"Username={self.user.slug}"), )
def test_helm_upgrade_release(): mock_execute = MagicMock() mock_update = MagicMock() with patch("controlpanel.api.helm._execute", mock_execute), patch( "controlpanel.api.helm.update_helm_repository", mock_update): upgrade_args = ( "release-name", "helm-chart-name", "--namespace=user-alice", "--set=username=alice", ) helm.upgrade_release(*upgrade_args) mock_update.assert_called_once_with() mock_execute.assert_called_with( "upgrade", "--install", "--wait", "--force", *upgrade_args, )
def install(self, **kwargs): self._delete_legacy_release() try: set_values = self._set_values(**kwargs) return helm.upgrade_release( self.release_name, # release # XXX assumes repo name f"{settings.HELM_REPO}/{self.chart_name}", # chart f"--version", self.tool.version, f"--namespace", self.k8s_namespace, *set_values, ) except helm.HelmError as error: raise ToolDeploymentError(error)