{"id":24886501,"url":"https://github.com/rspatel031/k8s-cluster-setup","last_synced_at":"2026-05-05T22:36:59.770Z","repository":{"id":273980569,"uuid":"921324388","full_name":"rspatel031/k8s-cluster-setup","owner":"rspatel031","description":"Step-by-step guide to set up a Kubernetes (K8s) cluster on Ubuntu, including configuring containerd, installing Kubernetes components, and deploying Weave Net as the network plugin. Perfect for developers and DevOps engineers looking to deploy containerized applications efficiently.","archived":false,"fork":false,"pushed_at":"2025-01-26T06:48:38.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T15:15:17.830Z","etag":null,"topics":["calico","containerd","control-plane","etcd","flannel","kube-apiserver","kube-controller-manager","kube-scheduler","kubeadm","kubectl","kubelet","kubernetes","kubernetes-cluster","weavenet","worker-node"],"latest_commit_sha":null,"homepage":"https://medium.com/@rspatel031/how-to-set-up-a-kubernetes-k8s-cluster-on-ubuntu-a-complete-guide-f96cdea28464","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rspatel031.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-23T18:40:29.000Z","updated_at":"2025-01-26T06:56:39.000Z","dependencies_parsed_at":"2025-01-24T06:24:17.618Z","dependency_job_id":"69267255-6e72-48fd-a26b-ddaf163e644d","html_url":"https://github.com/rspatel031/k8s-cluster-setup","commit_stats":null,"previous_names":["rspatel031/k8s-cluster-setup"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspatel031%2Fk8s-cluster-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspatel031%2Fk8s-cluster-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspatel031%2Fk8s-cluster-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspatel031%2Fk8s-cluster-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rspatel031","download_url":"https://codeload.github.com/rspatel031/k8s-cluster-setup/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245825466,"owners_count":20678592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calico","containerd","control-plane","etcd","flannel","kube-apiserver","kube-controller-manager","kube-scheduler","kubeadm","kubectl","kubelet","kubernetes","kubernetes-cluster","weavenet","worker-node"],"created_at":"2025-02-01T15:15:19.907Z","updated_at":"2026-05-05T22:36:59.743Z","avatar_url":"https://github.com/rspatel031.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kubernetes Cluster Setup\n\nThis guide provides a step-by-step process for setting up a Kubernetes cluster with:\n- A **Control Plane** node.\n- One or more **Worker Nodes**.\n\nTwo scripts are included:\n1. **`control-plane.sh`**: For setting up the control plane.\n2. **`worker-node.sh`**: For setting up the worker nodes.\n\nBoth setups include detailed instructions and port configurations for various network add-ons like Calico, Weave, and Flannel.\n\n---\n\n## Prerequisites\n\n1. You have at least two machines (VMs or physical) with Ubuntu installed (22.04 or later is recommended).\n2. You have root or sudo access to these machines.\n3. Networking is properly configured between the nodes.\n4. Swap is disabled on all nodes.\n\n---\n\n## Installation Overview\n\n### Script 1: Setting Up the Control Plane\n1. Download the `control-plane.sh` script to your control plane node:\n\n   ```bash\n   wget https://raw.githubusercontent.com/rspatel031/k8s-cluster-setup/refs/heads/main/control-plane.sh\n   ```\n\n2. Make the script executable:\n\n   ```bash\n   chmod +x control-plane.sh\n   ```\n\n3. Run the script:\n\n   ```bash\n   sudo ./control-plane.sh\n   ```\n   \n### Output:\nAt the end of the script, you will receive a **join command** for worker nodes. This is stored at:\n```bash\n/tmp/kubeadm-init-output.txt\n```\n\n---\n\n### Script 2: Setting Up Worker Nodes\n**Important:** Ensure you set the hostname before executing the worker-node.sh script.\n\nThe **`worker-node.sh`** script prepares worker nodes and joins them to the cluster.\n\n### Steps:\n\n1. Download the `worker-node.sh` script to your worker node(s).\n\n   ```bash\n   wget https://raw.githubusercontent.com/rspatel031/k8s-cluster-setup/refs/heads/main/worker-node.sh\n   ```\n\n2. Make the script executable:\n\n   ```bash\n   chmod +x worker-node.sh\n   ```\n\n3. Run the script:\n   \n   ```bash\n   sudo ./worker-node.sh\n   ```\n\n4. Once the script finishes, use the **join command** from the control plane node to connect the worker node to the cluster. For example:\n\n   ```bash\n   sudo kubeadm join \u003ccontrol-plane-ip\u003e:6443 --token \u003ctoken\u003e --discovery-token-ca-cert-hash sha256:\u003chash\u003e\n   ```\n\n---\n\n## Script Breakdown\n\n### Control Plane Script (`control-plane.sh`)\nThe control plane script:\n1. Updates and upgrades the system.\n2. Sets the hostname to `control-plane`.\n3. Disables swap for Kubernetes compatibility.\n4. Configures required kernel modules and `sysctl` settings.\n5. Installs and configures `containerd`.\n6. Configures Kubernetes repositories.\n7. Installs Kubernetes components (`kubelet`, `kubeadm`, and `kubectl`).\n8. Initializes the Kubernetes control plane.\n9. Sets `crictl` endpoints.\n10. Deploys a default network add-on.\n11. Displays the `kubeadm init` command output.\n12. Adds `kubectl` aliases and autocompletion for ease of use.\n\n### Worker Node Script (`worker-node.sh`)\nThe worker node script:\n1. Updates and upgrades the system.\n2. Disables swap.\n3. Configures required kernel modules and `sysctl` settings.\n4. Installs and configures `containerd`.\n5. Configures Kubernetes repositories.\n6. Installs Kubernetes components (`kubelet` and `kubeadm`).\n\n---\n\n## Network Add-Ons\n\nKubernetes requires a network add-on to manage communication between pods. Below are the supported network add-ons with their corresponding configuration files:\n\n- **Calico**:\n\n  ```bash\n  wget https://raw.githubusercontent.com/rspatel031/k8s-network-addon/refs/heads/main/calico/calico.yaml\n  ```\n  \n- **Flannel**:\n\n  ```bash\n  wget https://raw.githubusercontent.com/rspatel031/k8s-network-addon/refs/heads/main/flannel/flannel.yaml\n  ```\n  \n- **Weave**:\n\n  ```bash\n  wget https://raw.githubusercontent.com/rspatel031/k8s-network-addon/refs/heads/main/weave/weave.yaml\n  ```\n\n**CIDR Configuration:** All network add-ons mentioned above are preconfigured to use the `10.244.0.0/16` CIDR range.\n\n---\n\n## Port Requirements\n\nBelow are the port details required for the cluster to function properly:\n\n### Kubernetes Components\n| Component          | Protocol | Ports      | Description                           |\n|--------------------|----------|------------|---------------------------------------|\n| Kube-API Server    | TCP      | 6443       | Kubernetes API server port.           |\n| etcd               | TCP      | 2379-2380  | Communication between etcd members.   |\n| Kubelet            | TCP      | 10250      | Worker node to API server communication. |\n| Kube Scheduler     | TCP      | 10251      | Scheduler communication.              |\n| Kube Controller    | TCP      | 10252      | Controller-manager communication.     |\n\n### Network Add-Ons\n| Add-On  | Protocol | Ports      | Description                               |\n|---------|----------|------------|-------------------------------------------|\n| Calico  | TCP/UDP  | 179        | BGP communication between nodes.         |\n| Flannel | UDP      | 8285       | Overlay network communication.           |\n| Flannel | UDP      | 8472       | VXLAN communication.                     |\n| Weave   | TCP/UDP  | 6783-6784  | Control plane and data plane traffic.    |\n\n---\n\n## Additional Notes\n\n- Ensure ports are open and accessible between nodes in the cluster.\n- Ensure you use the correct `kubeadm join` command on worker nodes.\n- The scripts are written for Ubuntu and may require modifications for other distributions.\n- The **control-plane** setup also deploys a Calico network add-on. You can customize the network plugin if needed.\n- Restart nodes if necessary after installation.\n- Use the provided configuration files to deploy any network add-on suitable for your environment.\n\n---\n\n## References\n\n- [Calico Configuration](https://raw.githubusercontent.com/rspatel031/k8s-network-addon/refs/heads/main/calico/calico.yaml)\n- [Flannel Configuration](https://raw.githubusercontent.com/rspatel031/k8s-network-addon/refs/heads/main/flannel/flannel.yaml)\n- [Weave Configuration](https://raw.githubusercontent.com/rspatel031/k8s-network-addon/refs/heads/main/weave/weave.yaml)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspatel031%2Fk8s-cluster-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frspatel031%2Fk8s-cluster-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspatel031%2Fk8s-cluster-setup/lists"}