main

2020/04/01

hands-on with Kubernetes

https://kubernetes.io/blog/2019/07/23/get-started-with-kubernetes-using-python/

FROM python:3.7

RUN mkdir /app
WORKDIR /app
ADD . /app/
RUN pip install -r requirements.txt

EXPOSE 5000
CMD ["python", "/app/main.py"]

  1. Get the official Python Base Image for version 3.7 from Docker Hub.
  2. In the image, create a directory named app.
  3. Set the working directory to that new app directory.
  4. Copy the local directory’s contents to that new folder into the image.
  5. Run the pip installer (just like we did earlier) to pull the requirements into the image.
  6. Inform Docker the container listens on port 5000.
  7. Configure the starting command to use when the container starts.

docker build -f Dockerfile -t hello-python:latest .
docker run -p 5001:5000 hello-python

Running in Kubernetes

install kubernetes,

brew install kubectl 

https://kubernetes.io/docs/tasks/tools/install-kubectl/

No comments:

Post a Comment

How to Supercharge Your Python Classes with Class Methods

  How to Supercharge Your Python Classes with Class Methods | by Siavash Yasini | May, 2024 | Towards Data Science As we just mentioned, a c...