diff --git a/.bldr.toml b/.bldr.toml index ff97e185f4..ea4974bfb6 100644 --- a/.bldr.toml +++ b/.bldr.toml @@ -59,15 +59,6 @@ paths = [ "components/hab/*", ] -[hab-pkg-cfize] -plan_path = "components/pkg-cfize" -paths = [ - "components/pkg-export-container/*" -] - -[hab-pkg-mesosize] -plan_path = "components/pkg-mesosize" - [simple-hooks] plan_path = "test/fixtures/plans/simple-hooks" diff --git a/.expeditor/scripts/finish_release/sync_acceptance.toml b/.expeditor/scripts/finish_release/sync_acceptance.toml index a828667779..02371a042a 100644 --- a/.expeditor/scripts/finish_release/sync_acceptance.toml +++ b/.expeditor/scripts/finish_release/sync_acceptance.toml @@ -14,8 +14,6 @@ packages = [ "core/hab-backline", "core/hab-pkg-export-container", "core/hab-pkg-export-tar", - "core/hab-pkg-mesosize", - "core/hab-pkg-cfize" ] [[x86_64-linux-kernel2]] diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml index 2eb29955d7..26664305c7 100644 --- a/.expeditor/verify.pipeline.yml +++ b/.expeditor/verify.pipeline.yml @@ -950,24 +950,6 @@ steps: automatic: limit: 1 -# SHOULD BE UNCOMMENTED WHEN NEWER VERSION OF HAB IS RELEASED - - # - label: "[build] :linux: pkg-cfize" - # env: - # HAB_LICENSE: "accept-no-persist" - # BUILD_PKG_TARGET: "x86_64-linux" - - # command: - # - .expeditor/scripts/verify/build_package.sh components/pkg-cfize - # expeditor: - # executor: - # docker: - # privileged: true - # retry: - # automatic: - # limit: 1 - - - label: "[build] :linux: pkg-export-container" env: HAB_LICENSE: "accept-no-persist" @@ -1024,20 +1006,6 @@ steps: automatic: limit: 1 - - label: "[build] :linux: pkg-mesosize" - env: - HAB_LICENSE: "accept-no-persist" - BUILD_PKG_TARGET: "x86_64-linux" - command: - - .expeditor/scripts/verify/build_package.sh components/pkg-mesosize - expeditor: - executor: - docker: - privileged: true - retry: - automatic: - limit: 1 - - label: "[build] :linux: plan-build" env: HAB_LICENSE: "accept-no-persist" diff --git a/BUILDING.md b/BUILDING.md index 26376c14db..dac9309a32 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -192,29 +192,6 @@ hab-pkg-export-cf 0.55.0/20180321215151 … ``` -### Testing Cloud Foundry exporter - -See also [Exporting Docker Images for Cloud Foundry with Habitat](https://www.habitat.sh/blog/2018/03/habitat-cloudfoundry/). - -In order to test the Cloud Foundry exporter, you'll need a Cloud Foundry environment which supports -Docker images. If you have one already, you can skip to step 4. - -*Note:* Make sure to install PCF Dev on your base operating system. It uses VirtualBox as its virtualizer -so you can't install that within a VM. Fortunately, PCF Dev is has support for Linux, Windows and Mac OS. - -1. Install [the `cf` CLI](http://docs.pivotal.io/pivotalcf/2-1/cf-cli/install-go-cli.html). -2. Install [VirtualBox 5.0+](https://www.virtualbox.org/). -3. Install [PCF Dev](https://docs.pivotal.io/pcf-dev/index.html). *Note:* running `cf dev start` -for the first time requires a very large download (>7 GB as of this writing). -4. Build a `.hart` file and create a CF mapping `.toml`. See Stark and Wayne's -[Running Habitat Apps on Cloud Foundry](https://starkandwayne.com/blog/habitat-to-cloud-foundry/) and -[Exporting to Cloud Foundry documentation](https://www.habitat.sh/docs/developing-packages/#exporting-to-cloud-foundry) -for more details. -5. Run the exporter to add the `cf-` tagged image to Docker. -6. `docker push …` the image to Docker Hub. -7. `cf push …` the image from Docker Hub to add to the CF instance. *Note:* with PCF Dev this command -must be run from the source directory of the project to correctly identify the necessary buildpack. - ## HAB_STUDIO_BINARY This one is a bit special. Technically [hab-studio.sh](https://github.com/habitat-sh/habitat/blob/master/components/studio/bin/hab-studio.sh) is a shell script file and not binary. This also means that there is no need to build anything; set `HAB_STUDIO_BINARY` to the path to a version of `hab-studio.sh` within a `habitat` checkout and it will be used. This override will also affect which versions of the files in [studio/libexec](https://github.com/habitat-sh/habitat/tree/master/components/studio/libexec) are used. So if you want to test out changes to [hab-studio-profile.sh](https://github.com/habitat-sh/habitat/blob/master/components/studio/libexec/hab-studio-profile.sh) or [hab-studio-type-default.sh](https://github.com/habitat-sh/habitat/blob/master/components/studio/libexec/hab-studio-type-default.sh), make those changes in a checkout of the `habitat` repo located at `/path/to/habitat/repo` and set `HAB_STUDIO_BINARY` to `/path/to/habitat/repo/components/studio/bin/hab-studio.sh`. For example: diff --git a/END_TO_END_TESTING.md b/END_TO_END_TESTING.md index 3e1b7020aa..ee776ba647 100644 --- a/END_TO_END_TESTING.md +++ b/END_TO_END_TESTING.md @@ -35,7 +35,7 @@ packages for `stable` below in `HAB_BLDR_CHANNEL` if that is required. ``` env HAB_BLDR_CHANNEL=stable HAB_ORIGIN=core \ -hab studio run "for component in hab plan-build backline studio launcher sup pkg-export-tar pkg-export-docker pkg-mesosize pkg-cfize; do build components/\$component; done" +hab studio run "for component in hab plan-build backline studio launcher sup pkg-export-tar pkg-export-docker; do build components/\$component; done" ###################################################################### # Before uploading, ensure only your intended hart files are present # ###################################################################### diff --git a/components/docs-chef-io/content/habitat/container_orchestration.md b/components/docs-chef-io/content/habitat/container_orchestration.md index 7390e22b52..8267bd6b06 100644 --- a/components/docs-chef-io/content/habitat/container_orchestration.md +++ b/components/docs-chef-io/content/habitat/container_orchestration.md @@ -12,4 +12,4 @@ gh_repo = "habitat" +++ -Chef Habitat packages may be exported with the Supervisor directly into a [variety of container formats]({{< relref "pkg_exports" >}}), but frequently the container is running in a container orchestrator such as Kubernetes or Mesos. Container orchestrators provide scheduling and resource allocation, ensuring workloads are running and available. Containerized Chef Habitat packages can run within these runtimes, managing the applications while the runtimes handle the environment surrounding the application (ie. compute, networking, security). +Chef Habitat packages may be exported with the Supervisor directly into a [variety of container formats]({{< relref "pkg_exports" >}}), but frequently the container is running in a container orchestrator such as Kubernetes. Container orchestrators provide scheduling and resource allocation, ensuring workloads are running and available. Containerized Chef Habitat packages can run within these runtimes, managing the applications while the runtimes handle the environment surrounding the application (ie. compute, networking, security). diff --git a/components/docs-chef-io/content/habitat/install_faq.md b/components/docs-chef-io/content/habitat/install_faq.md index 35523ad62a..fdfac02ab3 100644 --- a/components/docs-chef-io/content/habitat/install_faq.md +++ b/components/docs-chef-io/content/habitat/install_faq.md @@ -39,4 +39,4 @@ If you're staunchly in the anti-curl-bash camp, you can get the latest packages **Q: How do I install `hab` across my server fleet?** -A: For the most part, we leave that up to you. You could just use the aforementioned curl-bash with your provisioner of choice. If your app was dockerized with Chef Habitat then you won't even need to ask this question, because you'll have everything you need inside your container. We are working on first class Mesosphere DC/OS, and Cloud Foundry integrations - which you can keep up to date on in our [Apache Mesos and DC/OS documentation]({{< relref "mesos_dcos" >}}) and [blog](https://www.chef.io/blog). +A: For the most part, we leave that up to you. You could just use the aforementioned curl-bash with your provisioner of choice. If your app was dockerize with Chef Habitat then you won't even need to ask this question, because you'll have everything you need inside your container. diff --git a/components/docs-chef-io/content/habitat/mesos_dcos.md b/components/docs-chef-io/content/habitat/mesos_dcos.md deleted file mode 100644 index 92cce4ebbc..0000000000 --- a/components/docs-chef-io/content/habitat/mesos_dcos.md +++ /dev/null @@ -1,88 +0,0 @@ -+++ -title = "Apache Mesos and DC/OS" -description = "Apache Mesos and DC/OS" -gh_repo = "habitat" - -[menu] - [menu.habitat] - title = "Apache Mesos and DC/OS" - identifier = "habitat/containers/mesos-dcos" - parent = "habitat/containers" - weight = 70 -+++ - -[Apache Mesos](https://mesos.apache.org/) is an open source distributed systems kernel and the distributed systems kernel for [Mesosphere's DC/OS](https://dcos.io) distributed platform. - -## Mesos Containerizers - -Mesos has support for [containerizers](https://mesos.apache.org/documentation/latest/containerizers/) for running commands and applications within isolated containers. Mesos supports Docker and its own [Mesos containerizer](https://mesos.apache.org/documentation/latest/mesos-containerizer/) format. The Mesos containerizer provides lightweight containerization with `cgroups/namespaces` isolation without actual isolation. The `hab pkg export mesos` command creates a mostly empty base filesystem with the application and the Chef Habitat Supervisor and packages it into a compressed tarball. - -## Marathon Applications - -[Marathon](https://mesosphere.github.io/marathon/) is a container orchestration platform for Mesos and DC/OS, handling the scheduling and deployment of applications. [Marathon applications](https://mesosphere.github.io/marathon/docs/application-basics.html) support Docker and the Mesos container formats, wrapping them in JSON metadata describing the resources needed to deploy the application. Once the application has been deployed to Marathon, it schedules it across the Mesos cluster and ensures the application is running optimally. - -### Export to a Mesos Container and Marathon Application - -You can create native Mesos containers from Chef Habitat packages by following these steps: - -1. Create an interactive studio in any directory with the `hab studio enter` command. - -2. Install or [build]({{< relref "pkg_build" >}}) the Chef Habitat package from which you want to create a Marathon application, for example: - - ```bash - $ hab pkg install yourorigin/yourpackage - ``` - -3. Run the Mesos exporter on the package. - - ```bash - $ hab pkg export mesos yourorigin/yourpackage - ``` - -4. This will create a Mesos container-format tarball in the results directory, and also print the JSON needed to load the application into Marathon. Note that the tarball needs to be uploaded to a download location and the `"uris"` in the JSON need to be updated manually. This is an example of the output: - - ```json - { - "id": "yourorigin/yourpackage", - "cmd": "/bin/id -u hab &>/dev/null || /sbin/useradd hab; /bin/chown -R hab:hab *; mount -t proc proc proc/; mount -t sysfs sys sys/;mount -o bind /dev dev/; /usr/sbin/chroot . ./init.sh start yourorigin/yourpackage", - "cpus": 0.5, - "disk": 0, - "mem": 256, - "instances": 1, - "uris": [ "https://storage.googleapis.com/mesos-habitat/yourorigin/yourpackage-0.0.1-20160611121519.tgz" ] - } - ``` - -5. Note that the default resource allocation for the application is very small: 0.5 units of CPU, no disk, one instance, and 256MB of memory. To change these resource allocations, pass different values to the Mesos exporter as command line options (defaults are documented with `--help`). - -6. From the DC/OS web interface, launch the Marathon Service. - - ![Screen shot of DC/OS Services](/images/habitat/mesos1-services-marathon.png) - -7. Select "Create Application". - - ![Screen shot of Marathon Applications List](/images/habitat/mesos2-new-application.png) - -8. Click on the "JSON Mode" selector and enter the JSON output of the Mesos exporter and click "Create Application". - - ![Screen shot of Marathon New Application JSON Mode](/images/habitat/mesos3-new-application-json.png) - -9. Marathon will then deploy the application and enter the "Running" status. - - ![Screen shot of Marathon Application Running](/images/habitat/mesos4-application.png) - -## Debugging - -You can get to the output from the running application by clicking on the "Marathon" service from the DC/OS "Services" tab. Select the application and the "Log Viewer" and choose either the "Error" or "Output" to see `stderr` and `stdout` respectively. If you have SSH access into the nodes, the Mesos container directories are beneath `/var/lib/mesos/slave/slaves`. - ![Screen shot of Debugging a Running Application](/images/habitat/mesos5-debugging.png) - -## Future Enhancements - -This is a basic integration, there are many improvements yet to be made. Here are a few examples: - - * Marathon environment variables are not passed into the Chef Habitat package "cmd" yet. - * Networking ports exposed by Chef Habitat need to be added to the JSON. - * The Chef Habitat gossip protocol needs to be included as a default exposed port. - * If Marathon is running the [artifact store](https://mesosphere.github.io/marathon/docs/), support uploading the tarball directly into it. - * Upload applications directly to the [Marathon application API](https://mesosphere.github.io/marathon/docs/application-basics.html). - * Marathon supports unpacking several archive formats. Native `.hart` support could be added directly to Marathon. diff --git a/components/docs-chef-io/content/habitat/pkg_exports.md b/components/docs-chef-io/content/habitat/pkg_exports.md index e95dc50567..95fc8735e7 100644 --- a/components/docs-chef-io/content/habitat/pkg_exports.md +++ b/components/docs-chef-io/content/habitat/pkg_exports.md @@ -1,6 +1,6 @@ +++ title = "Exporting Packages" -description = "Export Chef Habitat packages to Docker, Kubernetes, Helm, Mesos, DC/OS, Cloud Foundry, or as a tarball " +description = "Export Chef Habitat packages to Docker, Kubernetes, Helm, or as a tarball " gh_repo = "habitat" [menu] @@ -13,7 +13,7 @@ gh_repo = "habitat" Chef Habitat Artifacts--`.hart` files--can be exported in a number of different formats depending on what you need and where you need it. This is powerful because you can use the same immutable Chef Habitat artifact by exporting it into a format that you need for a specific job. -You can export packages into several different external, immutable runtime formats. Currently there are exports for: docker, mesos, tar, and cloudfoundry. +You can export packages into several different external, immutable runtime formats. Currently there are exports for: docker and tar. The command to export a package is `hab pkg export `. See the [Chef Habitat CLI Reference Guide]({{< relref "habitat_cli#hab-pkg-export" >}}) for more CLI information. @@ -99,115 +99,3 @@ You can create a Docker container image for any package by performing the follow sudo /hab/bin/hab sup run sudo /hab/bin/hab svc load / ``` - -### Exporting to Apache Mesos and DC/OS - -1. Create an interactive studio in any directory with the `hab studio enter` command. - -2. Install or [build]({{< relref "pkg_build" >}}) the Chef Habitat package from which you want to create a Marathon application, for example: - - ```bash - hab pkg install / - ``` - -3. Run the Mesos exporter on the package. - - ```bash - hab pkg export mesos / - ``` - -4. This will create a Mesos container-format tarball in the results directory, and also print the JSON needed to load the application into Marathon. Note that the tarball needs to be uploaded to a download location and the "uris" in the JSON need to be updated manually. This is an example of the output: - - ```json - { "id": "yourorigin/yourpackage", "cmd": "/bin/id -u hab &>/dev/null || /sbin/useradd hab; /bin/chown -R hab:hab *; - mount -t proc proc proc/; mount -t sysfs sys sys/;mount -o bind /dev dev/; /usr/sbin/chroot . ./init.sh start - yourorigin/yourpackage", "cpus": 0.5, "disk": 0, "mem": 256, "instances": 1, "uris": - ["https://storage.googleapis.com/mesos-habitat/yourorigin/yourpackage-0.0.1-20160611121519.tgz" ] } - ``` - -5. Note that the default resource allocation for the application is very small: 0.5 units of CPU, no disk, one instance, and 256MB of memory. To change these resource allocations, pass different values to the Mesos exporter as command line options (defaults are documented with `--help`). - -6. See the [Apaches Mesos and DC/OS documentation]({{< relref "mesos_dcos" >}}) for more information on getting your application running on Mesos. - -### Exporting to Cloud Foundry - -Packages can be exported to run in a [Cloud Foundry platform](https://www.cloudfoundry.org/certified-platforms/) through the use of a Docker image that contains additional layers meant to handle mapping from the Cloud Foundry environment to a Chef Habitat default.toml file. - -#### Setting up Docker Support in Cloud Foundry - -If you have not done so already, you must enable Docker support for Cloud Foundry before you can upload your Cloud Foundry-specific Docker image. - -To do so, make sure you have done the following: - -1. Log in as an Admin user. -2. Enable Docker support on your Cloud Foundry deployment by enabling the `diego_docker` feature flag. - -```bash -cf enable-feature-flag diego_docker -``` - -#### Creating a Mapping File - -The mapping file is a TOML file that can add Bash-interpolated variables and scripts. The Bash code will have access to: - -* all environment variables -* the jq binary -* the helper methods listed below - -Here's an example of a mapping TOML file named `cf-mapping.toml`: - -```toml cf-mapping.toml -secret_key_base = "$SECRET_KEY_BASE" -rails_env = "$RAILS_ENV" -port = ${PORT} - -[db] -user = "$(service "elephantsql" '.credentials.username')" -password = "$(service "elephantsql" '.credentials.password')" -host = "$(service "elephantsql" '.credentials.host')" -name = "$(service "elephantsql" '.credentials.database')" -``` - -#### Helpers - -The helper methods are designed to extract information from the standard Cloud Foundry environment variables [VCAP_SERVICES](https://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html#VCAP-SERVICES) and [VCAP_APPLICATION](https://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html#VCAP-APPLICATION). - -* `service ` will extract the JSON associated with the given service-name from the `VCAP_SERVICES` environment variable and apply the jq-expression to it. -* `application ` will apply the jq-expression to the `VCAP_APPLICATION` environment variable - -### Exporting and Pushing to a Cloud Foundry Endpoint - -1. Create a mapping.toml file using the format specified above and place that file in your local project repo. - -2. Enter the Studio through `hab studio enter`. - -3. Install or [build]({{< relref "pkg_build" >}}) the package that you want to export. - - ```bash - hab pkg install / - ``` - -4. Run the Cloud Foundry exporter on the package. - - ```bash - hab pkg export cf / /path/to/mapping.toml - ``` - - > **Note** To generate this image, a base Docker image is also created. The Cloud Foundry version of the docker image will have `cf-` as a prefix in the image tag. - -5. (Optional) If you are creating a web app that binds to another Cloud Foundry service, such as ElephantSQL, you must have this service enabled in your deployment before running your app. - -6. [Upload your Docker image to a supported registry](https://docs.cloudfoundry.org/devguide/deploy-apps/push-docker.html). Your Docker repository should be match the `origin/package` identifier of your package. - - ```bash - docker push origin/package:cf-version-release - ``` - -7. After your Cloud Foundry Docker image is built, you can deploy it to a Cloud Foundry platform. - - ```bash - cf push APP-NAME --docker-image docker_org/repository - ``` - - Your application will start after it has been successfully uploaded and deployed. - diff --git a/components/docs-chef-io/content/habitat/sup_rings.md b/components/docs-chef-io/content/habitat/sup_rings.md index 5ba5afec1c..ccac6545a4 100644 --- a/components/docs-chef-io/content/habitat/sup_rings.md +++ b/components/docs-chef-io/content/habitat/sup_rings.md @@ -17,15 +17,13 @@ A "Bastion Ring" is a pattern for preventing rumor loss and a split brain in a n ## Using a Scheduler -**Note:** If you are using a container scheduler such as the Kubernetes `kube-scheduler`, Docker Swarm mode, Mesos DC/OS's Marathon or Chronos, or a PaaS such as Cloud Foundry, you should not follow the bastion ring pattern, because the scheduler handles persistence and orchestration on your behalf. +**Note:** If you are using a container scheduler such as the Kubernetes `kube-scheduler` or Docker Swarm mode, you should not follow the bastion ring pattern, because the scheduler handles persistence and orchestration on your behalf. More resources on schedulers: - [Chef Habitat Container Orchestration]({{< relref "container_orchestration" >}}) - Kubernetes `kube-scheduler`: https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler - Docker Swarm mode: https://docs.docker.com/engine/swarm -- Mesos DC/OS Marathon or Chronos: https://mesosphere.github.io/marathon/ -- Cloud Foundry: https://www.habitat.sh/get-started/cloudfoundry ## Initial Peer(s) diff --git a/components/hab/src/cli/hab/pkg.rs b/components/hab/src/cli/hab/pkg.rs index 1a6e135fa1..e8b84e0962 100644 --- a/components/hab/src/cli/hab/pkg.rs +++ b/components/hab/src/cli/hab/pkg.rs @@ -541,18 +541,12 @@ pub struct PkgInstall { #[derive(ConfigOpt, StructOpt)] #[structopt(name = "export", aliases = &["e", "ex", "exp", "expo", "expor"], no_version)] pub enum ExportCommand { - #[cfg(target_os = "linux")] - /// Cloud Foundry exporter - Cf(ExternalCommandArgs), #[cfg(any(target_os = "linux", target_os = "windows"))] /// Container exporter Container(ExternalCommandArgs), #[cfg(any(target_os = "linux", target_os = "windows"))] #[structopt(settings = &[AppSettings::Hidden])] Docker(ExternalCommandArgs), - /// Mesos exporter - #[cfg(target_os = "linux")] - Mesos(ExternalCommandArgs), /// Tar exporter #[cfg(any(target_os = "linux", target_os = "windows"))] Tar(ExternalCommandArgs), diff --git a/components/hab/src/command/pkg/export.rs b/components/hab/src/command/pkg/export.rs index a3c1b51888..02d36451f5 100644 --- a/components/hab/src/command/pkg/export.rs +++ b/components/hab/src/command/pkg/export.rs @@ -1,5 +1,3 @@ -pub mod cf; pub mod container; mod export_common; -pub mod mesos; pub mod tar; diff --git a/components/hab/src/command/pkg/export/cf.rs b/components/hab/src/command/pkg/export/cf.rs deleted file mode 100644 index c2625b86d1..0000000000 --- a/components/hab/src/command/pkg/export/cf.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::{common::ui::UI, - error::Result}; -use std::ffi::OsString; - -// It would be more consistent naming to use "export cf" instead of "cfize", but for backwards -// compatibility we keep "cfize" -const EXPORT_CMD_ENVVAR: &str = "HAB_PKG_CFIZE_BINARY"; -const EXPORT_PKG_IDENT_ENVVAR: &str = "HAB_PKG_CFIZE_PKG_IDENT"; -const EXPORT_CMD: &str = "hab-pkg-cfize"; - -pub async fn start(ui: &mut UI, args: &[OsString]) -> Result<()> { - crate::command::pkg::export::export_common::start(ui, - args, - EXPORT_CMD_ENVVAR, - EXPORT_PKG_IDENT_ENVVAR, - EXPORT_CMD).await -} diff --git a/components/hab/src/command/pkg/export/mesos.rs b/components/hab/src/command/pkg/export/mesos.rs deleted file mode 100644 index 5633c59e2f..0000000000 --- a/components/hab/src/command/pkg/export/mesos.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::{common::ui::UI, - error::Result}; -use std::ffi::OsString; - -// It would be more consistent naming to use "export mesos" instead of "mesoize", but for backwards -// compatibility we keep "mesoize" -const EXPORT_CMD_ENVVAR: &str = "HAB_PKG_MESOSIZE_BINARY"; -const EXPORT_PKG_IDENT_ENVVAR: &str = "HAB_PKG_MESOSIZE_PKG_IDENT"; -const EXPORT_CMD: &str = "hab-pkg-mesosize"; - -pub async fn start(ui: &mut UI, args: &[OsString]) -> Result<()> { - crate::command::pkg::export::export_common::start(ui, - args, - EXPORT_CMD_ENVVAR, - EXPORT_PKG_IDENT_ENVVAR, - EXPORT_CMD).await -} diff --git a/components/hab/src/main.rs b/components/hab/src/main.rs index cd0ae718b9..52d8c0f340 100755 --- a/components/hab/src/main.rs +++ b/components/hab/src/main.rs @@ -299,10 +299,6 @@ async fn start(ui: &mut UI, feature_flags: FeatureFlag) -> Result<()> { all(target_os = "windows", target_arch = "x86_64"),))] Pkg::Export(export) => { match export { - #[cfg(target_os = "linux")] - PkgExportCommand::Cf(args) => { - return command::pkg::export::cf::start(ui, &args.args).await; - } #[cfg(any(target_os = "linux", target_os = "windows"))] PkgExportCommand::Container(args) => { return command::pkg::export::container::start(ui, &args.args).await; @@ -314,10 +310,6 @@ async fn start(ui: &mut UI, feature_flags: FeatureFlag) -> Result<()> { automation and processes accordingly.")?; return command::pkg::export::container::start(ui, &args.args).await; } - #[cfg(target_os = "linux")] - PkgExportCommand::Mesos(args) => { - return command::pkg::export::mesos::start(ui, &args.args).await; - } #[cfg(any(target_os = "linux", target_os = "windows"))] PkgExportCommand::Tar(args) => { return command::pkg::export::tar::start(ui, &args.args).await; diff --git a/components/pkg-cfize/README.md b/components/pkg-cfize/README.md deleted file mode 100644 index 126d292fb1..0000000000 --- a/components/pkg-cfize/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# CF Exporter - -Cloud Foundry is a Platform as a Service used to run 12 factor apps. - -## Exporter -To export a habitat package to run on Cloud Foundry you can run: -``` -$ hab pkg export cf / -``` - -This will create 2 docker images. First it will run the docker exporter and then it will create an image based off of that one with additional layers to handle mapping from the Cloud Foundry environment to the Habitat native configuration file. The CF version of the docker image will have `cf-` as a prefix to the image tag. - -``` -$ docker images -starkandwayne/redmine cf-3.4.2-20170921100414 39d89fc95ca6 16 hours ago 553MB -starkandwayne/redmine 3.4.2-20170921100414 9b9a155ece00 16 hours ago 549MB -``` - -## Mapping File -The mapping file is a toml file that can add Bash interpolated variables and scripts. The Bash code will have access to: -- all environment variables -- the jq binary -- a few helper methods - -cf-mapping.toml -``` -port = "${PORT}" -[db] -user = "$(service "redmine-pg" '.credentials.username')" -password = "$(service "redmine-pg" '.credentials.password')" -host = "$(service "redmine-pg" '.credentials.host')" -name = "$(service "redmine-pg" '.credentials.database')" -``` - -## Helpers - -The helper methods are designed to extract information from the standard Cloud Foundry environment variables `VCAP_SERVICES` and `VCAP_APPLICATION`. - -Helpers: -- `service ` will extract the JSON associated with the given service-name from the `VCAP_SERVICES` environment variable and apply the jq-expression to it. -- `application ` will apply the jq-expression to the `VCAP_APPLICATION` environment variable diff --git a/components/pkg-cfize/bin/hab-pkg-cfize.sh b/components/pkg-cfize/bin/hab-pkg-cfize.sh deleted file mode 100755 index 992907ba02..0000000000 --- a/components/pkg-cfize/bin/hab-pkg-cfize.sh +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/bash -# -# # Usage -# -# ``` -# $ hab-pkg-cfize [PKG] [MAPPING] -# ``` -# -# # Synopsis -# -# Create a Docker container from a set of Habitat packages. - -# Fail if there are any unset variables and whenever a command returns a -# non-zero exit code. -set -eu - -# If the variable `$DEBUG` is set, then print the shell commands as we execute. -if [ -n "${DEBUG:-}" ]; then - set -x - export DEBUG -fi - -# ## Help - -# **Internal** Prints help -print_help() { - echo -- "$program $version - -$author - -Habitat Package CFize - Create a Cloud Foundry ready Docker image from a given package. - -USAGE: - $program -" -} - -# **Internal** Exit the program with an error message and a status code. -# -# ```sh -# exit_with "Something bad went down" 55 -# ``` -exit_with() { - if [ "${HAB_NOCOLORING:-}" = "true" ]; then - echo -- "ERROR: $1" - else - case "${TERM:-}" in - *term | xterm-* | rxvt | screen | screen-*) - printf -- "\033[1;31mERROR: \033[1;37m%s\033[0m\n" "$1" - ;; - *) - printf -- "ERROR: %s\n" "$1" - ;; - esac - fi - exit "$2" -} - -dockerize_tags() { - local docker_output_file="$1" - grep tagged "$docker_output_file" | awk '{ print $3}' -} - -sh_shebang() { - local docker_output_file="$1" - echo "#!$(grep ENV "$docker_output_file" | \ - tr ":" "\n" | \ - grep busybox-static | \ - head -n1)/sh" -} - -build_cf_image() { - local hab_package=${1} - local mapping=${2} - - tmp_dir="$(mktemp -t -d "${program}-XXXX")" - - dockerize_out="${tmp_dir}/dockerize-out" - hab-pkg-export-container "${hab_package}" | tee "${dockerize_out}" - - docker_tag_array=$(dockerize_tags "${dockerize_out}") - cf_docker_tag_array=("${docker_tag_array[@]/:/:cf-}") - - DOCKER_CONTEXT=${tmp_dir}/docker - mkdir -p "${DOCKER_CONTEXT}" - render_helpers > "${DOCKER_CONTEXT}"/helpers.sh - - cat < "$DOCKER_CONTEXT"/cf-init.sh -$(sh_shebang "${dockerize_out}") -source /helpers.sh -( echo "cat <~/user.toml"; - cat /config.toml; - echo "EOF"; -) >~/render.sh -. ~/render.sh -mv ~/user.toml /hab/svc/$(basename "${hab_package}")/user.toml -exec /init.sh "\$@" -EOT - chmod +x "$DOCKER_CONTEXT"/cf-init.sh - - cat "${mapping}" > "${DOCKER_CONTEXT}"/config.toml - cat < "$DOCKER_CONTEXT"/Dockerfile -FROM ${docker_tag_array[0]} -RUN hab pkg install core/jq-static -ADD cf-init.sh / -ADD helpers.sh / -ADD config.toml / -ENTRYPOINT ["/cf-init.sh"] -CMD ["start", "$1"] -EOT - - docker build --force-rm --no-cache "${cf_docker_tag_array[@]/#/-t }" "${DOCKER_CONTEXT}" - rm -rf "${tmp_dir}" -} - -render_helpers() { - cat < "$bin" -#!$(pkg_path_for bash)/bin/bash -set -e -if test -n "\$DEBUG"; then set -x; fi - -export PATH="$_runtime_path:\${PATH:-}" - -exec ${bin}.real \$@ -EOF - chmod -v 755 "$bin" -} diff --git a/components/pkg-mesosize/bin/hab-pkg-mesosize.sh b/components/pkg-mesosize/bin/hab-pkg-mesosize.sh deleted file mode 100755 index cdae8e2cf7..0000000000 --- a/components/pkg-mesosize/bin/hab-pkg-mesosize.sh +++ /dev/null @@ -1,179 +0,0 @@ -#!/bin/bash -# -# # Usage -# -# ``` -# $ hab-pkg-mesosize [PKG ...] -# ``` -# -# # Synopsis -# -# Create a Mesos application from a set of Habitat packages. - -# defaults for the application -: "${CPU:="0.5"}" -: "${DISK:="0"}" -: "${INSTANCES:="1"}" -: "${MEM:="256"}" -: "${PKG:="unknown"}" - -# Fail if there are any unset variables and whenever a command returns a -# non-zero exit code. -set -eu - -# If the variable `$DEBUG` is set, then print the shell commands as we execute. -if [ -n "${DEBUG:-}" ]; then - set -x - export DEBUG -fi - -# ## Help - -# **Internal** Prints help -print_help() { - echo -- "$program $version - -$author - -Habitat Package Mesosize - Create a Mesos application from a set of Habitat packages - -USAGE: - $program [FLAGS] [OPTIONS] - -FLAGS: - --help Prints help information - -OPTIONS: - --cpu=N CPUs for the application (float, .5 is default) - --disk=N Disk Space for the application (0 is default) - --instances=N Number of application instances to launch (1 is default) - --mem=N Memory for the application (MB, 256 is default) - -ARGS: - Habitat package identifier (ex: acme/redis) -" -} - -# **Internal** Exit the program with an error message and a status code. -# -# ```sh -# exit_with "Something bad went down" 55 -# ``` -exit_with() { - if [ "${HAB_NOCOLORING:-}" = "true" ]; then - printf -- "ERROR: %s\n" "$1" - else - case "${TERM:-}" in - *term | xterm-* | rxvt | screen | screen-*) - printf -- "\033[1;31mERROR: \033[1;37m%s\033[0m\n" "$1" - ;; - *) - printf -- "ERROR: %s\n" "$1" - ;; - esac - fi - exit "$2" -} - -find_system_commands() { - if mktemp --version 2>&1 | grep -q 'GNU coreutils'; then - _mktemp_cmd=$(command -v mktemp) - else - if /bin/mktemp --version 2>&1 | grep -q 'GNU coreutils'; then - _mktemp_cmd=/bin/mktemp - else - exit_with "We require GNU mktemp to build Mesos applications; aborting" 1 - fi - fi -} - -# parse the CLI flags and options -parse_options() { - for i in "$@" - do - case $i in - --help) - print_help - exit - ;; - --cpu=*) - CPU="${i#*=}" - shift - ;; - --disk=*) - DISK="${i#*=}" - shift - ;; - --instances=*) - INSTANCES="${i#*=}" - shift - ;; - --mem=*) - MEM="${i#*=}" - shift - ;; - *) - PKG=${i} - ;; - esac - done - if [ "$PKG" == "unknown" ]; then - print_help - exit_with "You must specify one or more Habitat packages to Mesosize." 1 - fi -} - -# Create a hab studio baseimage and populate it with the application -build_tarball_image() { - TARBALL_CONTEXT="$($_mktemp_cmd -t -d "${program}-XXXX")" - pushd "$TARBALL_CONTEXT" > /dev/null - env PKGS="$PKG" NO_MOUNT=1 hab studio -r "$TARBALL_CONTEXT" -t bare new - echo "$PKG" > "$TARBALL_CONTEXT"/.hab_pkg - popd > /dev/null - tar -czpf "$(package_name_with_version "$PKG")".tgz -C "$TARBALL_CONTEXT" ./ -} - -package_name_with_version() { - local ident_file - ident_file=$(find "$TARBALL_CONTEXT"/"$HAB_ROOT_PATH"/pkgs/"$PKG" -name IDENT) - awk 'BEGIN { FS = "/" }; { print $1 "-" $2 "-" $3 "-" $4 }' < "$ident_file" -} - -# https://mesosphere.github.io/marathon/docs/application-basics.html -create_application_definition() { - echo " - { - \"id\": \"$PKG\", - \"cmd\": \"/bin/id -u hab &>/dev/null || /sbin/useradd hab; /bin/chown -R hab:hab *; mount -t proc proc proc/; mount -t sysfs sys sys/;mount -o bind /dev dev/; /usr/sbin/chroot . ./init.sh start $PKG\", - \"cpus\": $CPU, - \"disk\": $DISK, - \"mem\": $MEM, - \"instances\": $INSTANCES, - \"uris\": [ \"URL_TO_$(package_name_with_version "$PKG").tgz\" ] - } -" - # what about exposing ports? - } - -# The root of the filesystem. If the program is running on a separate -# filesystem or chroot environment, this environment variable may need to be -# set. -: "${FS_ROOT:=}" -# The root path of the Habitat file system. If the `$HAB_ROOT_PATH` environment -# variable is set, this value is overridden, otherwise it is set to its default -: "${HAB_ROOT_PATH:=$FS_ROOT/hab}" - -# The current version of Habitat Studio -version='@version@' -# The author of this program -author='@author@' -# The short version of the program name which is used in logging output -program=$(basename "$0") - -find_system_commands - -parse_options "$@" -build_tarball_image -# publish the tarball somewhere? upload_tarball_to_artifact_store? -create_application_definition -rm -rf "$TARBALL_CONTEXT" diff --git a/components/pkg-mesosize/habitat/plan.sh b/components/pkg-mesosize/habitat/plan.sh deleted file mode 100644 index 2c3974d8cc..0000000000 --- a/components/pkg-mesosize/habitat/plan.sh +++ /dev/null @@ -1,42 +0,0 @@ -# shellcheck disable=2154 -pkg_name=hab-pkg-mesosize -pkg_origin=core -pkg_maintainer="The Habitat Maintainers " -pkg_license=('Apache-2.0') -pkg_deps=(core/coreutils - core/findutils - core/gawk - core/grep - core/bash - core/tar - core/gzip - core/hab) -pkg_build_deps=() -pkg_bin_dirs=(bin) - -program=$pkg_name - -pkg_version() { - cat "$SRC_PATH/../../VERSION" -} - -do_before() { - do_default_before - update_pkg_version -} - -do_build() { - cp -v "$SRC_PATH"/bin/${program}.sh ${program} - - # Use the bash from our dependency list as the shebang. Also, embed the - # release version of the program. - sed \ - -e "s,#!/bin/bash$,#!$(pkg_path_for bash)/bin/bash," \ - -e "s,@author@,$pkg_maintainer,g" \ - -e "s,@version@,$pkg_version/$pkg_release,g" \ - -i $program -} - -do_install() { - install -v -D $program "$pkg_prefix"/bin/$program -}