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

Add --no-extras flag to join command #425

Merged
merged 1 commit into from
Dec 29, 2023

Conversation

rgee0
Copy link
Contributor

@rgee0 rgee0 commented Dec 29, 2023

Why do you need this?

It was found that when joining servers to a cluster any additional servers would not honour the --no-extras flag used with the install command.

It is necessary, therefore, for the flag to be added to join and only be applied in situations where --server has been provided.

  • I have raised an issue to propose this change (required)

Although closed, #408 refers

Description

Adds --no-extras to the join command such that it will work when used with --server.

How Has This Been Tested?

Add new flag without --server

$ ./k3sup-darwin join \             
  --ip $SERVER_IP_2 \
  --user $USER \
  --server-user $USER \
  --server-ip $SERVER_IP \
  --no-extras --print-command

Error: --no-extras can only be used with --server

Add new flag with --server

 $ ./k3sup-darwin join \
  --ip $SERVER_IP_2 \
  --user $USER \
  --server-user $USER \
  --server-ip $SERVER_IP \
  --no-extras --print-command --server

Running: k3sup join
Joining 209.97.141.169 => 138.68.158.53
ssh: sudo cat /var/lib/rancher/k3s/server/node-token

Received node-token from 138.68.158.53.. ok.
ssh: curl -sfL https://get.k3s.io | K3S_URL='https://138.68.158.53:6443'  \
K3S_TOKEN='<token>::server:<alphanumeric>' \
INSTALL_K3S_CHANNEL='stable' \
INSTALL_K3S_EXEC='server --server https://138.68.158.53:6443' \
sh -s -  --disable servicelb --disable traefik

Note the addition of --disable servicelb --disable traefik to the output command

With --tls-san added as this was in the area of change:

$ ./k3sup-darwin join \
  --ip $SERVER_IP_2 \
  --user $USER \
  --server-user $USER \
  --server-ip $SERVER_IP \
  --no-extras --print-command --server  --tls-san 127.0.0.1
Running: k3sup join
Joining 209.97.141.169 => 138.68.158.53
ssh: sudo cat /var/lib/rancher/k3s/server/node-token

Received node-token from 138.68.158.53.. ok.
ssh: curl -sfL https://get.k3s.io | K3S_URL='https://138.68.158.53:6443' K3S_TOKEN='<alphanumeric>::server:<alphanumeric>' INSTALL_K3S_CHANNEL='stable' INSTALL_K3S_EXEC='server --server https://138.68.158.53:6443 --tls-san 127.0.0.1' sh -s -  --disable servicelb --disable traefik

With --tls-san and without --server:

./k3sup-darwin join \
  --ip $SERVER_IP_2 \
  --user $USER \
  --server-user $USER \
  --server-ip $SERVER_IP \
  --print-command  --tls-san 127.0.0.1 
Error: --tls-san can only be used with --server

Demonstrates previous behaviour unchanged

Additional Test case using --no-extras with --k3s-extra-args set:

  • Install the initial server with --cluster:
➜  bin git:(NoExtrasOnJoin) ./k3sup-darwin install --ip $SERVER_IP --user root --no-extras --cluster
Running: k3sup install
2023/12/30 12:12:18 165.232.97.194
Public IP: 165.232.97.194
[INFO]  ...
[INFO]  systemd: Starting k3s
  • Join the second server with --no-extras & --k3s-extra-args:
➜  bin git:(NoExtrasOnJoin) ./k3sup-darwin join \                                                
  --ip $SERVER_IP_2 \
  --user $USER \
  --server-user $USER \
  --server-ip $SERVER_IP \
  --print-command  \
  --server \
  --no-extras \
  --k3s-extra-args "--node-taint key=value:NoExecute"

Running: k3sup join
Joining 165.232.97.185 => 165.232.97.194
ssh: sudo cat /var/lib/rancher/k3s/server/node-token

Received node-token from 165.232.97.194.. ok.
ssh: curl -sfL https://get.k3s.io | \
K3S_URL='https://165.232.97.194:6443' \
K3S_TOKEN='<alphanumeric>::server:<alphanumeric>' \
INSTALL_K3S_CHANNEL='stable' \
INSTALL_K3S_EXEC='server --server https://165.232.97.194:6443' \
sh -s - --node-taint key=value:NoExecute --disable servicelb --disable traefik
[INFO]  ...
[INFO]  systemd: Starting k3s

Verify that the extra args have been appropriately concatenated within the print-command output.

  • Inspect the nodes and pods to check that the disable flags have been handled correctly:
➜  bin git:(NoExtrasOnJoin) export KUBECONFIG=<path>
➜  bin git:(NoExtrasOnJoin) kubectl config use-context default
Switched to context "default".
➜  bin git:(NoExtrasOnJoin) kubectl get node -o wide
NAME           STATUS   ROLES                       AGE     VERSION        INTERNAL-IP      EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME
k3s-up-do-01   Ready    control-plane,etcd,master   2m40s   v1.28.4+k3s2   165.232.97.194   <none>        Ubuntu 22.04.2 LTS   5.15.0-67-generic   containerd://1.7.7-k3s1
k3s-up-do-02   Ready    control-plane,etcd,master   39s     v1.28.4+k3s2   165.232.97.185   <none>        Ubuntu 22.04.2 LTS   5.15.0-67-generic   containerd://1.7.7-k3s1
➜  bin git:(NoExtrasOnJoin) kubectl get pods --all-namespaces                                    
NAMESPACE     NAME                                      READY   STATUS    RESTARTS   AGE
kube-system   coredns-6799fbcd5-ln52n                   1/1     Running   0          2m38s
kube-system   local-path-provisioner-84db5d44d9-wjwp4   1/1     Running   0          2m38s
kube-system   metrics-server-67c658944b-cxvjj           1/1     Running   0          2m38s
  • Finally check that the no-taint value provided in --k3-extra-args has also been applied:
➜  bin git:(NoExtrasOnJoin) kubectl get nodes -o json | jq '.items[].spec'

{
  "podCIDR": "10.42.0.0/24",
  "podCIDRs": [
    "10.42.0.0/24"
  ],
  "providerID": "k3s://k3s-up-do-01"
}
{
  "podCIDR": "10.42.1.0/24",
  "podCIDRs": [
    "10.42.1.0/24"
  ],
  "providerID": "k3s://k3s-up-do-02",
  "taints": [
    {
      "effect": "NoExecute",
      "key": "key",
      "value": "value"
    }
  ]
}

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

It was found that when joining servers to a cluster any additional servers
would not honour the `--no-extras` flag used with the install command.

It is necessary, therefore, for the flag to be added to `join` and only
be applied in situations where `--server` has been provided.

Signed-off-by: Richard Gee <[email protected]>
@rgee0 rgee0 marked this pull request as ready for review December 29, 2023 16:09
Copy link
Owner

@alexellis alexellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for helping to fix a confusing bug 👍

@alexellis alexellis merged commit d952d6d into alexellis:master Dec 29, 2023
1 check passed
@alexellis
Copy link
Owner

Could you check whether --no-extras gets correctly merged with anything passed via --k3s-extra-args?

@rgee0
Copy link
Contributor Author

rgee0 commented Dec 30, 2023

Could you check whether --no-extras gets correctly merged with anything passed via --k3s-extra-args?

Updated the test output above with Additional Test case using --no-extras with --k3s-extra-args set:

TL;DR is that it merges the values from the --no-extras flag correctly

@alexellis
Copy link
Owner

Thanks @rgee0

@alexellis alexellis changed the title Add --no-extra flag to join command Add --no-extras flag to join command Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants