Class NamespaceCloud

All Implemented Interfaces:
ExtensionPoint, Describable<Cloud>, ModelObject, SearchableModelObject, SearchItem, AccessControlled, ModelObjectWithContextMenu

public class NamespaceCloud extends Cloud
A Jenkins cloud that provisions agents as Namespace instances.

Configured once globally (endpoint, token, profiles); jobs then select a profile by label and Jenkins asks this cloud to provision when the queue cannot be served by existing nodes.

  • Field Details

    • LABEL_MANAGED_BY

      public static final String LABEL_MANAGED_BY
      Instance labels, used to reap instances orphaned by a controller restart.

      Namespace documents label names as matching ^[a-z]([a-z0-9-.]*[a-z0-9])?$ and at most 63 bytes. A Kubernetes-style jenkins.io/agent is therefore rejected: the slash is not in that character class, and CreateInstance fails with INVALID_ARGUMENT.

      See Also:
    • LABEL_CLOUD

      public static final String LABEL_CLOUD
      See Also:
    • LABEL_AGENT

      public static final String LABEL_AGENT
      See Also:
    • MANAGED_BY_VALUE

      public static final String MANAGED_BY_VALUE
      See Also:
  • Constructor Details

    • NamespaceCloud

      @DataBoundConstructor public NamespaceCloud(@NonNull String name)
  • Method Details

    • getDisplayName

      @NonNull public String getDisplayName()
      The label shown in the UI, which is safe to change at any time.

      Cloud.name deliberately is not editable on the configuration page. Jenkins asks for it when the cloud is created and rejects a duplicate there, but nothing stops a later edit from colliding with another cloud, and duplicate cloud names cause trouble inside Jenkins. Renaming is therefore done here instead, leaving the identity alone.

      Falls back to the name so the UI never shows a blank cloud.

      Specified by:
      getDisplayName in interface ModelObject
      Overrides:
      getDisplayName in class Cloud
    • setDisplayName

      @DataBoundSetter public void setDisplayName(String displayName)
    • getCredentialsId

      public String getCredentialsId()
    • setCredentialsId

      @DataBoundSetter public void setCredentialsId(String credentialsId)
    • getRegion

      public String getRegion()
    • setRegion

      @DataBoundSetter public void setRegion(String region)
    • getComputeEndpointOverride

      public String getComputeEndpointOverride()
    • setComputeEndpointOverride

      @DataBoundSetter public void setComputeEndpointOverride(String computeEndpointOverride)
    • getInstanceRegion

      public String getInstanceRegion()
      The site to place the instance in, e.g. ord.

      Distinct from getRegion(), which only selects which API host to talk to. Blank is the sensible default: Namespace then picks any site with capacity for the requested shape. Setting this to an endpoint prefix such as "us" matches no site and the API rejects the request with no available region to start a linux/amd64 instance.

    • setInstanceRegion

      @DataBoundSetter public void setInstanceRegion(String instanceRegion)
    • getRegistryPrefix

      public String getRegistryPrefix()
      The workspace segment in nscr.io image references, e.g. abc012abc012 in nscr.io/abc012abc012/jenkins-agent:1.0.

      It has to be configured: the registry API reports bare repository names and the tenant is implicit in the token, and no RPC available to a least-privileged token reveals the tenant id. Without it, suggested image references are missing the segment and Namespace answers failed to resolve image.

    • setRegistryPrefix

      @DataBoundSetter public void setRegistryPrefix(String registryPrefix)
    • getComputeEndpoint

      public String getComputeEndpoint()
      ComputeService is regional; the override exists for non-standard deployments.
    • getJenkinsUrlOverride

      public String getJenkinsUrlOverride()
    • setJenkinsUrlOverride

      @DataBoundSetter public void setJenkinsUrlOverride(String jenkinsUrlOverride)
    • getInstanceCap

      public int getInstanceCap()
    • setInstanceCap

      @DataBoundSetter public void setInstanceCap(int instanceCap)
    • getTemplates

      @NonNull public List<AgentTemplate> getTemplates()
    • setTemplates

      @DataBoundSetter public void setTemplates(List<AgentTemplate> templates)
    • client

      @NonNull public NamespaceClient client() throws IOException
      Returns a client for the configured endpoint and token, rebuilding it if either changed since last time.
      Throws:
      IOException
    • resolveToken

      @CheckForNull public static Secret resolveToken(@CheckForNull String credentialsId)
      Public so the launch strategies can resolve the same credential for their own lookups.
    • destroyInstance

      public void destroyInstance(@NonNull String instanceId, @NonNull String reason)
    • templateFor

      @CheckForNull public AgentTemplate templateFor(@CheckForNull Label label)
    • canProvision

      public boolean canProvision(Cloud.CloudState state)
      Overrides:
      canProvision in class Cloud
    • provision

      public Collection<NodeProvisioner.PlannedNode> provision(Cloud.CloudState state, int excessWorkload)
      Overrides:
      provision in class Cloud
    • effectiveJenkinsUrl

      public String effectiveJenkinsUrl() throws IOException
      The URL the agent will dial back to.
      Throws:
      IOException