Sha256: d68276732272d56eb85bf271c6bbacf19e8d09ea300dd05e326326ee1241fc86

Contents?: true

Size: 1.5 KB

Versions: 15

Compression:

Stored size: 1.5 KB

Contents

---
title: Boot Hooks
---

If you need to hook into the Kubes boot process super-early on, Kubes boot hooks are designed for that.

* They run very early in the Kubes boot process.
* They are useful for setting shared global values like env vars.
* Boot hooks are ruby files that get required. It's nice and simple. There's no interface to learn.

## Hooks

Kubes will searches 2 files in the `config` folder. If the files exist, they will be ran in this order.

1. **.kubes/config/boot.rb**: Always runs.
2. **.kubes/config/boot/KUBES_ENV.rb**: Runs based on the env. IE: `KUBES_ENV=dev` => `.kubes/config/boot/dev.rb`

Both files are required and ran if they both exists. Since the `KUBES_ENV` one runs second, it can be used to override previously set values.

## Example: Default KUBES_ENV

If you prefer a different default than `KUBES_ENV=dev`.

config/boot.rb

```ruby
ENV['KUBES_ENV'] ||= 'development'
```

This changes the default for everyone using the project, but still allows them to control the default by adding `export KUBES_ENV=development` to their `~/.bash_profile`.

## Example: Auto-Switch AWS_PROFILE

One useful example is switching `AWS_PROFILE` based on the `KUBES_ENV`. Example:

config/boot/dev.rb

```ruby
ENV['AWS_PROFILE'] = 'dev'
```

This example is for AWS, but you can can do similiar switch logic with `GOOGLE_APPLICATION_CREDENTIALS`, etc.

## Boot Source

Please refer to the boot source code for more details: [kubes/booter.rb](https://github.com/boltops-tools/kubes/blob/master/lib/kubes/booter.rb)

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
kubes-0.9.3 docs/_docs/config/boot.md
kubes-0.9.2 docs/_docs/config/boot.md
kubes-0.9.1 docs/_docs/config/boot.md
kubes-0.9.0 docs/_docs/config/boot.md
kubes-0.8.10 docs/_docs/config/boot.md
kubes-0.8.9 docs/_docs/config/boot.md
kubes-0.8.8 docs/_docs/config/boot.md
kubes-0.8.7 docs/_docs/config/boot.md
kubes-0.8.6 docs/_docs/config/boot.md
kubes-0.8.5 docs/_docs/config/boot.md
kubes-0.8.4 docs/_docs/config/boot.md
kubes-0.8.3 docs/_docs/config/boot.md
kubes-0.8.2 docs/_docs/config/boot.md
kubes-0.8.1 docs/_docs/config/boot.md
kubes-0.8.0 docs/_docs/config/boot.md