Using a self-hosted Hub
Connect your tools to your organization's installation.
The feature guides apply to both Embedl-managed and self-hosted installations.
SDK examples use https://hub.embedl.com; for a self-hosted Hub, change the
connection settings below.
Install the SDK offline#
Ask your administrator for the supplied SDK package. Its sdk/README.md lists
the supported Python versions and operating system. Use the SDK version supplied
with your release when one is provided.
Activate a virtual environment, then run this from the package’s sdk/ directory:
pip install --no-index --find-links wheels embedl_hub-*.whl This installs from the included files without contacting a package index. Then connect the SDK.
Connect the SDK#
Create an API key in your Hub. Then, in the directory for your work, connect a workspace to the Hub and store the key. Replace the example URL with your own in both commands and paste the key at the prompt:
embedl-hub init
embedl-hub use hub https://your-hub.example.com
embedl-hub auth --hub https://your-hub.example.com --api-key - Use the URL you open in the browser, including any port but without /api or a
page path such as /projects. The key must come from that same Hub.
The SDK does not follow redirects. If the address redirects, for example from http:// to https://, the error names the address to use instead.
The Hub is saved in the workspace’s .ehub/ folder. Commit the whole folder
with your code, and everyone who clones the repository connects to your Hub
without setting it themselves; if the address changes, one commit updates it
for the whole team. The folder’s .gitignore keeps each person’s selected
project and run out of git, and each person still stores their own API key. See SDK configuration for the other
ways to set the Hub, including for automated jobs. If the Hub is behind Google
Cloud IAP, its IAP settings can be stored there too; see Connect to a Hub behind Google Cloud IAP.
Continue with Select a project.
Connect to a Hub behind Google Cloud IAP#
If your organization runs the Hub behind Google Cloud Identity-Aware Proxy (IAP), IAP checks every request before it reaches the Hub. The SDK then sends a Google-signed ID token alongside the API key. The API key is still required: IAP decides who may reach the Hub, and the Hub decides what the key may do.
The audience and the required access are set up by your deployment administrator; see Administrator setup.
Install the SDK with its iap extra, which adds google-auth:
pip install 'embedl-hub[iap]' The offline SDK package does not include google-auth. Install it from a package index your organization provides.
Settings#
| Setting | Environment variable | Config file | Value |
|---|---|---|---|
| Audience (required) | EMBEDL_HUB_IAP_AUDIENCE | iap.audience | The ID of an OAuth client that the Hub’s IAP accepts for programmatic access. |
| Google Cloud service account (optional) | EMBEDL_HUB_IAP_SERVICE_ACCOUNT | iap.service_account | The email of the Google Cloud service account to obtain the token as. |
Setting the audience is what turns this on. A Hub with no audience is contacted exactly as before.
The service account setting names a Google Cloud service account, which is unrelated to a Hub service account.
The settings are stored under hubs, by the Hub’s address, so they are only
used for that Hub:
hubs:
https://your-hub.example.com/:
iap:
audience: 1234567890-abc.apps.googleusercontent.com
service_account: hub-sdk@your-project.iam.gserviceaccount.com Add them to the workspace’s .ehub/config.yaml beside hub to share them with
everyone who uses the repository, or to the SDK’s global config file for
yourself alone. embedl-hub use --show-origin prints the path of each.
A workspace’s config.yaml decides which Hub receives your Google ID token and
the audience it is issued for. Use IAP settings from a workspace only in a
repository you trust.
In automated jobs outside a workspace, set the environment variables together with the Hub address:
export EMBEDL_HUB_URL=https://your-hub.example.com
export EMBEDL_HUB_API_KEY=YOUR_API_KEY
export EMBEDL_HUB_IAP_AUDIENCE=1234567890-abc.apps.googleusercontent.com
export EMBEDL_HUB_IAP_SERVICE_ACCOUNT=hub-sdk@your-project.iam.gserviceaccount.com Each setting is taken from the first of: the environment, the workspace, the global config file. For example, a workspace can set the audience while your global config file sets the service account you use.
The token is only ever sent to the Hub it is configured for, so the SDK stops with an error that names the fix when:
EMBEDL_HUB_IAP_AUDIENCEis set but the Hub address does not come fromEMBEDL_HUB_URL. An audience in the environment does not say which Hub it belongs to.- The Hub address is not
https, or ishttps://hub.embedl.com. - A Google Cloud service account is set without an audience.
embedl-hub status shows the audience and the Google Cloud service account in
effect, and where each comes from.
Which Google identity obtains the token#
The SDK starts from Application Default Credentials, the Google credentials configured in its environment. It obtains a new token before the current one expires, so a script that outlives one token keeps working.
| Environment | Credentials | Google Cloud service account setting |
|---|---|---|
| Your own machine | gcloud auth application-default login | Required. Your Google login cannot obtain a token for IAP itself. |
| Kubernetes or CI with Workload Identity Federation | The federation credential configuration file | Required, unless the file names a Google Cloud service account. |
| Google Cloud, such as Compute Engine, Cloud Run, or GKE with Workload Identity | The metadata server | Optional. Without it, the token is obtained as the workload’s own service account. |
When the credentials already act as a Google Cloud service account, the token is obtained as that account and the setting is optional. When the setting names a different account, the SDK impersonates it. Credentials that act as no service account need the setting, and the SDK says so when it is missing.
Workload Identity Federation has not yet been verified against a federation pool.
Administrator setup#
- The audience: the ID of an OAuth client that the Hub’s IAP accepts for programmatic access. Your administrator adds the client to IAP’s programmatic access allowlist. With IAP’s Google-managed OAuth client, that means creating an OAuth client for this first.
- On the Hub, through IAP’s access policy:
roles/iap.httpsResourceAccessor(IAP-secured Web App User) for the Google Cloud service account the token is obtained as. - On that service account:
roles/iam.serviceAccountOpenIdTokenCreator(Service Account OpenID Connect Identity Token Creator) for the identity that asks for the token, such as your Google user or the federated identity of a job. A workload on Google Cloud that uses its own service account needs no such role.
Calling the REST API without the SDK#
Send both headers on every request, and do not follow redirects:
Authorization: Bearer YOUR_API_KEY
Proxy-Authorization: Bearer GOOGLE_ID_TOKEN
Accept: application/json GOOGLE_ID_TOKEN is a Google-signed ID token, issued to a Google Cloud service
account with its email claim included, whose audience is the OAuth client ID
above. IAP authorizes the request by Proxy-Authorization and passes Authorization on to the Hub unchanged. Tokens expire after about an hour, so
obtain a new one before then. A response that IAP generates itself, instead of
forwarding the request, carries the header X-Goog-IAP-Generated-Response.
Feature availability#
The installed version and configuration determine which features are available. If a feature is missing, ask your deployment administrator whether it is enabled and supported in your release. If you can open it but cannot make changes, check Sharing and permissions.
Installation and upgrades#
Your deployment administrator handles installation, upgrades, and connected
services. Follow the instructions supplied with your release: README.md for
Docker Compose or helm/README.md for Kubernetes.
For account management, see User administration.