-
Notifications
You must be signed in to change notification settings - Fork 229
USHIFT-5539: Use add-node in cncf conformance scenarios #5586
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a3c1bbd
USHIFT-5339: Add configure-node script for cncf conformance
pacevedom 62069b5
USHIFT-5339: Update bootc cncf conformance scenario
pacevedom 4ff200e
USHIFT-5339: Update ostree cncf conformance scenario
pacevedom 807048b
USHIFT-5339: Remove kubelet version rebase logic
pacevedom c27379b
USHIFT-5339: Update contributor docs
pacevedom 2ac6714
USHIFT-5339: Remove unused multinode configure scripts
pacevedom 16da7a2
USHIFT-5339: Remove KUBELET_HOME var from configure-node
pacevedom 7146ae8
USHIFT-5339: Use greenboot, optional arg to configure-node and drop-i…
pacevedom 137c14b
USHIFT-5339: Update configure-node command in scenarios
pacevedom 05d48c2
USHIFT-5339: Nits
pacevedom f9c9624
USHIFT-5339: Verify nits
pacevedom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # Variables for node configuration | ||
| NODE_ADDR="" | ||
| BOOTSTRAP_KUBECONFIG="" | ||
|
|
||
| function usage() { | ||
| echo "This script configures a node to run a MicroShift cluster." | ||
| echo "Optionally, it can also be used to configure MicroShift to join an existing cluster." | ||
| echo "Usage: $(basename "$0") [OPTIONS]" | ||
| echo "Options:" | ||
| echo " --bootstrap-kubeconfig PATH Path to kubeconfig file for joining existing cluster (optional)" | ||
| echo " -h, --help Show this help message" | ||
| exit 1 | ||
| } | ||
|
|
||
| function configure_system() { | ||
| # TODO: Edit firewall rules instead of stopping firewall | ||
| sudo systemctl stop firewalld | ||
| sudo systemctl disable firewalld | ||
|
|
||
| sudo systemctl stop greenboot-healthcheck | ||
| sudo systemctl reset-failed greenboot-healthcheck | ||
| sudo systemctl disable greenboot-healthcheck | ||
| } | ||
|
|
||
| function configure_microshift() { | ||
| # Clean the current MicroShift configuration and stop the service | ||
| echo 1 | sudo microshift-cleanup-data --all --keep-images | ||
|
|
||
| get_node_ip_from_config | ||
|
|
||
| # Configure MicroShift to disable telemetry | ||
| cat <<EOF | sudo tee /etc/microshift/config.d/multinode.yaml &>/dev/null | ||
| apiServer: | ||
| subjectAltNames: | ||
| - ${NODE_ADDR} | ||
| telemetry: | ||
| status: Disabled | ||
| EOF | ||
|
|
||
| sudo mkdir -p /etc/systemd/system/microshift.service.d | ||
| cat <<EOF | sudo tee /etc/systemd/system/microshift.service.d/multinode.conf &>/dev/null | ||
| [Service] | ||
| # Clear previous ExecStart, otherwise systemd would try to run both. | ||
| ExecStart= | ||
| ExecStart=microshift run --multinode | ||
| EOF | ||
| sudo systemctl daemon-reload | ||
| sudo systemctl enable microshift.service | ||
| } | ||
|
|
||
| function start_microshift() { | ||
| sudo systemctl start microshift.service | ||
| } | ||
|
|
||
| function run_add_node_commands() { | ||
| if ! sudo microshift add-node --kubeconfig="${BOOTSTRAP_KUBECONFIG}"; then | ||
| echo "Error: Failed to add node using kubeconfig: ${BOOTSTRAP_KUBECONFIG}" | ||
| exit 1 | ||
| fi | ||
| echo "Successfully added node using kubeconfig: ${BOOTSTRAP_KUBECONFIG}" | ||
| } | ||
|
|
||
| function get_node_ip_from_config() { | ||
| # Extract nodeIP from MicroShift running configuration and store in global variable | ||
| local node_ip="" | ||
|
|
||
| # Use microshift show-config to get the IP address of the node | ||
| node_ip=$(sudo microshift show-config 2>/dev/null | awk '/^\s*nodeIP\s*:/ {print $NF; exit}') | ||
|
|
||
| if [ -z "${node_ip}" ]; then | ||
| echo "Warning: nodeIP not found in MicroShift config" | ||
| exit 1 | ||
| fi | ||
|
|
||
| NODE_ADDR="${node_ip}" | ||
| } | ||
|
|
||
| function copy_bootstrap_kubeconfig() { | ||
| local kubeconfig_source="/var/lib/microshift/resources/kubeadmin/${NODE_ADDR}/kubeconfig" | ||
| local kubeconfig_dest="${HOME}/kubeconfig-bootstrap" | ||
|
|
||
| if ! sudo test -f "${kubeconfig_source}"; then | ||
| echo "Error: Kubeconfig file not found at ${kubeconfig_source}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if sudo cp "${kubeconfig_source}" "${kubeconfig_dest}"; then | ||
| sudo chown "$(whoami):" "${kubeconfig_dest}" | ||
| echo "Kubeconfig copied successfully to ${kubeconfig_dest}" | ||
| else | ||
| echo "Error: Failed to copy kubeconfig file" | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| function run_healthcheck() { | ||
| if ! sudo systemctl start greenboot-healthcheck; then | ||
| echo "Error: Failed to start greenboot-healthcheck service" | ||
| exit 1 | ||
| fi | ||
|
|
||
| greenboot_status=$(systemctl show -p Result --value greenboot-healthcheck) | ||
| if [ "${greenboot_status}" != "success" ]; then | ||
| echo "Error: greenboot-healthcheck did not complete successfully (Result: ${greenboot_status})" | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| # Parse command line arguments | ||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| --bootstrap-kubeconfig) | ||
| if [ $# -lt 2 ]; then | ||
| echo "Error: --bootstrap-kubeconfig requires an argument" | ||
| usage | ||
| fi | ||
| BOOTSTRAP_KUBECONFIG="$2" | ||
| shift 2 | ||
| ;; | ||
| -h|--help) | ||
| usage | ||
| ;; | ||
| *) | ||
| echo "Error: Unknown option '$1'" | ||
| usage | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| # Validate BOOTSTRAP_KUBECONFIG if provided | ||
| if [ -n "${BOOTSTRAP_KUBECONFIG}" ]; then | ||
| if [ ! -f "${BOOTSTRAP_KUBECONFIG}" ]; then | ||
| echo "Error: Bootstrap kubeconfig file '${BOOTSTRAP_KUBECONFIG}' does not exist" | ||
| exit 1 | ||
| fi | ||
| echo "Using bootstrap kubeconfig: ${BOOTSTRAP_KUBECONFIG}" | ||
| fi | ||
|
|
||
| configure_system | ||
| configure_microshift | ||
| if [ -n "${BOOTSTRAP_KUBECONFIG}" ]; then | ||
| run_add_node_commands | ||
| run_healthcheck | ||
| else | ||
| start_microshift | ||
| fi | ||
| echo | ||
| echo "Node configuration completed" | ||
| if [ -z "${BOOTSTRAP_KUBECONFIG}" ]; then | ||
| copy_bootstrap_kubeconfig | ||
| echo | ||
| echo "To add other nodes to this cluster, copy the following kubeconfig file to other nodes:" | ||
| echo " ${HOME}/kubeconfig-bootstrap" | ||
| echo | ||
| echo "Then run the following command on each node you want to add:" | ||
| echo " $(basename "$0") --bootstrap-kubeconfig /path/to/kubeconfig" | ||
| fi | ||
| echo "Done" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this would be clear. Looking at the invocs I'm missing a bit info whether I'm setting up a primary or adding (secondary) node - aka invocs are not clear at first glance, but maybe that's just me :)
Like
compared to something like (just thinking out loud, I don't expect it to be change to this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some help to the command.
Just calling the script without options means "configure this node to run MicroShift", while also allowing it to be prepared to add more nodes. This is implied by the location of the script (
scripts/multinode).Similar semantics with the
--bootstrap-kubeconfig, which implies there is another cluster (the kubeconfig) that you will be using to bootstrap this node into it. Also the help shows it.Keep in mind that this is all unsupported, so quite niche for now.