Merge pull request #70 from ettoreciarcia/feat/minikube-setup

feat: added basic configuration to run Kubeinvaders on Minikube
This commit is contained in:
Eugenio Marzo
2023-10-10 11:16:19 +02:00
committed by GitHub
4 changed files with 164 additions and 0 deletions

36
minikube-setup/Makefile Normal file
View File

@@ -0,0 +1,36 @@
kubernetes-version?=v1.26.3
driver?=parallels
memory?=2048
cpu?=4
nodes?=1
.PHONY: init-cluster
init-cluster:
minikube start \
--kubernetes-version $(kubernetes-version) \
--driver $(driver) \
--memory $(memory) \
--cpus $(cpu) \
--nodes $(nodes) \
--embed-certs \
--static-ip 10.211.55.70
.PHONY: setup-cluster
setup-cluster:
kubectl apply -f manifests && helm install kubeinvaders --set-string config.target_namespace="ns-1" \
-n kubeinvaders kubeinvaders/kubeinvaders --set ingress.enabled=true --set ingress.hostName=kubeinvaders.local --set deployment.image.tag=v1.9.6 && minikube addons enable ingress
.PHONY: setup
setup: init-cluster setup-cluster
.PHONY: delete-cluster
delete-cluster:
minikube delete

62
minikube-setup/README.md Normal file
View File

@@ -0,0 +1,62 @@
# How to use Kubeinvaders on Minikube
## Prerequisites
- [Minikube](https://github.com/kubernetes/minikube)
- [kubectl](https://kubernetes.io/docs/tasks/tools/)
- [Helm](https://helm.sh/)
- [Virtualization Software compatible with Minikube](https://minikube.sigs.k8s.io/docs/drivers/) (Parallels, VirtualBox, Hyperkit ecc).
## What we are going to install in our cluster
- Kubeinvasers 1.9.6
- Ingress addons for Minikube
- x1 Deployment, x1 ReplicaSet, x10 nginx pods in namesapce **ns-1**
## Walkthrough
### Setup your Minikube cluster
```make init-cluster```
If no hypervisor is specified within the Makefile, the default will be parallels. Check this [link](https://minikube.sigs.k8s.io/docs/drivers/) for a complete list of Minikube-compatible drivers
Within the makefile, you can specify other configurations as well:
- Number of nodes
- RAM
- CPU
- Kubernetes version
### Setup Kubeinvaders, Ingress addons and Nginx deployment
```make setup-cluster```
### How to reach the applications within the cluster
The two applications can be accessed at the following paths:
- kubeinvaders.local
- nginx.local
However, to reach them, you need to add these two entries to the /etc/hosts file, associating these DNS names with the output obtained from the "minikube ip" command.
Run
```minikube ip```
and add the following entries to the /etc/hosts file:
```
<your_minikube_ip> kubeinvaders.local
<your_minikube_ip> nginx.local
```
More about minikube ip command [here](https://minikube.sigs.k8s.io/docs/commands/ip/)
Now you can visit the kubeinvaders.local page and have fun!

View File

@@ -0,0 +1,62 @@
apiVersion: v1
kind: Namespace
metadata:
name: ns-1
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: ns-1
labels:
app: nginx-deployment
name: nginx-deployment
spec:
replicas: 10
selector:
matchLabels:
app: nginx-deployment
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nginx-deployment
spec:
containers:
- image: nginx:alpine-slim
name: nginx
resources: {}
status: {}
---
apiVersion: v1
kind: Service
metadata:
namespace: ns-1
name: nginx-service
spec:
selector:
app: nginx-deployment
ports:
- protocol: TCP
port: 80
targetPort: 80
type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: ns-1
name: nginx-ingress
spec:
rules:
- host: nginx.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-service
port:
number: 80

View File

@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: kubeinvaders