Skip to content

Commit

Permalink
Merge "[CE-487] support Fabric 1.2 on K8s agent"
Browse files Browse the repository at this point in the history
  • Loading branch information
yeasy authored and Gerrit Code Review committed Nov 1, 2018
2 parents 316c554 + 77736ae commit 48ce48f
Show file tree
Hide file tree
Showing 707 changed files with 9,193 additions and 2,604 deletions.
2 changes: 1 addition & 1 deletion scripts/worker_node/download_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function downloadImages() {

IMG_TAG=$5
echo_b "Downloading and retag images for kafka/zookeeper separately, as their img_tag format is different"
for IMG in kafka zookeeper; do
for IMG in kafka zookeeper couchdb; do
HLF_IMG=hyperledger/fabric-${IMG}
if [ -z "$(docker images -q ${HLF_IMG}:${HLF_VERSION} 2> /dev/null)" ]; then # not exist
docker pull ${HLF_IMG}:$ARCH-$IMG_TAG
Expand Down
15 changes: 10 additions & 5 deletions src/agent/k8s/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def create(self, cid, mapped_ports, host, config, user_id):
containers = operation.deploy_cluster(cluster_name,
ports_index,
nfsServer_ip,
consensus)
consensus,
config.get('network_type'))
except Exception as e:
logger.error("Failed to create Kubernetes Cluster: {}".format(e))
return None
Expand All @@ -79,7 +80,8 @@ def delete(self, cid, worker_api, config):
operation.delete_cluster(cluster_name,
ports_index,
nfsServer_ip,
consensus)
consensus,
config.get('network_type'))

# delete ports for clusters
cluster_ports = ServicePort.objects(cluster=cluster)
Expand Down Expand Up @@ -123,13 +125,15 @@ def start(self, name, worker_api, mapped_ports, log_type, log_level,
operation = K8sClusterOperation(kube_config)
cluster_name = self.trim_cluster_name(cluster_name)
containers = operation.start_cluster(cluster_name, ports_index,
nfsServer_ip, consensus)
nfsServer_ip, consensus,
config.get('network_type'))

if not containers:
logger.warning("failed to start cluster={}, stop it again."
.format(cluster_name))
operation.stop_cluster(cluster_name, ports_index,
nfsServer_ip, consensus)
nfsServer_ip, consensus,
config.get('network_type'))
return None

service_urls = self.get_services_urls(name)
Expand Down Expand Up @@ -159,7 +163,8 @@ def stop(self, name, worker_api, mapped_ports, log_type, log_level,
operation.stop_cluster(cluster_name,
ports_index,
nfsServer_ip,
consensus)
consensus,
config.get('network_type'))

cluster_ports = ServicePort.objects(cluster=cluster)
for ports in cluster_ports:
Expand Down
132 changes: 94 additions & 38 deletions src/agent/k8s/cluster_operations.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
---
################################################################################
#
# 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:
- orderer0: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:
- kafka0:9092
- kafka1:9092
- kafka2:9092

# Organizations is the list of orgs which are defined as participants on
# the orderer side of the network
Organizations:
- *OrdererOrg
################################################################################
#
# 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:
- *Org1
- *Org2
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# ---------------------------------------------------------------------------
# "OrdererOrgs" - Definition of organizations managing orderer nodes
# ---------------------------------------------------------------------------
OrdererOrgs:
# ---------------------------------------------------------------------------
# Orderer
# ---------------------------------------------------------------------------
- Name: orderer
Domain: example.com
# ---------------------------------------------------------------------------
# "Specs" - See PeerOrgs below for complete description
# ---------------------------------------------------------------------------
Specs:
- Hostname: orderer
SANS:
- orderer0

# ---------------------------------------------------------------------------
# "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
# ---------------------------------------------------------------------------
Specs:
- Hostname: peer0
SANS:
- peer0-org1
- Hostname: peer1
SANS:
- peer1-org1
# 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
Specs:
- Hostname: peer0
SANS:
- peer0-org2
- Hostname: peer1
SANS:
- peer1-org2
Users:
Count: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgH8cgUJX3szzaugqX
b6VHJ52VaQeD4/2M1GVrVEPzwKahRANCAAQQhlRDM3EDZwjvjlQ2nR2QPYVFk8Nk
IUtDMVgbEfVUnRJx9h8LSVFzBqMgU01XaiDFQt6KZ6jT/AbuFel/sq/0
-----END PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----BEGIN CERTIFICATE-----
MIICLzCCAdWgAwIBAgIQd3mpED9jN9D7lOpFbn1hSzAKBggqhkjOPQQDAjBpMQsw
CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy
YW5jaXNjbzEUMBIGA1UEChMLZXhhbXBsZS5jb20xFzAVBgNVBAMTDmNhLmV4YW1w
bGUuY29tMB4XDTE4MTAyNzEwMDY1MloXDTI4MTAyNDEwMDY1MlowaTELMAkGA1UE
BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lz
Y28xFDASBgNVBAoTC2V4YW1wbGUuY29tMRcwFQYDVQQDEw5jYS5leGFtcGxlLmNv
bTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABBCGVEMzcQNnCO+OVDadHZA9hUWT
w2QhS0MxWBsR9VSdEnH2HwtJUXMGoyBTTVdqIMVC3opnqNP8Bu4V6X+yr/SjXzBd
MA4GA1UdDwEB/wQEAwIBpjAPBgNVHSUECDAGBgRVHSUAMA8GA1UdEwEB/wQFMAMB
Af8wKQYDVR0OBCIEICdkGEO52bmFLiJ65hiN9z/wJ2WIvgUt0tPe174XRPwUMAoG
CCqGSM49BAMCA0gAMEUCIQD1RsB94DWeHUOxF9yQbL6gJsJWB/abvgsmlkIad3qR
QQIgQ2FvByjKLUI0rHhClVFptZSua9zmo8BI1FuCcEdD40g=
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-----BEGIN CERTIFICATE-----
MIICCzCCAbGgAwIBAgIRAPeOvjB+yUG/vGYbsHXu09wwCgYIKoZIzj0EAwIwaTEL
MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG
cmFuY2lzY28xFDASBgNVBAoTC2V4YW1wbGUuY29tMRcwFQYDVQQDEw5jYS5leGFt
cGxlLmNvbTAeFw0xODEwMjcxMDA2NTJaFw0yODEwMjQxMDA2NTJaMFYxCzAJBgNV
BAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNp
c2NvMRowGAYDVQQDDBFBZG1pbkBleGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqG
SM49AwEHA0IABOOVCsMSTNLLC2iBaXxYQygRYAwf4LUClr1PZXHa5lnOLMLOJpkT
GipvuxUh7riVEsefW+7dNLyYW3gwRF8RU/WjTTBLMA4GA1UdDwEB/wQEAwIHgDAM
BgNVHRMBAf8EAjAAMCsGA1UdIwQkMCKAICdkGEO52bmFLiJ65hiN9z/wJ2WIvgUt
0tPe174XRPwUMAoGCCqGSM49BAMCA0gAMEUCIQC1TPX5A9rF7ZoalJG8o1lxCbcf
WcnVAp2bxaDEyMJEVwIgYbkzjAYT3ZjPQr0Zwc1sySeV6ue6l91+I32qhe9239Y=
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----BEGIN CERTIFICATE-----
MIICLzCCAdWgAwIBAgIQd3mpED9jN9D7lOpFbn1hSzAKBggqhkjOPQQDAjBpMQsw
CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy
YW5jaXNjbzEUMBIGA1UEChMLZXhhbXBsZS5jb20xFzAVBgNVBAMTDmNhLmV4YW1w
bGUuY29tMB4XDTE4MTAyNzEwMDY1MloXDTI4MTAyNDEwMDY1MlowaTELMAkGA1UE
BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lz
Y28xFDASBgNVBAoTC2V4YW1wbGUuY29tMRcwFQYDVQQDEw5jYS5leGFtcGxlLmNv
bTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABBCGVEMzcQNnCO+OVDadHZA9hUWT
w2QhS0MxWBsR9VSdEnH2HwtJUXMGoyBTTVdqIMVC3opnqNP8Bu4V6X+yr/SjXzBd
MA4GA1UdDwEB/wQEAwIBpjAPBgNVHSUECDAGBgRVHSUAMA8GA1UdEwEB/wQFMAMB
Af8wKQYDVR0OBCIEICdkGEO52bmFLiJ65hiN9z/wJ2WIvgUt0tPe174XRPwUMAoG
CCqGSM49BAMCA0gAMEUCIQD1RsB94DWeHUOxF9yQbL6gJsJWB/abvgsmlkIad3qR
QQIgQ2FvByjKLUI0rHhClVFptZSua9zmo8BI1FuCcEdD40g=
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----BEGIN CERTIFICATE-----
MIICNjCCAdygAwIBAgIRAO9eQIvFWTVu6P3wG7qyxwMwCgYIKoZIzj0EAwIwbDEL
MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG
cmFuY2lzY28xFDASBgNVBAoTC2V4YW1wbGUuY29tMRowGAYDVQQDExF0bHNjYS5l
eGFtcGxlLmNvbTAeFw0xODEwMjcxMDA2NTJaFw0yODEwMjQxMDA2NTJaMGwxCzAJ
BgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJh
bmNpc2NvMRQwEgYDVQQKEwtleGFtcGxlLmNvbTEaMBgGA1UEAxMRdGxzY2EuZXhh
bXBsZS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQVkav3qnUaq2sT5fXa
w7PC66C1tNvm0JEp8BnNrNa9FTqHve8J39rpLim7axRtVJgH0pp/n91Gc9Xzs3Lc
Wuj9o18wXTAOBgNVHQ8BAf8EBAMCAaYwDwYDVR0lBAgwBgYEVR0lADAPBgNVHRMB
Af8EBTADAQH/MCkGA1UdDgQiBCBAi+/AxDDh3cwnuAXW3vuXv4wjqV30WOuBa6Sh
mD8jYjAKBggqhkjOPQQDAgNIADBFAiEAj8nHgKRVcScP5atiRilix5AULPsxEcLx
tkazxYlUqb0CIHuBnz2s+DCiAfvQyBgsN6vUzoFfwylS3+e7o/sgpU3R
-----END CERTIFICATE-----
Binary file not shown.
Loading

0 comments on commit 48ce48f

Please sign in to comment.