Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control which kubernetes nodes chaincode runs on #228

Open
jt-nti opened this issue Dec 10, 2024 · 3 comments
Open

Control which kubernetes nodes chaincode runs on #228

jt-nti opened this issue Dec 10, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@jt-nti
Copy link
Member

jt-nti commented Dec 10, 2024

It may be desirable to control which kubernetes nodes chaincode runs on. For example, to use a pool of nodes specifically for running chaincode on, or to run the chaincode on the same node as the peer.

Covering all possible use cases is outside the scope of the k8s builder and should be handled with a Dynamic Admission Control using a Mutating Webhook. For example, it looks like the namespace-node-affinity webhook could be used to assign node affinity and tolerations to all pods in the FABRIC_K8S_BUILDER_NAMESPACE namespace.

Developing and deploying a webhook is not trivial though, so optionally adding basic affinity and toleration to chaincode pods may be useful for simple deployments. For example,

affinity:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
      – matchExpressions:
        – key: hlf-node-role/chaincode
          operator: Exists
tolerations:
- key: "hlf-node-role/chaincode"
  operator: "Exists"
  effect: "NoSchedule"

Chaincode nodes would then need a corresponding label and taint. For example,

kubectl label nodes node1 hlf-node-role/chaincode
kubectl taint nodes node1 hlf-node-role/chaincode:NoSchedule
@jt-nti jt-nti added the enhancement New feature or request label Dec 10, 2024
@davidfdr
Copy link
Contributor

Very nice upgrade!

@labibfarag
Copy link

labibfarag commented Dec 11, 2024

Also we have to consider that NOT all CC run on the same nodes ,
Example:
each orgs has a set of nodes ,
chaincodes for Org1 run on nodes managed by Org1 ex: node1,
chaincodes for Org2 run on nodes managed by Org2 ex: node2,

@jt-nti
Copy link
Member Author

jt-nti commented Dec 11, 2024

I think adding a new FABRIC_K8S_BUILDER_NODE_ROLE configuration option should work.

For example, in the simple case with the node role set to "chaincode" the following affinity and toleration would be added:

affinity:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
      - matchExpressions:
        - key: "fabric-builder-k8s-role"
          operator: In
          values:
          - "chaincode"
tolerations:
- key: "fabric-builder-k8s-role"
  operator: "Equal"
  value: "chaincode"
  effect: "NoSchedule"

Nodes with the matching label and taint should then be dedicated to running chaincode. For example:

kubectl label nodes node1 fabric-builder-k8s-role=chaincode
kubectl taint nodes node1 fabric-builder-k8s-role=chaincode:NoSchedule

To handle the case where you want different nodes running different chaincode, different node roles could be configured. For example, "org1cc", "org2cc", etc.

Does that sound ok?

jt-nti added a commit to jt-nti/fabric-builder-k8s that referenced this issue Dec 13, 2024
jt-nti added a commit to jt-nti/fabric-builder-k8s that referenced this issue Dec 16, 2024
jt-nti added a commit to jt-nti/fabric-builder-k8s that referenced this issue Dec 17, 2024
jt-nti added a commit to jt-nti/fabric-builder-k8s that referenced this issue Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants