This is a simple blockchain application implemented in Python. It allows you to create a blockchain network and add blocks to the chain. The application uses Docker for containerization and Kubernetes for deployment and management of the blockchain nodes.
Before running the blockchain application, make sure you have the following dependencies installed:
Docker: Install Docker
Kubernetes: Install Kubernetes
To containerize the blockchain application using Docker, follow these steps:
-
Clone this repository to your local machine.
-
Open a terminal and navigate to the project directory.
-
Build the Docker image by running the following command:
docker build -t blockchain-app:latest . -
Once the image is built, you can verify it by running:
docker images
To deploy the blockchain application using Kubernetes, follow these steps:
- Make sure you have a Kubernetes cluster set up and configured.
- Modify the
deployment.yamlfile:- Replace
<your-docker-registry>with the appropriate Docker registry where you intend to push your Docker image.
- Replace
- Apply the Kubernetes Deployment by running the following command:
kubectl apply -f deployment.yaml - Verify that the deployment is successful by checking the created pods:
kubectl get pods - Modify the
service.yamlfile if necessary (e.g., change theportortargetPort). - Apply the Kubernetes Service by running the following command:
kubectl apply -f service.yaml - Verify that the service is created and the application is accessible:
kubectl get services
Once the blockchain application is deployed, you can interact with it using the exposed API.
Here's an example using cURL:
- To add a block to the blockchain:
curl -X POST http://<service-ip>:<service-port>/blocks -d '{"data":"Block Data"}'
- To retrieve the entire blockchain:
curl http://<service-ip>:<service-port>/blocks
Note: Replace <service-ip> and <service-port> with the appropriate IP and port values of the Kubernetes service.
To clean up and remove the deployed blockchain application, run the following commands:
kubectl delete deployment blockchain-app-deployment
kubectl delete service blockchain-app-service
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.
This project is licensed under the Apache License - 2.0.