Exposing Minikube NodePort Ethernet Interface Visibility for Enterprise Project Prototyping with Hyperledger Fabric
In this article, we will discuss how to expose Hyperledger Fabric (HLF) services running on Minikube, focusing on the enterprise project prototype stage. We will cover key concepts related to Minikube, NodePort, and HLF network, providing detailed context and subtitles using H2, H3 tags, accompanied by paragraphs using
tags. Code blocks, when necessary, will be enclosed within tags with proper formatting and indentation.
Minikube NodePort Ethernet Interface Visibility
Minikube is a tool that makes it easy to run Kubernetes locally. One of its features is NodePort, which exposes a service on the cluster's nodes (i.e., minikube VM) on a static port. By default, the NodePort range is 30000-32767, but it can be changed by configuring the Kubernetes API server.
Understanding NodePort
NodePort is a type of Kubernetes service that exposes a service on each node in the cluster using a static port. With NodePort, you can access your service from outside the cluster by requesting : .
Minikube NodePort Configuration
To configure the NodePort range in Minikube, follow these steps:
- Stop Minikube:
minikube stop
- Edit the
kube-apiserver configuration file: vi ~/.kube/config
- Find the
--service-node-port-range parameter and change its value to the desired range, e.g., --service-node-port-range=35000-37000
- Save and exit the file
- Start Minikube:
minikube start
Hyperledger Fabric Network in Minikube
Hyperledger Fabric (HLF) is a blockchain framework for developing applications and solutions with a modular architecture. To test and prototype HLF networks, you can use Minikube to deploy and manage the network components.
HLF Network Components
HLF network components include:
- Ordering service: manages the delivery of blocks to peers
- Peers: endorse transactions, maintain the ledger, and validate transactions
- Chaincode: smart contract that contains the application logic
- Certificate Authority (CA): manages identities and issues certificates
- Channels: isolate network communication between different sets of organizations
Exposing HLF Services in Minikube
To expose HLF services (non-HTTP) running on Minikube NodePort, follow these steps:
- Deploy the HLF network components within Minikube
- Create a service for each HLF network component using NodePort
- Access the HLF network component using the NodePort IP and port
Example: Exposing an Ordering Service
Here's an example of how to expose an ordering service in HLF using Minikube NodePort:
- Create a YAML file to define the ordering service, e.g.,
ordering-service.yaml:
apiVersion: v1
kind: Service
metadata:
name: orderer-service
spec:
selector:
app: orderer
ports:
- name: orderer-nodeport
nodePort: 35001
port: 7050
targetPort: 7050
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: orderer-deployment
spec:
selector:
matchLabels:
app: orderer
replicas: 1
template:
metadata:
labels:
app: orderer
spec:
containers:
- name: orderer
image: hyperledger/fabric-orderer
ports:
- containerPort: 7050
Apply the YAML file to create the ordering service:
kubectl apply -f ordering-service.yaml
Access the ordering service using the NodePort:
minikube service orderer-service --url
In this article, we discussed how to expose HLF services using Minikube NodePort for enterprise project prototyping. We covered key concepts related to Minikube NodePort and HLF network, providing detailed context and examples to help you get started. To recap:
- Minikube is a tool for running Kubernetes locally, with NodePort as one of its features
- HLF is a blockchain framework for developing applications with modular architecture
- Exposing HLF services in Minikube requires deploying the network components and creating a service for each using NodePort
References
-
Minikube NodePort documentation: https://kubernetes.io/docs/concepts/services-networking/service/#nodeport
-
Hyperledger Fabric documentation: https://hyperledger-fabric.readthedocs.io/en/latest/