Giter Site home page Giter Site logo

dockerized_app's Introduction

Create a simple web application, Dockerize it, and run it on Minikube Kubernetes cluster.

This is a simple Python application that displays a welcome message.

image

Screenshot 2024-07-31 at 18 51 03

Dockerize the application:

Write a Dockerfile to containerize the application.

Build the Docker image and run it locally to ensure it works correctly.

Screenshot 2024-07-31 at 19 48 57

Docker ps

image

Tag it and Push the Docker image to a container registry (e.g., Docker Hub).

image

Running Container on Docker Desktop

image

Docker Inspect

image

Tag Image and push to Docker Hub with Link

https://hub.docker.com/layers/benn1440/python_app/Latest/images/sha256:1f4a2f43a5a2269bc46e280a5154e8eacd26d2271e2d50fea7fe371bd42bd55b?uuid=a6cfa028-74f7-47b1-8a34-2d8176dae4e3%0A

image

image

image

Deploy the application to a Kubernetes cluster:

  • Spin up Minikube for Local development

    image

  • Minikube was spinned up with docker driver

image

Create a Kubernetes manifest file for a Deployment to deploy the Docker image.

Deploy the app to minikube cluster

$ kubectl apply -f deployment.yaml

image

Kubectl describe deployment

$ kubectl describe deployment python-app-deployment

image

Errors and Troubleshooting

When I try to list the Pods created by the deployment, I noticed the pods were on ImagePullBackOff,

$ kubectl get pods -l app=python-app

image

To resolve this I had to check the Image name that was deployed and noticed a slight difference in the name

Screenshot 2024-07-31 at 21 23 00

Pod in running state after using the appropriate Image; changes were made on the deployment file and then redeployed.

image

Create a Kubernetes Service of type ClusterIP to expose the application.

$ kubectl get svc

image

Test the deployment:

  • Port-forward the service to a local host port and access it through a web browser.

    $ kubectl port-forward service/python-app-service 8080:80

Errors and Troubleshooting

When I copy the localhost port and input on the browser, the Pod lost connection and throws this error

image

To resolve this, I noticed that the target port on my deployment and service was different from the port my app was running (5500), this was corrected and the deployment and service were reapplied

$ kubectl apply -f deployment.yaml $ kubectl apply -f service.yaml

image

Verify that the application displays the expected message.

Application running on Port forwarded port

image

Implementing secrets

https://kubernetes.io/docs/concepts/configuration/secret/

dockerized_app's People

Contributors

benn1440 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.