šŸ¶
Kubernetes

Find kubeadm join command on master node

By Jan on 02/09/2025

Learn how to easily locate the kubeadm join command on your Kubernetes master node for adding worker nodes to your cluster.

Find kubeadm join command on master node

Table of Contents

Introduction

To add a new node to your Kubernetes cluster, you'll need a special join command from your master node. This command contains a unique token that acts like a key, allowing the new node to securely join the cluster. Here's how to get and use this join command:

Step-by-Step Guide

To join a node to your Kubernetes cluster, you'll need the join command generated on your master node. Here's how to get it:

1. On your master node:

kubeadm token create --print-join-command

This command does two things:

  • Creates a new token: This token acts as a key for the node to join the cluster.
  • Prints the join command: This command, including the generated token, is what you'll use on the node you want to join.

2. Copy the entire join command output.

3. On the node you want to join:

  • Paste and run the copied join command.

This process ensures secure communication and authentication between the new node and your existing Kubernetes cluster.

Code Example

This guide explains how to add a new node to an existing Kubernetes cluster. On the master node, generate a join command using 'kubeadm token create --print-join-command'. Copy the entire command output. On the node you want to add, paste and run the copied join command. Ensure the new node can communicate with the master node and that the master node was previously set up with 'kubeadm init'. This process securely integrates the new node into your cluster.

This example demonstrates how to join a node to your Kubernetes cluster.

1. On your master node:

kubeadm token create --print-join-command

This command will output something similar to:

kubeadm join <master-node-ip>:<port> --token <token> \
    --discovery-token-ca-cert-hash sha256:<hash> 

2. Copy the entire join command output.

3. On the node you want to join:

  • Paste and run the copied join command. For example:
kubeadm join 192.168.0.100:6443 --token abcdef.0123456789abcdef \
    --discovery-token-ca-cert-hash sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef 

Important Notes:

  • Replace <master-node-ip>, <port>, <token>, and <hash> with the actual values from your output.
  • Ensure the joining node has network connectivity to the master node on the specified port.
  • This process assumes you have already set up your Kubernetes master node using kubeadm init.

This process securely adds the new node to your cluster, allowing it to participate in the Kubernetes environment.

Additional Notes

  • Token Expiration: The generated token might have an expiration time. If the token expires, you'll need to generate a new one on the master node.
  • Token Uses: You can specify how many times a token can be used with the --usages flag when creating it.
  • Existing Tokens: You can list existing tokens and their details using kubeadm token list.
  • Deleting Tokens: Remove unused tokens with kubeadm token delete <token>.
  • Security: Keep the join command and token confidential. Anyone with access to it can potentially join a node to your cluster.
  • Network Requirements: Ensure the joining node can reach the master node on the specified port (default 6443) and resolve its hostname or IP address.
  • Firewall Rules: Configure firewalls on both the master and joining nodes to allow the necessary traffic for Kubernetes communication.
  • Cloud Environments: When working in cloud environments, ensure the necessary network settings and security groups are configured to allow communication between the master and joining nodes.
  • Troubleshooting: If the join process fails, check the logs on both the master and joining nodes for error messages. The kubelet logs on the joining node are particularly helpful for debugging join issues.

Summary

Step Action Description
1. On Master Node Run: kubeadm token create --print-join-command * Generates a unique token: Acts as a key for the joining node.
* Prints the join command: Includes the generated token.
2. On Master Node Copy the entire join command output.
3. On Joining Node Paste and run the copied join command. This securely adds the node to the cluster.

Conclusion

Joining nodes to your Kubernetes cluster is a fundamental process, made simple and secure with kubeadm. By generating a join command on the master node and executing it on the node you wish to add, you can easily expand your cluster's resources and capabilities. Remember to pay attention to security best practices, such as keeping tokens confidential and configuring firewalls appropriately. With a solid understanding of these steps, you'll be well-equipped to manage and scale your Kubernetes cluster effectively.

References

Were You Able to Follow the Instructions?

šŸ˜Love it!
šŸ˜ŠYes
šŸ˜Meh-gical
šŸ˜žNo
šŸ¤®Clickbait