{"id":13827583,"url":"https://github.com/square/p2","last_synced_at":"2025-07-09T04:33:11.332Z","repository":{"id":21995390,"uuid":"25320424","full_name":"square/p2","owner":"square","description":"Platypus Platform: Tools for Scalable Deployment","archived":true,"fork":false,"pushed_at":"2020-01-14T21:31:37.000Z","size":53723,"stargazers_count":196,"open_issues_count":10,"forks_count":51,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-08-05T09:16:22.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/square.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-16T20:31:12.000Z","updated_at":"2024-01-13T23:52:58.000Z","dependencies_parsed_at":"2022-08-20T04:21:46.655Z","dependency_job_id":null,"html_url":"https://github.com/square/p2","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fp2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fp2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fp2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/square%2Fp2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/square","download_url":"https://codeload.github.com/square/p2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225036042,"owners_count":17410802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T09:02:02.415Z","updated_at":"2024-11-20T07:30:54.774Z","avatar_url":"https://github.com/square.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# P2: Tools for Scalable Software Deployment\n\n[![Build Status](https://travis-ci.org/square/p2.svg?branch=master)](https://travis-ci.org/square/p2)\n\nThis is a collection of tools intended to allow huge fleets of machines to\nparticipate in safe, flexible and scalable deployment models. It was designed\nfor Square but is a general-purpose framework that should look _suspiciously\nlike Kubernetes_ to anyone paying close attention.\n\n## Docker Optional\n\nUsing Docker isn't an overnight choice, especially for a company with a long\nhistory of deploying things that aren't Docker. P2 supports our internal\nartifact specification (\"Hoist artifacts\") which are `.tar.gz` files with a\ndefined layout.\n\nAlmost any `.tar.gz` can be a Hoist artifact, as long as it has a `bin/launch`\nscript or directory of scripts to exec under process management (we use Runit).\n\nHoist artifacts are totally self-contained and are expected to have all\ndependencies statically linked internally with very few exceptions.\n\nP2 executes artifacts in resource constrained cgroups as different users with\ndifferent home directories to create _extremely lightweight_ isolation.\n\n## Pods, Labels and Replication Controllers\n\nKubernetes provides some excellent tools for grouping and managing sets of\napplications. We copied them! We didn't want to wait to have our entire Docker\necosystem established (new build system, new kernel, etc) to start using these\ngreat higher-order orchestration primitives.\n\nWe currently have production-quality support for pod manifests, replication controllers\nand rolling updates, analagous to Kubernetes pods, replication controllers and deployments,\nrespectively. We are also actively working on pod clusters, our variation on Kubernetes\nservices.\n\n## More stuff!\n\nWe had to solve a number of problems that Square has today. That led us to the following concepts built-in from the beginning:\n\n\n* **Arbitrary configuration** files written into the pod manifest, exported and\nmounted at `CONFIG_PATH` for applications.\n* **Application lifecycle management and health.** During the shutdown of an\ninstance, we first run `bin/disable`. When starting up an instance, we run\n`bin/enable`, and then monitor the application via a call to `GET /_status`. A\n200 response code means ready and healthy.\n* **Rich plugin architecture for _secret company stuff_**. For example, our\nintegration with [Keywhiz](https://github.com/square/keywhiz) is implemented in an `after_install` hook. The `hooks`\npackage in this repo provides a handy Go library for writing hooks that can be\nscheduled.\n* **Self-hosting!** We wanted to deploy P2 with P2, so we did that. The binary\n`p2-bootstrap` allows you to set up a Consul agent and a P2 preparer on the\nsame host. If done right, that host should allow any future deploys to Just\nWork, including to both the Consul agent and the preparer themselves!\n* **Deployment Authorization.** From the beginning we needed a way to restrict\nwho can start which applications. The preparer can be given an ACL that can be\nenforced by GPG signatures on pod manifests, signed by the deployer. Or if you\nhate GPG, you can use delegated signing with a trusted orchestration service.\n\n# Playing Around\n\nTo build the tools in `p2`, run `rake build`. The `bin` subdirectory contains\nagents and executables, the `pkg` directory contains useful libraries for Go.\nWe strongly believe in small things that do one thing well.\n\n## Layout\n\n* `bin/` contains executables that, together, manage deployment. The `bootstrap` executable can be used to set up new nodes.\n* `pkg/` contains standalone libraries that provide supporting functionality of the executables. These libraries are all useful in isolation.\n\n## Integration Test\n\nRunning `rake integration` will attempt to launch a Vagrant Centos7 machine on\nyour computer, launch Consul and our preparer and then launch an application.\nIf you see a success message, you can `vagrant up` the halted box to check out\nthe setup without needing to do any work yourself.\n\nEnsure that [Vagrant](https://www.vagrantup.com/downloads.html) and\n[VirtualBox](https://www.virtualbox.org/wiki/Downloads) are installed if\n`rake integration` does not work.\n\n## Dependencies\n\nP2 is based on existing deployment tools at Square. The following list reflects\nall the system dependencies required by every P2 library, although many\nlibraries require only one of these or are dependency-free.\n\n* [Consul](https://consul.io/)\n* [Runit](http://smarden.org/runit/), which includes chpst\n\nMany P2 binaries expect to be able to invoke the `p2-exec` binary, ideally by knowing its full path.\nThe location can be set at compile-time by modifying the `github.com/square/p2/pkg/p2exec.DefaultP2Exec` variable.\nThe `-X` flag to `go install -ldflags` can be used to perform this assignment.\n\nIf the preparer config option `process_result_reporter_config` is set, the preparer will crash unless the configured extractor exists.\nWe provide one possible implementation at `p2-finish-env-extractor`.\n\n## Desirable Features\n\nAdding Docker support is a big next step, but will ultimately help us migrate to using Docker (or equally excellent RunC implementation) at Square.\n\nP2 also lacks a native job admission / scheduling system, so all pod scheduling is currently done manually by client using either a label selector or simply a hostname. Solutions to this are to be determined.\n\n# License\n\n[Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Fp2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquare%2Fp2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquare%2Fp2/lists"}