🗺️ Workspaces¶
Was auch immer Sie mit Polycrate bauen passiert in einem Workspace. Der Workspace enthält Konfiguration, Credentials und Lifecycle-Artefakte, die beim Ausführen von Blöcken entstehen. Ein Workspace ist im Grunde genommen nur ein Ordner auf Ihrer Festplatte der mit Hilfe von git oder anderen Mechanismen versioniert und synchronisiert werden kann. Die sog. Workspace Directory kann beim Ausführen von Polycrate mit dem Flag --workspace ~/.polycrate/workspaces/demo, bzw. -w ~/.polycrate/workspaces/demo festgelegt werden.
Info
Standardmäßig nimmt Polycrate an, dass der aktuelle Pfad ($PWD), von dem Polycrate ausgeführt wurde, ein Workspace ist.
Der Workspace kann mit Hilfe der Workspace-Konfiguration zusammengestellt werden.
Workspace Directory Layout¶
Ein Workspace folgt einer definierten Verzeichnisstruktur, die automatisch beim Initialisieren angelegt wird:
graph TB
WS[my-workspace/] --> Config[workspace.poly]
WS --> DF[Dockerfile.poly optional]
WS --> PrivKey[id_rsa]
WS --> PubKey[id_rsa.pub]
WS --> Blocks[blocks/]
WS --> Logs[.logs/ optional]
WS --> Arts[artifacts/]
WS --> Inv[inventory.yml optional]
WS --> Kube[kubeconfig.yml optional]
Blocks --> B1[block-1/]
Blocks --> B2[block-2/]
B1 --> BP1[block.poly]
B1 --> CL1[CHANGELOG.poly]
B1 --> RM1[README.md]
B1 --> T1[templates/]
Logs --> Date[2025-01-30/]
Date --> TXLog[uuid.yml]
Arts --> BlockArts[blocks/]
BlockArts --> BA1[block-1/]
BA1 --> AInv[inventory.yml]
BA1 --> AKube[kubeconfig.yml]
BA1 --> Cache[hosts_cache.json]
style WS fill:#e1f5ff
style Logs fill:#ffe1e1
style Blocks fill:#f0ffe1
style Arts fill:#fff4e1 Wichtige Verzeichnisse und Dateien¶
Workspace-Root: - workspace.poly - Workspace-Konfiguration (Pflicht) - Dockerfile.poly - Optional: Custom Docker-Image für den Workspace - id_rsa / id_rsa.pub - SSH-Schlüsselpaar (automatisch generiert mit polycrate workspace init --with-ssh-keys) - inventory.yml - Optional: Globales Ansible-Inventory - kubeconfig.yml - Optional: Globale Kubernetes-Konfiguration
blocks/ - Alle Blocks des Workspaces - Jeder Block hat sein eigenes Verzeichnis - block.poly definiert Block-Konfiguration und Actions - CHANGELOG.poly dokumentiert Versionshistorie - README.md beschreibt den Block - templates/ enthält Jinja2-Templates für Ansible
.logs/ - Optional: Event Handler Logs - Wird primär von Event-Handlers verwendet - Transaction-Logging ist standardmäßig deaktiviert - Falls aktiviert: Logs nach Datum organisiert in .logs/YYYY-MM-DD/uuid.yml
artifacts/ - Von Blocks generierte Artifacts - blocks/BLOCKNAME/ - Block-spezifische Artifacts - inventory.yml - Generiertes oder geerbtes Ansible-Inventory - kubeconfig.yml - Generierte oder geerbte Kubernetes-Config - hosts_cache.json - SSH-Host-Cache für schnellere Verbindungen
Git-Integration
Ein Workspace kann (und sollte) ein Git-Repository sein. Polycrate kann automatisch Commits erstellen und mit Remote-Repositories synchronisieren. Konfigurieren Sie dies in der workspace.poly unter sync_options.