Skip to content

Commit

Permalink
Make the sample based on docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
pchico83 committed May 12, 2021
1 parent 8d4710f commit 89d5b2a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 133 deletions.
130 changes: 4 additions & 126 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,129 +1,7 @@
# Getting Started with Okteto Stacks
# Getting Started with Docker Compose

This example shows how to leverage [Okteto](https://github.com/okteto/okteto) to develop an application using [Stacks](hhttps://okteto.com/docs/cloud/stacks#manifest-reference). Stacks are designed for developers that don't want to deal with the complexities of Kubernetes manifests or Helm charts.
[![Develop on Okteto](https://okteto.com/develop-okteto.svg)](https://cloud.okteto.com/deploy?repository=https://github.com/okteto/compose-getting-started)

## Prerequisites
This example shows how to use [Okteto](https://github.com/okteto/okteto) to deploy a Docker Compose application on Okteto Cloud.

- Install the Okteto CLI. Follow this [guide](https://okteto.com/docs/getting-started/installation) if you haven't done it yet.
- Access to a Kubernetes Cluster. You can also give [Okteto Cloud](https://okteto.com/) a try. Okteto Cloud is a development platform for Kubernetes applications. Free developer accounts come with 4GB of RAM, 2 CPUs, and 10GB Disk space.

## Deploy the Sample App

Get a local version of the Sample App by executing the following commands in your local terminal:

```console
$ git clone https://github.com/okteto/stacks-getting-started
$ cd stacks-getting-started
```

The Sample App is a simple web application implemented using Python, with Redis for storage.
The `okteto-stack.yml` file contains the [Stack manifest](https://okteto.com/docs/reference/stacks) of the Sample App.
Deploy the Sample App by executing:


```console
$ okteto stack deploy --wait
```

```console
✓ Successfully deployed stack 'voting-app'
```

> The [Stack CLI reference](https://okteto.com/docs/reference/cli#stack) explains the different `okteto stack` subcommands and options.
Check that all pods are ready by executing the command below:

```console
$ kubectl get pod
```

```console
NAME READY STATUS RESTARTS AGE
redis-0 1/1 Running 0 34s
vote-6f4b7f5756-4dr72 1/1 Running 0 35s
vote-6f4b7f5756-x6k7d 1/1 Running 0 35s
```

## Activate your development environment

Use `okteto up` to synchronize your local changes with your application by executing the following command:

```console
$ okteto up -f vote/okteto.yml
```

```console
✓ Development environment activated
✓ Files synchronized
Namespace: pchico83
Name: vote
Forward: 8080 -> 8080

* Serving Flask app "app" (lazy loading)
* Environment: development
* Debug mode: on
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 279-349-987
```

From this moment, every change you do from your local IDE will be immediately hot reloaded by your application running on Kubernetes:

```console
* Detected change in '/src/app.py', reloading
* Restarting with stat
* Debugger is active!
* Debugger PIN: 167-523-127
```

## Redeploy the Sample App

When you are done with your code changes, you can rebuild and redeploy your application by executing the following command:

```console
$ okteto stack deploy --build
```

```console
i Running your build in Okteto Cloud...
i Building image for service 'vote'...
[+] Building 4.2s (13/13) FINISHED
=> importing cache manifest from registry.cloud.okteto.net/pchico83/ vote:okteto 1.0s
=> [internal] load build definition from buildkit-630371997 0.4s
=> => transferring dockerfile: 524B 0.4s
=> [internal] load .dockerignore 0.3s
=> => transferring context: 2B 0.3s
=> [internal] load metadata for docker.io/library/python:3-slim 0.7s
=> [internal] load build context 0.6s
=> => transferring context: 6.04kB 0.6s
=> [1/6] FROM docker.io/library/python:3-slim@sha256:c0281d8fe99edff517fcc748f088bc51822ae660bac9e4aba76a81fa987fe9e8 0.0s
=> => resolve docker.io/library/python:3-slim@sha256:c0281d8fe99edff517fcc748f088bc51822ae660bac9e4aba76a81fa987fe9e8 0.0s
=> CACHED [2/6] WORKDIR /src 0.0s
=> CACHED [3/6] RUN pip install --upgrade pip 0.0s
=> CACHED [4/6] ADD requirements.txt requirements.txt 0.0s
=> CACHED [5/6] RUN pip install -r requirements.txt 0.0s
=> CACHED [6/6] ADD . /src 0.0s
=> exporting to image 1.8s
=> => exporting layers 0.0s
=> => exporting manifest sha256:23567b4fef520ef1fb356cacad163e019c06c5942a991fc76f12f0cbab7b3b3a 0.0s
=> => exporting config sha256:a424f508b9602ec44193c2c6408107d4d4c8f7f7eb71828c884a2c6feb574ea6 0.0s
=> => pushing layers 1.1s
=> => pushing manifest for registry.cloud.okteto.net/pchico83/vote:okteto 0.6s
=> exporting cache 0.2s
=> => preparing build cache for export 0.2s
✓ Image for service 'vote' successfully pushed
✓ Successfully deployed stack 'voting-app'
```

## Destroy the Sample App

Execute the command below to destroy the application from your Kubernetes cluster:

```console
$ okteto stack destroy
```

```console
✓ Successfully destroyed stack 'voting-app'
```
Follow the step by step tutorial in [this link](https://okteto.com/docs/tutorials/stacks-getting-started).
8 changes: 2 additions & 6 deletions okteto-stack.yml → docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: voting-app

services:
vote:
public: true
build: vote
replicas: 2
scale: 2
ports:
- 8080
- 8080:8080

redis:
image: redis
Expand All @@ -17,4 +14,3 @@ services:

volumes:
redis:
size: 1Gi
1 change: 1 addition & 0 deletions vote/.stignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
3 changes: 2 additions & 1 deletion vote/okteto.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: vote
workdir: /src
command: ["python", "app.py"]
environment:
- FLASK_ENV=development
sync:
- .:/src
forward:
- 8080:8080

0 comments on commit 89d5b2a

Please sign in to comment.