This example shows how to build and deploy a containerized python web server application using Opta.
This directory contains:
.
├── app.py # HTTP server implementation. It responds to all HTTP requests with a "Hello, World!" response.
├── Dockerfile # build the Docker image for the application
├── env-aws.yaml # opta environment file for AWS
├── env-azure.yaml # opta environment file for Azure
├── env-gcp.yaml # opta environment file for GCP
├── env-local.yaml # opta environment file for local
└── hello.yaml # opta service file
- Build the image
docker build . -t hello-app:v1
- Run the hello app
docker run -p 80:80 hello-app:v1 # or use a different port docker run -p 8080:8080 -e PORT=8080 hello-app:v1
- Test
curl http://localhost:80/hello
- Create the local kubernetes cluster
opta apply --local --auto-approve -c env-local.yaml
- Deploy the service
opta deploy --image hello-app:v1 --config hello.yaml --auto-approve --env local
- Test
curl http://localhost:8080/hello
- Clean up
opta destroy --auto-approve --local --config hello.yaml opta destroy --auto-approve --local --config env-local.yaml
- Select the target environment
# pick one export ENV=[aws/azure/gcp] # edit the env file to specify where to deploy (Account information) open env-${ENV}.yaml
- Create the environment infrastructure (VPC, Kubernetes...)
opta apply --auto-approve -c env-${ENV}.yaml # when done, find load_balancer_raw_dns or load_balancer_raw_ip in the output and save it export load_balancer=[Value from output]
- Deploy the service: push the image and deploy it to Kubernetes
opta deploy --image hello-app:v1 --config hello.yaml --auto-approve --env $ENV
- Test
curl http://${load_balancer}/hello # you can run any kubectl command at this point kubectl -n hello get all
- Clean up
opta destroy --auto-approve --config hello.yaml --env $ENV opta destroy --auto-approve --config env-${ENV}.yaml
For more guidance, please reach out to us in our slack channel.