A very basic flask web service to test running containers on any container orchestration platforms.
988
This is a very basic flask web service to test running containers on any container orchestration platforms such as AWS EKS, AWS ECS, Azure AKS etc.
The following is used to build this container image, so feel free to build your own.
Dockerfile
FROM --platform=linux/amd64 python:3.10-alpine
ARG PORT=8000
WORKDIR /app
RUN pip3 install flask
COPY . /app
ENTRYPOINT ["python3"]
CMD ["app.py"]
ENV PORT ${PORT}
EXPOSE ${PORT}
app.py
from flask import Flask
import os
app = Flask(__name__)
# Variable testing
HOSTNAME = os.getenv('HOSTNAME')
APP_VAR_1 = os.getenv('APP_VAR_1', 'N/A')
APP_VAR_2 = os.getenv('APP_VAR_2', 'N/A')
APP_VAR_3 = os.getenv('APP_VAR_3', 'N/A')
@app.route('/')
def hello():
all_vars = {
'Hostname': HOSTNAME,
'APP_VAR_1': APP_VAR_1,
'APP_VAR_2': APP_VAR_2,
'APP_VAR_3': APP_VAR_3
}
return f"Hello World! Following are some info for testing:\n{json.dumps(all_vars, indent=4)}"
if __name__ == '__main__':
app.run(host='0.0.0.0', port=os.getenv('PORT'))
An example of running the service in Kubernetes and accessing it via an endpoint service.
$ curl http://flask-service.prod.svc.cluster.local:8000
Hello World! I am sample-flask-xxx-yyy!!!
Content type
Image
Digest
sha256:5dc98decd…
Size
22.9 MB
Last updated
almost 3 years ago
docker pull 88lexd/sample-flask