Habitat Documentation

repository·main·Indexed 25 days ago

https://github.com/habitat-sh/habitat

An 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.

Tokens
81.5K
Snippets
229
Records
718
Agent score
81%

What's inside Habitat

  1. Overview of Habitat

    main
    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.
  2. Overview of Butterfly gossip protocol

    main

    Butterfly is the Habitat gossip protocol used for membership management. It implements the SWIM+Inf+Susp protocol 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.
  3. Overview of Chef Habitat Builder

    main

    Chef 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:

    1. Cloud-based (SaaS): A cloud service where plan files are stored, viewed, and accessed by the Chef Habitat community.
    2. 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.

  4. Overview of Habitat Launcher

    main

    The 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.

  5. Overview of Chef Habitat components

    main

    Chef 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.
  6. Understand Role-Based Access Control (RBAC) in Chef Habitat Builder

    main

    Chef 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 unstable channel, but cannot promote them.
    • Maintainer: Includes Member access. Can write to packages, membership, jobs, integrations, and invitations. Can promote packages from unstable to 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.
  7. Understand Supervisor Cryptography

    main

    Chef 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 (.hart files) are signed using BLAKE2b cryptographic hash functions.
  8. Understand Chef Habitat Plans and Artifacts

    main

    In 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 .hart extension) containing the application, its dependencies, and lifecycle hooks.

    Key components of a plan include:

    • plan.sh (Linux) or plan.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.
  9. Understand Chef Habitat package contents and directory structure

    main

    When 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-build script 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.

  10. Understand Service Groups

    main

    A 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>.default unless 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.