Sha256: f8aa75d45fa1fbc16c89a19bb7dbc26bf2191a63dd8a3e1832890e509ddff7c6

Contents?: true

Size: 1.39 KB

Versions: 37

Compression:

Stored size: 1.39 KB

Contents

---
title: Clock Web Worker Pattern
nav_text: Clock Web Worker
categories: patterns
---

A common pattern is to use the same code to run different types of processes like clock, web, worker. Kubes is flexible enough to support this pattern.

Note, often the clock process is also called a scheduler.

## Structure

Here's a structure that achieves this pattern with Kubes:

    .kubes/resources
    ├── clock
    │   └── deployment.rb
    ├── web
    │   ├── deployment.rb
    │   └── service.rb
    └── worker
        └── deployment.rb

## Source Code

.kubes/resources/demo-clock/deployment.rb

```ruby
name "demo-clock"
namespace "default"
labels(role: "web")

replicas 1
image docker_image # IE: user/demo-clock:kubes-2020-06-13T19-55-16-43afc6e
command "bin/clock"
```

.kubes/resources/web/deployment.rb

```ruby
name "demo-web"
namespace "default"
labels(role: "web")

replicas 1
image docker_image # IE: user/demo-clock:kubes-2020-06-13T19-55-16-43afc6e
```

.kubes/resources/demo-worker/deployment.rb

```ruby
name "demo-worker"
namespace "default"
labels(role: "web")

replicas 2
image docker_image # IE: user/demo-clock:kubes-2020-06-13T19-55-16-43afc6e
command "bin/worker"
```

## Deploy All-At-Once

To deploy all 3 process types:

    kubes deploy

## Deploy Selectively

To deploy selectively:

    kubes deploy clock
    kubes deploy web
    kubes deploy worker

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
kubes-0.9.3 docs/_docs/patterns/clock-web-worker.md
kubes-0.9.2 docs/_docs/patterns/clock-web-worker.md
kubes-0.9.1 docs/_docs/patterns/clock-web-worker.md
kubes-0.9.0 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.10 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.9 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.8 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.7 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.6 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.5 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.4 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.3 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.2 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.1 docs/_docs/patterns/clock-web-worker.md
kubes-0.8.0 docs/_docs/patterns/clock-web-worker.md
kubes-0.7.10 docs/_docs/patterns/clock-web-worker.md
kubes-0.7.9 docs/_docs/patterns/clock-web-worker.md
kubes-0.7.8 docs/_docs/patterns/clock-web-worker.md
kubes-0.7.7 docs/_docs/patterns/clock-web-worker.md
kubes-0.7.6 docs/_docs/patterns/clock-web-worker.md