Services
Accessor: client.Services()
Expose, inspect, and manage network services attached to sandboxes. Services provide external access to ports running inside a sandbox via managed endpoints.
Expose
Section titled “Expose”Expose a port from a sandbox as a named service endpoint. Set domain to true
to assign a DNS-routable domain name to the service.
endpoint, err := client.Services().Expose(ctx, "default", "my-sandbox", "web", 8080, true)if err != nil { log.Fatal(err)}fmt.Printf("Service available at: %s\n", endpoint.URL)List returns a lazy pager over exposed services. Use ListAll to collect
every page.
services, err := client.Services().ListAll(ctx, "default", "my-sandbox")if err != nil { log.Fatal(err)}for _, svc := range services { fmt.Printf(" %s -> port %d (%s)\n", svc.Name, svc.TargetPort, svc.URL)}
// Platform Admin only: list services across all workspacesallServices, err := client.Services().ListAll(ctx, "", "", v1.ListOptions{ AllWorkspaces: true,})Delete
Section titled “Delete”Remove an exposed service. The underlying sandbox port remains accessible internally but is no longer reachable through the service endpoint.
deletion, err := client.Services().Delete(ctx, "default", "my-sandbox", "web")if err != nil { log.Fatal(err)}See also: Error Handling, Testing
We are a Cloud Native Computing Foundation sandbox project.
Copyright OpenShell a Series of LF Projects, LLC
For website terms of use, trademark policy and other project policies please see lfprojects.org/policies/.