Skip to content

Commit

Permalink
[CE-96] Debugging Scripts and manifests
Browse files Browse the repository at this point in the history
Added Kube-Dns settings and Nginx conf files,
which will create a proxy for Kube-Dns which
later can be added to Docker-DNS to support
chaincode-container to peer-pod communication.

Signed-off-by: Nikhil Chawla <[email protected]>

Change-Id: I754c47a8e65e3fbe0c8907efc0254e1c9f9e0e3e
Signed-off-by: Nikhil Chawla <[email protected]>
  • Loading branch information
chawlanikhil24 committed Aug 26, 2017
1 parent 6991d68 commit ee4ca22
Show file tree
Hide file tree
Showing 19 changed files with 1,123 additions and 36 deletions.
52 changes: 52 additions & 0 deletions src/agent/k8s/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

# Copyright IBM Corp., All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

##This part of Cello deploys **Fabric over Kubernetes**
---
Note: This guide assumes that you already have running Kubernetes Cluster with a master and n-minions.

###--Steps to Deploy--

1. Prepare crypto-config.yaml and configtx.yaml in "driving-files" Directory.

2. Run "generateArtifacts.sh" script in "driving-files" directory to create "orderer.genesis.block"
```
$ cd driving-files
$ bash generateArtifacts.sh <channel-name>
note: If you don't wish to provide a channel-name, then
by default, genesis block will be created for a channel name "mychannel"
```
3. Now, all the artifacts are generated, finally run:
```$ bash prepare-files.sh```
4. Now, Copy "driving-files" directory to all the nodes, i.e.
Master along with all the Minions.
5. On Master, run "run.sh"
```$ bash run.sh```
6. Now, Kube-DNS and Nginx Stream Proxy has been setted up.
7. Setting up the environment variables
```$ export NGINX_PROXY_DNS=<your master-node ip-address>```
8. Add this setting to Docker running on all nodes
``` Environment=DOCKER_OPT_DNS=--dns=<Master node IP-address>
ExecStart=/usr/bin/dockerd -H fd:// \
$DOCKER_OPTS $DOCKER_OPT_BIP $DOCKER_OPT_MTU \
$DOCKER_OPT_DNS
```

9. Now, time to restart the docker daemon
```$ systemctl daemon-reload && systemctl restart docker```

10. Deploy the cluster
```$ bash run deploy.sh```

<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
27 changes: 27 additions & 0 deletions src/agent/k8s/cluster-Down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

#!/usr/bin/env bash

# Copyright IBM Corp., All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

#This is a one step script to delete all the deployment and
#services executed during the execution of the cluster

kubectl delete deployment hyperledger-fabric-ca
kubectl delete deployment hyperledger-fabric-cli
kubectl delete deployment hyperledger-orderer
kubectl delete deployment hyperledger-peer0-org1
kubectl delete deployment hyperledger-peer0-org2
kubectl delete deployment hyperledger-peer1-org1
kubectl delete deployment hyperledger-peer1-org2

kubectl delete svc orderer-service
kubectl delete svc peer0-org1
kubectl delete svc peer1-org1
kubectl delete svc peer0-org2
kubectl delete svc peer1-org2
kubectl delete svc ca

echo "CLUSTER Down Completed"
39 changes: 39 additions & 0 deletions src/agent/k8s/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

#!/usr/bin/env bash

# Copyright IBM Corp., All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

#comment this if you don't want to use the default CHANNEL_NAME "mychannel"
#to create your channel, mannually run:

# bash generateArtifacts.sh <CHANNEL_NAME>
bash driving-files/generateArtifacts.sh

bash driving-files/prepare-files.sh


echo "Deploying ca"
kubectl create -f local/ca.yaml
sleep 5

echo "Deploying orderer"
kubectl create -f local/orderer.yaml
sleep 5


echo "Deploying Peer0"
kubectl create -f local/peer0.yaml
sleep 5

echo "Deploying rest of the Peers"
kubectl create -f local/peer1.yaml -f local/peer2.yaml -f local/peer3.yaml

sleep 5

echo "Deploying Cli"
kubectl create -f local/cli.yaml

echo "**********Deployment done successfully**********"
180 changes: 180 additions & 0 deletions src/agent/k8s/driving-files/configtx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
---
################################################################################
#
# Profile
#
# - Different configuration profiles may be encoded here to be specified
# as parameters to the configtxgen tool
#
################################################################################
Profiles:

TwoOrgsOrdererGenesis:
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
TwoOrgsChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2

################################################################################
#
# Section: Organizations
#
# - This section defines the different organizational identities which will
# be referenced later in the configuration.
#
################################################################################
Organizations:

# SampleOrg defines an MSP using the sampleconfig. It should never be used
# in production but may be used as a template for other definitions
- &OrdererOrg
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: OrdererOrg

# ID to load the MSP definition as
ID: OrdererMSP

# MSPDir is the filesystem path which contains the MSP configuration
MSPDir: crypto-config/ordererOrganizations/example.com/msp

# BCCSP (Blockchain crypto provider): Select which crypto implementation or
# library to use
# BCCSP:
# Default: SW
# SW:
# Hash: SHA2
# Security: 256
# # Location of Key Store. If this is unset, a location will
# # be chosen using 'MSPDir'/keystore
# FileKeyStore:
# KeyStore:

- &Org1
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org1MSP

# ID to load the MSP definition as
ID: Org1MSP

MSPDir: crypto-config/peerOrganizations/org1.example.com/msp

# BCCSP (Blockchain crypto provider): Select which crypto implementation or
# library to use
# BCCSP:
# Default: SW
# SW:
# Hash: SHA2
# Security: 256
# # Location of Key Store. If this is unset, a location will
# # be chosen using 'MSPDir'/keystore
# FileKeyStore:
# KeyStore:

AnchorPeers:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer0-org1
Port: 7051

- &Org2
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org2MSP

# ID to load the MSP definition as
ID: Org2MSP

MSPDir: crypto-config/peerOrganizations/org2.example.com/msp

# BCCSP (Blockchain crypto provider): Select which crypto implementation or
# library to use
# BCCSP:
# Default: SW
# SW:
# Hash: SHA2
# Security: 256
# # Location of Key Store. If this is unset, a location will
# # be chosen using 'MSPDir'/keystore
# FileKeyStore:
# KeyStore:

AnchorPeers:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer0-org2
Port: 7051

################################################################################
#
# SECTION: Orderer
#
# - This section defines the values to encode into a config transaction or
# genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults

# Orderer Type: The orderer implementation to start
# Available types are "solo" and "kafka"
OrdererType: solo

Addresses:
- orderer-service:7050

# Batch Timeout: The amount of time to wait before creating a batch
BatchTimeout: 2s

# Batch Size: Controls the number of messages batched into a block
BatchSize:

# Max Message Count: The maximum number of messages to permit in a batch
MaxMessageCount: 10

# Absolute Max Bytes: The absolute maximum number of bytes allowed for
# the serialized messages in a batch.
AbsoluteMaxBytes: 99 MB

# Preferred Max Bytes: The preferred maximum number of bytes allowed for
# the serialized messages in a batch. A message larger than the preferred
# max bytes will result in a batch larger than preferred max bytes.
PreferredMaxBytes: 512 KB

Kafka:
# Brokers: A list of Kafka brokers to which the orderer connects
# NOTE: Use IP:port notation
Brokers:
- 127.0.0.1:9092

# Organizations is the list of orgs which are defined as participants on
# the orderer side of the network
Organizations:

################################################################################
#
# SECTION: Application
#
# - This section defines the values to encode into a config transaction or
# genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults

# Organizations is the list of orgs which are defined as participants on
# the application side of the network
Organizations:
76 changes: 76 additions & 0 deletions src/agent/k8s/driving-files/crypto-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# ---------------------------------------------------------------------------
# "OrdererOrgs" - Definition of organizations managing orderer nodes
# ---------------------------------------------------------------------------
OrdererOrgs:
# ---------------------------------------------------------------------------
# Orderer
# ---------------------------------------------------------------------------
- Name: orderer
Domain: example.com
# ---------------------------------------------------------------------------
# "Specs" - See PeerOrgs below for complete description
# ---------------------------------------------------------------------------
Specs:
- Hostname: orderer
# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
# ---------------------------------------------------------------------------
# Org1
# ---------------------------------------------------------------------------
- Name: Org1
Domain: org1.example.com
# ---------------------------------------------------------------------------
# "Specs"
# ---------------------------------------------------------------------------
# Uncomment this section to enable the explicit definition of hosts in your
# configuration. Most users will want to use Template, below
#
# Specs is an array of Spec entries. Each Spec entry consists of two fields:
# - Hostname: (Required) The desired hostname, sans the domain.
# - CommonName: (Optional) Specifies the template or explicit override for
# the CN. By default, this is the template:
#
# "{{.Hostname}}.{{.Domain}}"
#
# which obtains its values from the Spec.Hostname and
# Org.Domain, respectively.
# ---------------------------------------------------------------------------
# Specs:
# - Hostname: foo # implicitly "foo.org1.example.com"
# CommonName: foo27.org5.example.com # overrides Hostname-based FQDN set above
# - Hostname: bar
# - Hostname: baz
# ---------------------------------------------------------------------------
# "Template"
# ---------------------------------------------------------------------------
# Allows for the definition of 1 or more hosts that are created sequentially
# from a template. By default, this looks like "peer%d" from 0 to Count-1.
# You may override the number of nodes (Count), the starting index (Start)
# or the template used to construct the name (Hostname).
#
# Note: Template and Specs are not mutually exclusive. You may define both
# sections and the aggregate nodes will be created for you. Take care with
# name collisions
# ---------------------------------------------------------------------------
Template:
Count: 2
# Start: 5
# Hostname: {{.Prefix}}{{.Index}} # default
# ---------------------------------------------------------------------------
# "Users"
# ---------------------------------------------------------------------------
# Count: The number of user accounts _in addition_ to Admin
# ---------------------------------------------------------------------------
Users:
Count: 1
# ---------------------------------------------------------------------------
# Org2: See "Org1" for full specification
# ---------------------------------------------------------------------------
- Name: Org2
Domain: org2.example.com
Template:
Count: 2
Users:
Count: 1
Loading

0 comments on commit ee4ca22

Please sign in to comment.