-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Created kind k8s installation guide #34
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,129 @@ | ||||||||||||||||||||||||||||||
| # Kind K8s Installation Guide for AWS EC2 | ||||||||||||||||||||||||||||||
| <img src="https://github.com/user-attachments/assets/2942ee8e-7e11-4f58-a1de-bc939a33b8ab" alt="kind logo" style="height: 50px; width: auto;"> | ||||||||||||||||||||||||||||||
| <img src="https://github.com/user-attachments/assets/2af10983-a2f4-492a-961c-28b6f36f977a" alt="k8s logo" style="height: 50px; width: auto;"> | ||||||||||||||||||||||||||||||
| <img src="https://github.com/user-attachments/assets/9f1b82ea-d285-43ed-b7de-564019075ab1" alt="docker logo" style="height: 50px; width: auto;"> | ||||||||||||||||||||||||||||||
| <img src="https://github.com/user-attachments/assets/51fea0a8-3a8c-4727-8129-784c35f1389c" alt="ec2 logo" style="height: 50px; width: auto;"> | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| This guide provides step-by-step instructions for installing Kind K8s on AWS EC2 (Ubuntu). Kind allows you to run a single-node Kubernetes cluster locally for development and testing purposes. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| > ⚠️ **Caution:** | ||||||||||||||||||||||||||||||
| > This installation guide recommends using a `t2.medium` EC2 instance, which is **NOT** covered under the AWS Free Tier. | ||||||||||||||||||||||||||||||
| > Please be aware that using this instance type may incur **ADDITIONAL CHARGES**. For optimal performance with Kind K8s, it is advised to use a higher-tier EC2 instance to meet the computational requirements and **not** `t2.micro`. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Pre-requisites | ||||||||||||||||||||||||||||||
| * AWS EC2 (Ubuntu) | ||||||||||||||||||||||||||||||
| * Docker | ||||||||||||||||||||||||||||||
| * kubectl | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+14
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Expand prerequisites section Add essential prerequisites for a complete setup:
## Pre-requisites
* AWS EC2 (Ubuntu)
+* AWS Account with appropriate IAM permissions
+* SSH key pair for EC2 access
+* Security Group with following ports open:
+ * SSH (22)
+ * Container ports (30000-32767) for NodePort services
* Docker
* kubectl
+* Minimum 15GB storage📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||
| ## Pre-requisites Installation | ||||||||||||||||||||||||||||||
| ### 1. Create an EC2 (Ubuntu) and connect to it | ||||||||||||||||||||||||||||||
| * Create an EC2 of Instance type `t2.medium` and storage size of `15 GB` or more | ||||||||||||||||||||||||||||||
| * Launch the newly created EC2 and connect to it | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ### 2. Update system packages | ||||||||||||||||||||||||||||||
| Update your package lists to make sure you are getting the latest version and dependencies. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| sudo apt update | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ### 3. Install Docker | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Since **kind** runs Kubernetes clusters using Docker containers as nodes, Docker needs to be installed. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| * Install Docker using the below command | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| sudo apt install docker.io -y | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Docker service will be started and enabled by default. Verify if its started and enabled using `sudo systemctl status docker` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| * If Docker service is not started or enabled, do it using the command below | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| sudo systemctl enable --now docker | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| * Add current user to docker group (To use docker without root) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| sudo usermod -aG docker $USER && newgrp docker | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
| * Verify using `docker --version` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+33
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance Docker installation security Consider adding security best practices and version pinning:
### 3. Install Docker
+
+It's recommended to install a specific version of Docker for reproducibility:
+
+```bash
+DOCKER_VERSION="24.0.7"
+sudo apt install docker.io=${DOCKER_VERSION}* -y
+```
+
+Configure Docker daemon with security best practices:
+
+```bash
+sudo tee /etc/docker/daemon.json <<EOF
+{
+ "log-driver": "json-file",
+ "log-opts": {
+ "max-size": "100m"
+ },
+ "default-ulimits": {
+ "nofile": {
+ "Name": "nofile",
+ "Hard": 64000,
+ "Soft": 64000
+ }
+ }
+}
+EOF
+
+sudo systemctl restart docker
+``` |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ### 4. Install kubectl | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Download **kubectl**, which is a Kubernetes command-line tool. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| * Download kubectl binary with curl on Linux | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| > **Optional**: **Validate the downloaded kubectl binary ** | ||||||||||||||||||||||||||||||
| > * Download the kubectl checksum file | ||||||||||||||||||||||||||||||
| > `curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"` | ||||||||||||||||||||||||||||||
| > * Validate the kubectl binary against the checksum file | ||||||||||||||||||||||||||||||
| > `echo "$(cat kubectl.sha256) kubectl" | sha256sum --check` | ||||||||||||||||||||||||||||||
| > * If valid, the output is `kubectl: OK` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+72
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make checksum verification mandatory The checksum verification step should not be optional as it ensures the integrity and authenticity of the kubectl binary. -Optional**: **Validate the downloaded kubectl binary **
-> * Download the kubectl checksum file
-> `curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"`
-> * Validate the kubectl binary against the checksum file
-> `echo "$(cat kubectl.sha256) kubectl" | sha256sum --check`
-> * If valid, the output is `kubectl: OK`
+**Important**: Verify kubectl binary integrity
+
+```bash
+# Download kubectl checksum file
+curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
+
+# Validate kubectl binary (Required)
+echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
+
+# Proceed only if verification succeeds with "kubectl: OK"
+```🧰 Tools🪛 Markdownlint72-72: null (MD037, no-space-in-emphasis) |
||||||||||||||||||||||||||||||
| * Install kubectl | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| * Verify installation by checking kubectl version | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| kubectl version --client | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+63
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Specify kubectl version compatibility Add a note about kubectl version compatibility with Kind. The kubectl version should be within one minor version of the Kind cluster's Kubernetes version. 🧰 Tools🪛 Markdownlint72-72: null (MD037, no-space-in-emphasis) |
||||||||||||||||||||||||||||||
| ## Kind K8s Installation | ||||||||||||||||||||||||||||||
| ### Install Kind | ||||||||||||||||||||||||||||||
| Download and install **kind** k8s | ||||||||||||||||||||||||||||||
| * Download kind binary with curl on Linux | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| [ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.25.0/kind-linux-amd64 | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve version handling and architecture support
-[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.25.0/kind-linux-amd64
+KIND_VERSION=$(curl -s https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | grep tag_name | cut -d '"' -f 4)
+if [ $(uname -m) = x86_64 ]; then
+ curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64
+elif [ $(uname -m) = aarch64 ]; then
+ curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-arm64
+else
+ echo "Unsupported architecture"
+ exit 1
+fi📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
| * Install kind | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| chmod +x ./kind | ||||||||||||||||||||||||||||||
| sudo mv ./kind /usr/local/bin/kind | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
| * Run `kind` to verify if its installed | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+91
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add support for ARM64 architecture AWS offers Graviton (ARM64) instances which can be more cost-effective. Add support for ARM64 architecture. Download and install **kind** k8s
* Download kind binary with curl on Linux
```bash
- [ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.25.0/kind-linux-amd64
+ ARCH=$(uname -m)
+ case $ARCH in
+ x86_64)
+ curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.25.0/kind-linux-amd64
+ ;;
+ aarch64)
+ curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.25.0/kind-linux-arm64
+ ;;
+ *)
+ echo "Unsupported architecture: $ARCH"
+ exit 1
+ ;;
+ esac |
||||||||||||||||||||||||||||||
| ## Kind K8s Usage | ||||||||||||||||||||||||||||||
| ### Create a Cluster | ||||||||||||||||||||||||||||||
| Create a Kubernetes Cluster using `kind create cluster`. Use the `--name` flag to provide a cluster name. For Example, `kind create cluster --name=<cluster-name>` (Replace `<cluster-name>` with desired cluster name). | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ### Interacting with Clusters | ||||||||||||||||||||||||||||||
| `kubectl` can be used to interact with created clusters. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| * To list all the clusters, execute `kind get clusters` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| * To get nodes, run `kubectl get nodes` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ### Optional: Delete cluster | ||||||||||||||||||||||||||||||
| Delete a Kubernetes Cluster using `kind delete cluster`. Use the `--name` flag to provide a cluster name. For Example, `kind delete cluster --name=<cluster-name>` (Replace `<cluster-name>` with desired cluster name). | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+107
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Expand cluster management section Add essential cluster management topics:
## Kind K8s Usage
+
+### Cluster Configuration
+Create a config file `kind-config.yaml`:
+```yaml
+kind: Cluster
+apiVersion: kind.x-k8s.io/v1alpha4
+nodes:
+- role: control-plane
+ extraPortMappings:
+ - containerPort: 80
+ hostPort: 80
+- role: worker
+- role: worker
+```
+
+Create cluster with config:
+```bash
+kind create cluster --config kind-config.yaml
+```
+
+### Storage Setup
+Apply local storage class:
+```bash
+kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
+```
+
+### Troubleshooting
+Common issues and solutions:
+- Check logs: `kubectl logs -n kube-system kube-controller-manager-kind-control-plane`
+- Check events: `kubectl get events --all-namespaces`
+- Resource constraints: `kubectl describe node` |
||||||||||||||||||||||||||||||
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.
🛠️ Refactor suggestion
Consider using permanent image URLs
The current image URLs use temporary paths (
user-attachments). Consider:docs/images/)