Skip to content

Commit 7d5d7e0

Browse files
author
Eugenio Marzo
committed
fix doc
1 parent 74b9f7a commit 7d5d7e0

File tree

4 files changed

+221
-134
lines changed

4 files changed

+221
-134
lines changed

README.md

+221-134
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Backed by the teams at [platformengineering.it](https://platformengineering.it)
1414
# Table of Contents
1515

1616
1. [Description](#Description)
17-
2. [Installation](#Installation)
17+
2. [Installation - Helm with ClusterIP Service + Nginx Ingress](#Installation-default)
18+
2. [Installation - Helm with NodePort Service](#Installation-nodeport)
19+
2. [Installation - Using Podman or Docker](#Installation-podman)
1820
3. [Usage](#Usage)
1921
4. [URL Monitoring During Chaos Session](#URL-Monitoring-During-Chaos-Session)
2022
5. [Persistence](#Persistence)
@@ -31,7 +33,224 @@ Backed by the teams at [platformengineering.it](https://platformengineering.it)
3133

3234
With **k-inv**, you can stress a K8s cluster in a fun way and check how resilient it is.
3335

34-
## Installation
36+
## Installation-default
37+
38+
If you need a lab kubernetes cluster you can use this setup via Make and Minikube. Follow [this readme](./minikube-setup/README.md)
39+
40+
[![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/kubeinvaders)](https://artifacthub.io/packages/search?repo=kubeinvaders)
41+
42+
```bash
43+
# Please be sure to use kubeinvaders-1.9.8 that is ne latest helm chart version!
44+
45+
helm repo add kubeinvaders https://lucky-sideburn.github.io/helm-charts/
46+
helm repo update
47+
48+
kubectl create namespace kubeinvaders
49+
50+
# With ingress and TLS enabled
51+
helm install --set-string config.target_namespace="namespace1\,namespace2" --set ingress.enabled=true --set ingress.hostName=kubeinvaders.local --set deployment.image.tag=latest -n kubeinvaders kubeinvaders kubeinvaders/kubeinvaders --set ingress.tls_enabled=true
52+
53+
# With ingress enabled but TLS disabled (in case you have a reverse-proxy that does TLS termination and nginx controller in http)
54+
helm install --set-string config.target_namespace="namespace1\,namespace2" --set ingress.enabled=true --set ingress.hostName=kubeinvaders.local --set deployment.image.tag=latest -n kubeinvaders kubeinvaders kubeinvaders/kubeinvaders/ --set ingress.tls_enabled=false
55+
56+
```
57+
58+
### Example for K3S
59+
60+
```bash
61+
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable traefik" sh -s -
62+
63+
cat >/tmp/ingress-nginx.yaml <<EOF
64+
apiVersion: v1
65+
kind: Namespace
66+
metadata:
67+
name: ingress-nginx
68+
---
69+
apiVersion: helm.cattle.io/v1
70+
kind: HelmChart
71+
metadata:
72+
name: ingress-nginx
73+
namespace: kube-system
74+
spec:
75+
chart: ingress-nginx
76+
repo: https://kubernetes.github.io/ingress-nginx
77+
targetNamespace: ingress-nginx
78+
version: v4.9.0
79+
set:
80+
valuesContent: |-
81+
fullnameOverride: ingress-nginx
82+
controller:
83+
kind: DaemonSet
84+
hostNetwork: true
85+
hostPort:
86+
enabled: true
87+
service:
88+
enabled: false
89+
publishService:
90+
enabled: false
91+
metrics:
92+
enabled: false
93+
serviceMonitor:
94+
enabled: false
95+
config:
96+
use-forwarded-headers: "true"
97+
EOF
98+
99+
kubectl create -f /tmp/ingress-nginx.yaml
100+
101+
kubectl create ns namespace1
102+
kubectl create ns namespace2
103+
104+
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
105+
106+
helm install kubeinvaders --set-string config.target_namespace="namespace1\,namespace2" \
107+
-n kubeinvaders kubeinvaders/kubeinvaders --set ingress.enabled=true --set ingress.hostName=kubeinvaders.io --set deployment.image.tag=latest
108+
```
109+
110+
### Install to Kubernetes with Helm (v3+) - LoadBalancer / HTTP (tested with GKE)
111+
112+
```bash
113+
helm install kubeinvaders --set-string config.target_namespace="namespace1\,namespace2" -n kubeinvaders kubeinvaders/kubeinvaders --set ingress.enabled=true --set ingress.hostName=kubeinvaders.local --set deployment.image.tag=latest --set service.type=LoadBalancer --set service.port=80
114+
115+
kubectl set env deployment/kubeinvaders DISABLE_TLS=true -n kubeinvaders
116+
```
117+
118+
### SCC for Openshift
119+
120+
```bash
121+
oc adm policy add-scc-to-user anyuid -z kubeinvaders
122+
```
123+
124+
### Route for Openshift
125+
126+
```bash
127+
apiVersion: route.openshift.io/v1
128+
kind: Route
129+
metadata:
130+
name: kubeinvaders
131+
namespace: "kubeinvaders"
132+
spec:
133+
host: "kubeinvaders.io"
134+
to:
135+
name: kubeinvaders
136+
tls:
137+
termination: Edge
138+
```
139+
## Add simple nginx Deployment for Pods to shot at
140+
```bash
141+
cat >deployment.yaml <<EOF
142+
apiVersion: apps/v1
143+
kind: Deployment
144+
metadata:
145+
name: nginx-deployment
146+
spec:
147+
selector:
148+
matchLabels:
149+
app: nginx
150+
replicas: 20 # tells deployment to run 20 pods matching the template
151+
template:
152+
metadata:
153+
labels:
154+
app: nginx
155+
spec:
156+
containers:
157+
- name: nginx
158+
image: nginx:1.24.0
159+
ports:
160+
- containerPort: 81
161+
EOF
162+
```
163+
Apply Nginx Deployment in namespace1 and namespace2
164+
```bash
165+
sudo kubectl apply -f deployment.yaml -n namespace1
166+
sudo kubectl apply -f deployment.yaml -n namespace2
167+
```
168+
169+
## Installation-nodeport
170+
171+
Let's say we have a Layer4 or Layer7 Load Balancer that redirect traffic directly to the KubeInvaders Service Node Port.
172+
173+
For example this HaProxy configuration and we don't want use TLS (no secure just for experiment)
174+
175+
Please remember to disable TLS: **kubectl set env deployment/kubeinvaders DISABLE_TLS=true -n kubeinvaders**
176+
(TODO: put this into values of the Helm)
177+
178+
```bash
179+
global
180+
# to have these messages end up in /var/log/haproxy.log you will
181+
# need to:
182+
#
183+
# 1) configure syslog to accept network log events. This is done
184+
# by adding the '-r' option to the SYSLOGD_OPTIONS in
185+
# /etc/sysconfig/syslog
186+
#
187+
# 2) configure local2 events to go to the /var/log/haproxy.log
188+
# file. A line like the following can be added to
189+
# /etc/sysconfig/syslog
190+
#
191+
# local2.* /var/log/haproxy.log
192+
#
193+
log 127.0.0.1 local2
194+
195+
chroot /var/lib/haproxy
196+
pidfile /var/run/haproxy.pid
197+
maxconn 4000
198+
user haproxy
199+
group haproxy
200+
daemon
201+
202+
# turn on stats unix socket
203+
stats socket /var/lib/haproxy/stats
204+
205+
# utilize system-wide crypto-policies
206+
ssl-default-bind-ciphers PROFILE=SYSTEM
207+
ssl-default-server-ciphers PROFILE=SYSTEM
208+
209+
defaults
210+
mode tcp
211+
log global
212+
option httplog
213+
option dontlognull
214+
option http-server-close
215+
option forwardfor except 127.0.0.0/8
216+
option redispatch
217+
retries 3
218+
timeout http-request 10s
219+
timeout queue 1m
220+
timeout connect 10s
221+
timeout client 1m
222+
timeout server 1m
223+
timeout http-keep-alive 10s
224+
timeout check 10s
225+
maxconn 3000
226+
227+
frontend mylb
228+
bind *:80
229+
default_backend mynodeport
230+
231+
backend mynodeport
232+
balance roundrobin
233+
```
234+
Follow these steps:
235+
236+
```bash
237+
238+
helm repo add kubeinvaders https://lucky-sideburn.github.io/helm-charts/ && helm repo list
239+
VERSION=latest
240+
241+
helm install kubeinvaders kubeinvaders/kubeinvaders \
242+
--version=$VERSION \
243+
--namespace kubeinvaders \
244+
--create-namespace \
245+
--set service.type=NodePort \
246+
--set service.nodePort=30016 \
247+
--set ingress.enabled=false \
248+
--set config.target_namespace="default\,namespace1" \
249+
--set route_host=foobar.local
250+
251+
kubectl set env deployment/kubeinvaders DISABLE_TLS=true -n kubeinvaders
252+
```
253+
## Installation-podman
35254

36255
### Run through Docker or Podman
37256

@@ -210,138 +429,6 @@ podman run -p 8080:8080 \
210429
luckysideburn/kubeinvaders:latest
211430
```
212431

213-
### Install to Kubernetes with Helm (v3+)
214-
215-
If you need a lab kubernetes cluster you can use this setup via Make and Minikube. Follow [this readme](./minikube-setup/README.md)
216-
217-
[![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/kubeinvaders)](https://artifacthub.io/packages/search?repo=kubeinvaders)
218-
219-
```bash
220-
# Please be sure to use kubeinvaders-1.9.8 that is ne latest helm chart version!
221-
222-
helm repo add kubeinvaders https://lucky-sideburn.github.io/helm-charts/
223-
helm repo update
224-
225-
kubectl create namespace kubeinvaders
226-
227-
# With ingress and TLS enabled
228-
helm install --set-string config.target_namespace="namespace1\,namespace2" --set ingress.enabled=true --set ingress.hostName=kubeinvaders.local --set deployment.image.tag=latest -n kubeinvaders kubeinvaders kubeinvaders/kubeinvaders --set ingress.tls_enabled=true
229-
230-
# With ingress enabled but TLS disabled (in case you have a reverse-proxy that does TLS termination and nginx controller in http)
231-
helm install --set-string config.target_namespace="namespace1\,namespace2" --set ingress.enabled=true --set ingress.hostName=kubeinvaders.local --set deployment.image.tag=latest -n kubeinvaders kubeinvaders kubeinvaders/kubeinvaders/ --set ingress.tls_enabled=false
232-
233-
```
234-
235-
### Example for K3S
236-
237-
```bash
238-
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--disable traefik" sh -s -
239-
240-
cat >/tmp/ingress-nginx.yaml <<EOF
241-
apiVersion: v1
242-
kind: Namespace
243-
metadata:
244-
name: ingress-nginx
245-
---
246-
apiVersion: helm.cattle.io/v1
247-
kind: HelmChart
248-
metadata:
249-
name: ingress-nginx
250-
namespace: kube-system
251-
spec:
252-
chart: ingress-nginx
253-
repo: https://kubernetes.github.io/ingress-nginx
254-
targetNamespace: ingress-nginx
255-
version: v4.9.0
256-
set:
257-
valuesContent: |-
258-
fullnameOverride: ingress-nginx
259-
controller:
260-
kind: DaemonSet
261-
hostNetwork: true
262-
hostPort:
263-
enabled: true
264-
service:
265-
enabled: false
266-
publishService:
267-
enabled: false
268-
metrics:
269-
enabled: false
270-
serviceMonitor:
271-
enabled: false
272-
config:
273-
use-forwarded-headers: "true"
274-
EOF
275-
276-
kubectl create -f /tmp/ingress-nginx.yaml
277-
278-
kubectl create ns namespace1
279-
kubectl create ns namespace2
280-
281-
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
282-
283-
helm install kubeinvaders --set-string config.target_namespace="namespace1\,namespace2" \
284-
-n kubeinvaders kubeinvaders/kubeinvaders --set ingress.enabled=true --set ingress.hostName=kubeinvaders.io --set deployment.image.tag=latest
285-
```
286-
287-
### Install to Kubernetes with Helm (v3+) - LoadBalancer / HTTP (tested with GKE)
288-
289-
```bash
290-
helm install kubeinvaders --set-string config.target_namespace="namespace1\,namespace2" -n kubeinvaders kubeinvaders/kubeinvaders --set ingress.enabled=true --set ingress.hostName=kubeinvaders.local --set deployment.image.tag=latest --set service.type=LoadBalancer --set service.port=80
291-
292-
kubectl set env deployment/kubeinvaders DISABLE_TLS=true -n kubeinvaders
293-
```
294-
295-
### SCC for Openshift
296-
297-
```bash
298-
oc adm policy add-scc-to-user anyuid -z kubeinvaders
299-
```
300-
301-
### Route for Openshift
302-
303-
```bash
304-
apiVersion: route.openshift.io/v1
305-
kind: Route
306-
metadata:
307-
name: kubeinvaders
308-
namespace: "kubeinvaders"
309-
spec:
310-
host: "kubeinvaders.io"
311-
to:
312-
name: kubeinvaders
313-
tls:
314-
termination: Edge
315-
```
316-
## Add simple nginx Deployment for Pods to shot at
317-
```bash
318-
cat >deployment.yaml <<EOF
319-
apiVersion: apps/v1
320-
kind: Deployment
321-
metadata:
322-
name: nginx-deployment
323-
spec:
324-
selector:
325-
matchLabels:
326-
app: nginx
327-
replicas: 20 # tells deployment to run 20 pods matching the template
328-
template:
329-
metadata:
330-
labels:
331-
app: nginx
332-
spec:
333-
containers:
334-
- name: nginx
335-
image: nginx:1.24.0
336-
ports:
337-
- containerPort: 81
338-
EOF
339-
```
340-
Apply Nginx Deployment in namespace1 and namespace2
341-
```bash
342-
sudo kubectl apply -f deployment.yaml -n namespace1
343-
sudo kubectl apply -f deployment.yaml -n namespace2
344-
```
345432
## Usage
346433

347434
At the top you will find some metrics as described below:

html5/custom.css

Whitespace-only changes.

html5/custom.js

Whitespace-only changes.

html5/index.html

Whitespace-only changes.

0 commit comments

Comments
 (0)