mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-02 10:09:02 +01:00
/msp and the guide promise that without a valid lease a provider's clients fall back to Community behaviour and core monitoring keeps running. In fact the hosted gate treated them as Pulse Cloud subscribers and returned 402. A client whose container could not renew its one-day lease locked about a day after creation, licensed or not: private-address DNS, the runtime's refusal of private addresses, no NAT hairpin or a filtering firewall all do it. The control plane now marks its clients, and a marked runtime opens the workspace it was provisioned for. Capabilities still come only from a verified lease, and organization routes and further organizations stay gated, so nothing paid is granted. Pulse Cloud keeps the 402. Renewal also stops depending on the host's network. Traefik answers the portal's name on a client's isolated network, and a runtime with a configured control plane accepts that private address. Older runtimes refuse private addresses and upgrade.sh leaves them in place by default, so the name is given only to runtimes whose image declares they can use it. Checked on a lab VM with a release-tagged build and a private-address domain: a client with an expired lease renewed; one created with no licence opened and accepted an agent report.
62 lines
2.0 KiB
Go
62 lines
2.0 KiB
Go
package docker
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// TenantRuntimeRoutingContract is the canonical hosted-runtime addressing
|
|
// surface derived from a tenant ID and base domain.
|
|
type TenantRuntimeRoutingContract struct {
|
|
Host string
|
|
PublicURL string
|
|
// ProviderHosted says the runtime must carry the provider client marker.
|
|
ProviderHosted bool
|
|
}
|
|
|
|
// CanonicalTenantRuntimeRouting derives the canonical hosted route host and
|
|
// public URL. Hosted routing must stay lowercase regardless of how the tenant
|
|
// ID is cased in control-plane storage.
|
|
func CanonicalTenantRuntimeRouting(tenantID, baseDomain string) TenantRuntimeRoutingContract {
|
|
tenantID = strings.ToLower(strings.TrimSpace(tenantID))
|
|
baseDomain = strings.ToLower(strings.TrimSpace(baseDomain))
|
|
if tenantID == "" || baseDomain == "" {
|
|
return TenantRuntimeRoutingContract{}
|
|
}
|
|
host := fmt.Sprintf("%s.%s", tenantID, baseDomain)
|
|
return TenantRuntimeRoutingContract{
|
|
Host: host,
|
|
PublicURL: "https://" + host,
|
|
}
|
|
}
|
|
|
|
// TraefikLabels generates Docker labels for Traefik reverse-proxy routing.
|
|
// Each tenant gets a subdomain under the configured control-plane base domain.
|
|
func TraefikLabels(tenantID, baseDomain string, containerPort int, dockerNetwork ...string) map[string]string {
|
|
svc := "pulse-" + tenantID
|
|
routing := CanonicalTenantRuntimeRouting(tenantID, baseDomain)
|
|
|
|
labels := map[string]string{
|
|
"traefik.enable": "true",
|
|
|
|
// HTTP router
|
|
fmt.Sprintf("traefik.http.routers.%s.rule", svc): fmt.Sprintf("Host(`%s`)", routing.Host),
|
|
fmt.Sprintf("traefik.http.routers.%s.entrypoints", svc): "websecure",
|
|
fmt.Sprintf("traefik.http.routers.%s.tls.certresolver", svc): "le",
|
|
|
|
// Service
|
|
fmt.Sprintf("traefik.http.services.%s.loadbalancer.server.port", svc): fmt.Sprintf("%d", containerPort),
|
|
|
|
// Metadata
|
|
"pulse.tenant.id": tenantID,
|
|
}
|
|
for _, networkName := range dockerNetwork {
|
|
networkName = strings.TrimSpace(networkName)
|
|
if networkName != "" {
|
|
labels["traefik.docker.network"] = networkName
|
|
break
|
|
}
|
|
}
|
|
return labels
|
|
}
|