Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/milesrack/kubernetes-setup

A guide along with scripts I used for setting up a kubernetes cluster.
https://github.com/milesrack/kubernetes-setup

bash cloud cloud-computing containerization containers k8s kubernetes kubernetes-cluster kubernetes-node kubernetes-setup

Last synced: 1 day ago
JSON representation

A guide along with scripts I used for setting up a kubernetes cluster.

Awesome Lists containing this project

README

        

# kubernetes-setup
A guide along with scripts I used for setting up a kubernetes cluster.

## Overview
We will setup one master node and at least one worker node to creake a kubernetes cluster. From the master node we can deploy containerized applications that will distribute the workload across the worker nodes.

Both the master and worker nodes will have Ubuntu 22.04 Server installed.

## Requirements
- Ubuntu 22.04 Server (tested with this script)
- \>= 2 GB RAM
- \>= 2 CPUs

## Master Node
Run the setup script for the master node:
```bash
wget -q https://raw.githubusercontent.com/milesrack/kubernetes-setup/master/master-setup.sh -O - | bash
```

Copy the `kubeadm join` command in the output, this will allow worker nodes to join the cluster.

It may take a few minutes for all the pods to start running. We can view the running pods on the master node with the following command:
```bash
kubectl get pods -n kube-system
```

## Worker Nodes
Use the following command to set the hostname:
```bash
sudo hostnamectl hostname node1
```
*If you are setting up multiple worker nodes, make sure each hostname is unique (eg. `node1`, `node2`, `node3`).*

Now run the setup script for the worker nodes:
```bash
wget -q https://raw.githubusercontent.com/milesrack/kubernetes-setup/master/node-setup.sh -O - | bash
```

Once the script has completed run the `kubeadm join` command generated by the master node:
```bash
sudo kubeadm join :6443 --token --discovery-token-ca-cert-hash sha256:
```

## Viewing Resources
Run the following command on the master node to view nodes in the cluster:
```bash
kubectl get nodes
```

For more verbose output (IP addresses, OS version, etc.):
```bash
kubectl get nodes -o wide
```

To show resource usage of nodes in the cluster:
```bash
kubectl top nodes
```

To show pods in the kubernetes system:
```bash
kubectl get pods -n kube-system
```

To show resource usage of pods in the kubernetes system:
```bash
kubectl top pods -n kube-system
```

## Deploying Nginx
Run the following commands on the master node to configure the nginx service:
```bash
wget -q https://raw.githubusercontent.com/milesrack/kubernetes-setup/master/deployment.yaml -O - | kubectl apply -f -
wget -q https://raw.githubusercontent.com/milesrack/kubernetes-setup/master/service.yaml -O - | kubectl apply -f -
```

We can view the newly created pods with:
```bash
kubectl get pods
```

To show resource usage of the pods:
```bash
kubectl top pods
```

Navigate to `http://:32000/` in your browser to view the running nginx server. Replace `` with the IP address of any of the worker nodes.

## Resources
- https://devopscube.com/setup-kubernetes-cluster-kubeadm/
- https://kubernetes.io/docs/setup/