Habitat Documentation
repository·main·Indexed 25 days ago
https://github.com/habitat-sh/habitatAn open-source tool for creating platform-independent build artifacts with built-in automation for deployment, management, scaling, and updates. Documentation covers the Butterfly gossip protocol, the Habitat Launcher sidecar process, native package builds, and instructions for building the hab binary on macOS.
What's inside Habitat
- Habitat is an open-source platform that creates platform-independent build artifacts. It allows you to automate application behavior during creation and bundle that automation (runtime behavior, update strategies, failure handling, and scaling) directly with the application. This ensures the application behaves correctly regardless of the deployment target.
Overview of Butterfly gossip protocol
mainButterfly is the Habitat gossip protocol used for membership management. It implements the
SWIM+Inf+Suspprotocol for membership and utilizes a ZeroMQ-based newscast-inspired gossip protocol.Key characteristics include:
- Eventually consistent: Members converge on the same state over time.
- Efficient: The protocol avoids back-chatter by sending messages without requiring confirmations.
- Reliable: Designed as a safe and reliable building block for Habitat.
Overview of Chef Habitat Builder
mainChef Habitat Builder is the core of Chef's Application Delivery Enterprise hub. It serves as a repository for plan templates and application delivery content. It is available in two consumption models:
- Cloud-based (SaaS): A cloud service where plan files are stored, viewed, and accessed by the Chef Habitat community.
- On-premises: A solution for users who prefer to store packages and run the builder locally. Plan files from the SaaS version can be shared with and maintained by the on-premises version.
This dual-model approach supports air-gapped environments and local package maintenance.
Overview of Habitat Launcher
mainThe Habitat Launcher is a minimal sidecar process for the Supervisor. It acts as the entry point for running the Supervisor and is designed to run as process 1. Its primary responsibilities include:
- Launching the Habitat Supervisor.
- Restarting the Habitat Supervisor on shutdown (acting as the 'Supervisor for the Supervisor').
- Starting, stopping, and restarting processes on behalf of the Supervisor.
Launcher is specifically designed to enable the Supervisor to self-update without shutting down or re-parenting the services being supervised. Because it is intended to run as process 1, it is versioned separately and should be updated very infrequently.
Overview of Chef Habitat components
mainChef Habitat is a workload-packaging, orchestration, and deployment system designed to separate platform-independent application parts (build/runtime dependencies, lifecycle events, and codebase) from the underlying infrastructure.
Key components include:
- Habitat Package: An immutable, cryptographically signed artifact (.HART file) containing the application codebase, lifecycle hooks, and a manifest of dependencies.
- Habitat Builder: A package store (SaaS or on-prem) used to store, build, and deploy Habitat packages.
- Habitat Supervisor: A runtime component that pulls packages from the Builder and manages the application (start, stop, monitor, update) based on the defined Plan and lifecycle hooks. It can run on bare metal, VMs, containers, or PaaS.
- Service: A package currently under management by a Supervisor.
- Service Group: A collection of services with the same package and topology type connected across a Supervisor network.
Understand Service Groups in Chef Habitat
mainA service group is a collection of one or more running services that share a common configuration and topology.
If you start a service without explicitly specifying a group name, Habitat assigns it to a default group based on the package name. For example:
redis.defaultpostgres.financialdbpostgres.userdb
Understand Role-Based Access Control (RBAC) in Chef Habitat Builder
mainChef Habitat Builder uses token-based RBAC at the origin level to control user access. Roles are cumulative: each higher role includes all privileges of the previous roles.
Available Roles:
- Read-Only: Default for new members. Can view packages, channels, membership, jobs, keys, integrations, invitations, roles, and settings. Cannot upload or change anything.
- Member: Includes Read-Only access. Can upload and build packages in the
unstablechannel, but cannot promote them. - Maintainer: Includes Member access. Can write to packages, membership, jobs, integrations, and invitations. Can promote packages from
unstableto other channels. Can read origin keys and settings, but cannot modify them. Cannot read/write origin secrets. - Administrator: Includes Maintainer access. Has write access to origin keys, can manage origin membership, and can read/write origin secrets.
- Owner: Full read/write access to all aspects of the origin. Only Owners can delete the origin or transfer ownership.
Understand Supervisor Cryptography
mainChef Habitat utilizes
libsodium(a Rust implementation of NaCl) for its cryptographic operations. It employs both symmetric encryption for wire encryption and asymmetric encryption for other security tasks.- Message Encryption: When wire encryption or service group encryption is enabled, Habitat uses the Curve25519, Salsa20, and Poly1305 ciphers.
- Package Signing: Habitat packages (
.hartfiles) are signed using BLAKE2b cryptographic hash functions.
Identify Chef-owned origins
mainProgress Chef maintains several official origins for specific package types:
- core: Common dependencies and compilers maintained by Progress Chef.
- chef: Chef products (e.g., Chef Infra Client, Chef InSpec, Chef Automate).
- chef-platform: Chef 360 Platform skills.
- habitat: Packages required for an on-prem Habitat Builder deployment.
Understand Chef Habitat Plans and Artifacts
mainIn Chef Habitat, a plan is a directory of shell scripts (or PowerShell scripts on Windows) and optional configuration files that define how software is downloaded, configured, built, installed, and managed.
These plans are used to build artifacts, which are cryptographically-signed tarballs (with a
.hartextension) containing the application, its dependencies, and lifecycle hooks.Key components of a plan include:
plan.sh(Linux) orplan.ps1(Windows): The required entry point for the build process.pkg_*variables: Define metadata like name, version, origin, dependencies, and directory structures.- Optional files: Configuration templates, runtime hooks, and service configuration files.
Understand Chef Habitat package contents and directory structure
mainWhen Chef Habitat packages are installed, they are placed in the
/hab/pkgs/directory, organized by their fully-qualified identifiers in the format:origin/name/version/release.During the build process, the
hab-plan-buildscript generates several metadata files that define dependencies, environment variables, and configuration. These files are used by the Chef Habitat Supervisor during the initialization phase to ensure services have the correct runtime environment.Understand Service Groups
mainA service group is a logical grouping of services that share the same package and topology type, connected across a Supervisor network.
Key characteristics:
- Shared Configuration: Services within a group can share configuration and file updates.
- Segmentation: Groups can be used to segment services by workflow or deployment needs (e.g.,
QA,Production). - Security: Updates can be encrypted so only members of a specific service group can decrypt them.
- Default Behavior: By default, every service joins a group named
<service-name>.defaultunless specified otherwise at runtime. - Network Isolation: Multiple service groups can exist within the same Supervisor network, allowing data exposed by Supervisors to be shared across the ring regardless of group membership.