This tutorial will show you how to develop an application using Okteto Stacks. Stacks are designed for developers who don't want to deal with the complexities of Kubernetes manifests or Helm charts.
- Install the Okteto CLI. Follow this guide if you haven't done it yet.
- Configure Access to your Okteto Cloud Namespace using the Okteto CLI or using the Okteto Cloud UI.
Step 1: Deploy the Sample App
Get a local version of the Sample App by executing the following commands:
$ 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.
okteto-stack.yml file contains the Stack manifest of the Sample App:
name: voting-appservices:vote:public: trueimage: okteto.dev/votebuild: votereplicas: 2ports:- 8080resources:cpu: 100mmemory: 128Miredis:image: redisports:- 6379resources:cpu: 100mmemory: 128Mistorage: 1Givolumes:- /data
The equivalent Kubernetes manifests would have more than 200 lines of yaml!
Deploying the Sample App is as simple as executing this command:
$ okteto stack deploy --build --wait
✓ Successfully deployed stack 'voting-app'
deploy command will create the necesary deployments, services, persistent volumes and ingress rules needed to run the Sample App. Cool no 😎?
Open your browser and go to the URL of the application. You can get the URL by logging into Okteto Cloud and clicking on the application's endpoint:
Step 2: Developing time!
Let's do some changes to our application. For example, open the
vote/app.py file in your IDE and modify the voting options on lines 16-17. Save your changes.
def getOptions():option_a = "Local development"option_b = "Cloud development"
Once you are happy with your changes, execute the following command:
$ okteto stack deploy --build
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:[email protected]:c0281d8fe99edff517fcc748f088bc51822ae660bac9e4aba76a81fa987fe9e8 0.0s=> => resolve docker.io/library/python:[email protected]: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'
okteto stack deploy --build automatically builds a new image tag using the Okteto Build Service, pushes it to the Okteto Registry and redeploys your application with the new image tag.
In a matter of seconds, your changes are running in the Cloud 💥!
Congratulations, you just developed your first application in Okteto Cloud 🚀.
Head over to our getting started guides for Go, ASP.NET, Java, Node.js, PHP, Python or Ruby to see how to configure Okteto to live-update your application with different programming languages and debuggers.