Sha256: 3a6efedbcccde4b2133207a4566c67a7ca18767d6528e48558873d22e1996628

Contents?: true

Size: 1.6 KB

Versions: 28

Compression:

Stored size: 1.6 KB

Contents

---
title: Mixed Layering
---

You can mix and match the YAML and DSL forms together and layering still works.

## Project Structure

Here's an example structure, so we can understand how layering works.

    .kubes/resources/
    ├── base
    │   ├── all.yaml
    │   └── deployment.yaml
    └── web
        ├── deployment
        │   ├── dev.yaml
        │   └── prod.yaml
        ├── deployment.rb
        └── service.yaml

Notice, how deployment.rb is defined as a DSL. The layers will still be merged like so:

    .kubes/resources/base/all.yaml
    .kubes/resources/base/deployment.yaml
    .kubes/resources/web/deployment.rb
    .kubes/resources/web/deployment/dev.rb

## Resources Files

.kubes/resources/base/all.yaml

```yaml
metadata:
  namespace: demo-<%= Kubes.env %>
  labels:
    app: demo
```

.kubes/resources/base/deployment.yaml

```yaml
metadata:
  labels:
    app: demo
spec:
  selector:
    matchLabels:
      app: demo
  template:
    metadata:
      labels:
        app: demo
```

.kubes/resources/web/deployment.rb

```ruby
name "web"
labels(role: "web")
image "nginx"
```

.kubes/resources/web/deployment/dev.yaml

```yaml
spec:
  replicas: 2
```

## Output

The result is the merged layered files.

```yaml
metadata:
  namespace: demo-dev
  labels:
    app: demo
    role: web
  name: web
spec:
  selector:
    matchLabels:
      app: demo
      role: web
  template:
    metadata:
      labels:
        app: demo
        role: web
    spec:
      containers:
      - image: nginx
        name: web
  replicas: 2
apiVersion: apps/v1
kind: Deployment
```

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
kubes-0.8.9 docs/_docs/layering/mix.md
kubes-0.8.8 docs/_docs/layering/mix.md
kubes-0.8.7 docs/_docs/layering/mix.md
kubes-0.8.6 docs/_docs/layering/mix.md
kubes-0.8.5 docs/_docs/layering/mix.md
kubes-0.8.4 docs/_docs/layering/mix.md
kubes-0.8.3 docs/_docs/layering/mix.md
kubes-0.8.2 docs/_docs/layering/mix.md
kubes-0.8.1 docs/_docs/layering/mix.md
kubes-0.8.0 docs/_docs/layering/mix.md
kubes-0.7.10 docs/_docs/layering/mix.md
kubes-0.7.9 docs/_docs/layering/mix.md
kubes-0.7.8 docs/_docs/layering/mix.md
kubes-0.7.7 docs/_docs/layering/mix.md
kubes-0.7.6 docs/_docs/layering/mix.md
kubes-0.7.5 docs/_docs/layering/mix.md
kubes-0.7.4 docs/_docs/layering/mix.md
kubes-0.7.3 docs/_docs/layering/mix.md
kubes-0.7.2 docs/_docs/layering/mix.md
kubes-0.7.1 docs/_docs/layering/mix.md