bhouse-nexthop opened a new issue, #14797:
URL: https://github.com/apache/cloudstack/issues/14797

   ### problem
   
   CKS add-node picks the new node's SSH port from the node count, not from the 
ports in use. After removing an added node that is not the last one, the next 
add-node picks a port a live node still uses, and the add fails on a rule 
conflict.
   
   In `KubernetesClusterAddWorker.validateAndSetupNode`:
   
   ```java
   int startSshPortNumber = CLUSTER_NODES_DEFAULT_START_SSH_PORT + (int) 
kubernetesCluster.getTotalNodeCount() - 
kubernetesCluster.getEtcdNodeCount().intValue();
   int sshStartPort = startSshPortNumber + nodeIndex;
   ```
   
   Example, 1 control + 2 workers (2222-2224):
   
   | step | node count | port picked | result |
   |---|---|---|---|
   | add A | 3 → 4 | 2225 | ok |
   | add B | 4 → 5 | 2226 | ok |
   | remove A | 5 → 4 | (2225 freed) | ok |
   | add C | 4 | 2226 | clash with B's rules |
   
   On an isolated network the firewall rule create fails (`The range specified, 
2226-2226, conflicts with rule ...`). On a VPC tier the PF rule is saved 
without a conflict check, so two PF rules share the port.
   
   ### versions
   
   4.22 and main (same code). Any CKS cluster that uses add-node / remove-node 
with external VMs.
   
   ### The steps to reproduce the bug
   
   1. Create a CKS cluster (1 control, 2 workers) on an isolated network.
   2. `addNodesToKubernetesCluster` with VM A, then with VM B.
   3. `removeNodesFromKubernetesCluster` with VM A.
   4. `addNodesToKubernetesCluster` with VM C: it fails on port 2226.
   
   ### What to do about it?
   
   Pick the lowest port from 2222 up that no rule on the cluster's public IP is 
using, so a gap left by a removed node is reused and live nodes' ports are 
never taken. Existing nodes keep their ports.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to