Skip to content

rajeev3012/python-docker-k8s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python-Docker-K8s

  • Containerization & Orchestration: Containerized Python Flask application using Docker, published to DockerHub and deployed it on Kubernetes cluster using manifest files.
  • Version Control: Implemented version control and facilitated collaboration by uploading project code to GitHub.

Step-by-step commands followed during the implementation:

-- Docker --

  • Containerize the python application:

1. Build docker image:

	docker build -t python-app .

2. Run container:

	docker run -d -p 5000:5000 my-python-app

3. Show images:

	docker images

4. Show containers (including stopped):

	docker ps -a

DockerHub

  • Upload the built image to docker Hub:

1. First login to docker hub:

	docker login -u rajeev3012

2. Tag the image with your docker hub username:

	docker tag my-python-app rajeev3012/python-app

3. Push

	docker push rajeev3012/python-app

Cleanup:

1. Stop running container:

	docker stop <container>

2. Remove container:

	docker rm <container>

3. Remove image:

	docker rmi <image>

-- Kubernetes --

1. Deploy resources:

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

2. Show deployed resources:

	kubectl get all
	kubectl get pods

3. Access the app:

	minikube service python-app-service

4. Delete

	kubectl delete all --all
	kubectl delete pods -l app=python-app    (-l: label containing "python-app")
	kubectl delete pod python-app-123 --grace-period=0 --force    (force delete)

-- GitHub --

1. Initialize git:

	git init 

2. Create and checkout to main branch (by default it may be master):

	git checkout -b main 

3. Check files:

	git status 

4. Add to staging area:

	git add . 

5. Add commit with message:

	git commit -am "initial commit" 

6. Add GitHub remote repo:

	git remote add origin https://github.com/rajeev3012/python-docker-k8s.git 

7. Fetch and merge latest change to local first:

	git pull origin main --rebase 

8. Finally push changes to remote repo:

	git push -u origin main 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages