https://github.com/kdgyun/k8s-cluster-bootstrap
An easy and ready-to-go bootstrap for k8s installation and automatic cluster deployment!
https://github.com/kdgyun/k8s-cluster-bootstrap
bootstrap k8s k8s-cluster kubernetes terraform
Last synced: 5 months ago
JSON representation
An easy and ready-to-go bootstrap for k8s installation and automatic cluster deployment!
- Host: GitHub
- URL: https://github.com/kdgyun/k8s-cluster-bootstrap
- Owner: kdgyun
- License: apache-2.0
- Created: 2023-05-18T01:13:27.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-23T07:01:25.000Z (about 2 years ago)
- Last Synced: 2024-05-23T07:47:44.188Z (about 2 years ago)
- Topics: bootstrap, k8s, k8s-cluster, kubernetes, terraform
- Language: Shell
- Homepage:
- Size: 128 KB
- Stars: 9
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README-en.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
**[νκΈ λ¬Έμ](./README.md)** | **English Document**





&color=green&style=flat-square&logo=ubuntu)
&color=green&style=flat-square&logo=ubuntu)





# k8s-cluster-bootstrap
#### π¨ An easy and ready-to-go bootstrap for k8s installation and automatic cluster deployment!
## Requirements
- Ubuntu (or ubuntu server) version between 18.04 (inclusive) and 22.04 (inclusive) recommended.
- Nodes (both master and workers) are to be in the same subnet. **For calico autodeployment to work** the Master node's IP(Host IP) must **not be within the same CIDR**.
- If accessing via ssh, use username/password authentication and not pem.
- The script automatically opens some ports (such as 6443), but ports may need to be manually opened in case of firewalls or company policies.
([ports required to be open for k8s installation](https://kubernetes.io/docs/reference/networking/ports-and-protocols/))
## **Usage**
### 1. Bootstrap download
From the home directory, run `curl -sSLO http://raw.githubusercontent.com/kdgyun/k8s-cluster-bootstrap/main/k8s-cluster-bootstrap.sh` or download from github [**latest release version**](https://github.com/kdgyun/k8s-cluster-bootstrap/releases/) and run k8s-cluster-bootstrap.sh.
### 2. File Run Permission
Grant `k8s-cluster-bootstrap.sh` the following permission:
```bash
chmod +x k8s-cluster-bootstrap.sh
```
### 3. Execution
Run `k8s-cluster-bootstrap.sh` with sudo.
```bash
sudo ./k8s-cluster-bootstrap.sh [options]
```
The arguments for [options] are explained below.
## Options
The following shows the available options to run this bootstrap.
| Option(Flag) | Values | Description, example | Remarks |
| --- | --- | --- | --- |
| ```-c / --cni``` | CIDR | Installs cni(with calico) during master node installation. | To utilize this option, the master's IP(Host IP) cannot overlap with calico's CIDR. Please utilize one of the following CIDR: ```10.0.0.0/8```, ```172.16.0.0/12```, ```192.168.0.0/16```. |
| ```-ct / --containertype``` | Container Runtime | Specify the type of container runtime k8s will use. If empty, it will default to ```docker(cri-dockerd)``` | For **cri-dockerd** write ```docker``` ,
for **containerd** write ```containerd``` as the parameter for this option. |
| ```-h / --help``` | | Display all options and their respective descriptions. | |
| ```-i / --ip``` | Master's (Host) IP | Declare IP for master node (e.g, 10.0.0.1).
In case of deploying k8s in a cloud (e.g, aws, gcp β¦) declare an IP with the scope of a private IP, not the public IP. | |
| ```-kv / --k8sversion``` | | Displays all versions of k8s this bootstrap can install | |
| ```-m / --master``` | | Use this option to install a master ```-m``` | The flag ```-i/--ip``` is a must if this option is utilized. |
| ```-ms / --metricserver``` | | To install the metrics-server for Kubernetes, use the `-ms` flag. | It can only be installed when configuring a master node, so the `-m/--master` flag is also required. |
| ```-p / --password``` | Master(Host) node password | Required for ssh login using a password.
It is done so the worker node can access the master during installation to obtain the join token. Both master and worker must be in the same subnet. | The flag ```-u/--username``` is a must if this option is utilized. |
| ```-r / --regularuser```
**(\*beta)** | HOME_PATH of regular user | This bootstrap is executed with sudo permission, thus this option is used to allow regular users (such as the user `ubuntu` in ubuntu servers) to also use k8s.
run this option as ```-r /home/username```. Crucial that HOME_PATH is the same as **the regular user's home directory($HOME)** | Not a must option. Utilized when initializing a master node with ```-m```. |
| ```-u / --username``` | Master(Host) node username | ```username``` for ssh login.
Set so a newly created worker node within the same subnet as the master node can fetch the join token from the master node. | The floag ```-p/--password``` is a must if this option is utilized. |
| ```-v / --version``` | k8s version | Declare k8s version to install.
Supports k8s version from ```1.24.15``` to ```1.31.2``` and more details can be checked using the ```-kv``` or ```--k8sversion``` option. | The parameters for this options are to be written as ```x.y.z```.
Not using this option will default k8s version to ```1.24.15``` and does not support RC nor beta versions since they are not stable versions. |
| ```-w / --worker``` | | Used to specify worker node installation. | the following 3 options are required: ```-i/--ip``` , ```-u/--username```, ```-p/-password```. |
Executing this bootstrap with **no** options will only install the packages for k8s (no auto deployment)
In the case that only the packages are install, you can still use the ```kubeadm init``` command to manually deploy nodes.
example for installing k8s and deploying a **master** node:
```bash
sudo ./k8s-cluster-bootstrap.sh -m -c 192.168.0.0/16 -i 10.0.0.1 -ct containerd -v 1.25.0
```
example for installing k8s and deploying a **worker** node:
```bash
sudo ./k8s-cluster-bootstrap.sh -w -i 10.0.0.1 -u username -p pwd123! -ct containerd -v 1.25.0
```
## Contribution guidelines
**If you want to contribute to this Repo, be sure to review the
[contribution guidelines](.github/CONTRIBUTING.md).**