-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
386 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v2 | ||
name: network-shaping | ||
description: Network shaping for spartan using chaos-mesh | ||
type: application | ||
version: 0.1.0 | ||
appVersion: "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
helm upgrade chaos-mesh . -n chaos-mesh --install --atomic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# Delete all actively running chaos experiments | ||
kubectl delete networkchaos,podchaos,iochaos,httpchaos --all --all-namespaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{{/* | ||
Create a default fully qualified app name. | ||
*/}} | ||
{{- define "network-shaping.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "chaos-mesh.selectorLabels" -}} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "network-shaping.labels" -}} | ||
app.kubernetes.io/name: {{ include "network-shaping.fullname" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{{- if .Values.networkShaping.enabled }} | ||
{{- if .Values.networkShaping.conditions.latency.enabled }} | ||
--- | ||
apiVersion: chaos-mesh.org/v1alpha1 | ||
kind: NetworkChaos | ||
metadata: | ||
name: {{ .Values.global.namespace }}-latency | ||
namespace: {{ .Values.global.chaosMeshNamespace }} | ||
labels: | ||
{{- include "network-shaping.labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": post-install,post-upgrade | ||
"helm.sh/hook-weight": "0" | ||
"helm.sh/resource-policy": keep | ||
spec: | ||
action: delay | ||
mode: all | ||
selector: | ||
namespaces: | ||
- {{ .Values.global.targetNamespace }} | ||
delay: | ||
{{- toYaml .Values.networkShaping.conditions.latency.delay | nindent 4 }} | ||
duration: 8760h # 1 year | ||
{{- end }} | ||
|
||
{{- if .Values.networkShaping.conditions.bandwidth.enabled }} | ||
--- | ||
apiVersion: chaos-mesh.org/v1alpha1 | ||
kind: NetworkChaos | ||
metadata: | ||
name: {{ .Values.global.namespace }}-bandwidth | ||
namespace: {{ .Values.global.chaosMeshNamespace }} | ||
labels: | ||
{{- include "network-shaping.labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": post-install,post-upgrade | ||
"helm.sh/hook-weight": "0" | ||
"helm.sh/resource-policy": keep | ||
spec: | ||
action: bandwidth | ||
mode: all | ||
selector: | ||
namespaces: | ||
- {{ .Values.global.targetNamespace }} | ||
bandwidth: | ||
rate: {{ .Values.networkShaping.conditions.bandwidth.rate }} | ||
limit: {{ .Values.networkShaping.conditions.bandwidth.limit }} | ||
buffer: {{ .Values.networkShaping.conditions.bandwidth.buffer }} | ||
duration: 8760h | ||
{{- end }} | ||
|
||
{{- if .Values.networkShaping.conditions.packetLoss.enabled }} | ||
--- | ||
apiVersion: chaos-mesh.org/v1alpha1 | ||
kind: NetworkChaos | ||
metadata: | ||
name: {{ .Values.global.namespace }}-packet-loss | ||
namespace: {{ .Values.global.chaosMeshNamespace }} | ||
labels: | ||
{{- include "network-shaping.labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/resource-policy": keep | ||
spec: | ||
action: loss | ||
mode: all | ||
selector: | ||
namespaces: | ||
- {{ .Values.global.targetNamespace }} | ||
loss: | ||
loss: {{ .Values.networkShaping.conditions.packetLoss.loss | quote }} | ||
correlation: {{ .Values.networkShaping.conditions.packetLoss.correlation | quote }} | ||
duration: 8760h | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
global: | ||
# When deploying, override the namespace to where spartan will deploy to, this will apply all chaos experiments to all pods within that namespace | ||
# run deployment with --values global.namespace=your-namespace | ||
targetNamespace: smoke | ||
chaosMeshNamespace: chaos-mesh | ||
|
||
# Network shaping configuration | ||
networkShaping: | ||
# Master switch to enable network shaping | ||
enabled: true | ||
|
||
# Default settings | ||
defaultSettings: | ||
mode: all | ||
# Set duration to 1 year so the the experiment will run indefinitely unless overridden | ||
duration: 8760h | ||
|
||
# Network conditions to apply | ||
conditions: | ||
# Latency Simulation | ||
latency: | ||
# Enable / disable latency configuration | ||
enabled: false | ||
delay: | ||
# Base latency of all network traffic | ||
# can be defined in ms / s | ||
latency: "100ms" | ||
|
||
# Random variation in latency | ||
# Actual will be latency +- jitter | ||
jitter: "50ms" | ||
|
||
# Correlation | ||
# This means previous delays will impact the immediate next delay | ||
# Eg: 75 means the current delay will be 75% influenced by the previous delay | ||
correlation: "75" | ||
|
||
|
||
packetLoss: | ||
# Enable / disable packet loss configuration | ||
enabled: false | ||
# Packet drop percentage | ||
# 2 = 2% of packets will disappear into the ether | ||
loss: "2" | ||
|
||
# Correlation | ||
# Higher values mean packet losses happen in bursts | ||
# 25 = 25% influenced by the previous loss | ||
correlation: "25" | ||
|
||
bandwidth: | ||
# Enable / disable bandwidth configuration | ||
enabled: false | ||
|
||
# Target bandwidth rate | ||
# kbps, mbps, gbps | ||
rate: "1024kbps" | ||
|
||
# Burst size, buffer to allow before bandwidth limiting is applied | ||
# Not a string! | ||
limit: 20971520 | ||
|
||
# Buffer = smoother bandwidth restriction but higher memory usage | ||
buffer: 1000 | ||
|
||
|
||
|
||
## Here are some exciting example configurations created by claude: | ||
# Example use cases for different configurations: | ||
|
||
# High latency network simulation (e.g., satellite) | ||
# latency: | ||
# enabled: true | ||
# delay: | ||
# latency: 500ms | ||
# jitter: 50ms | ||
# correlation: "75" | ||
|
||
# Mobile network simulation (3G) | ||
# bandwidth: | ||
# enabled: true | ||
# rate: 1500kbps | ||
# limit: 1500kb | ||
# buffer: 1000 | ||
# latency: | ||
# enabled: true | ||
# delay: | ||
# latency: 100ms | ||
# jitter: 40ms | ||
# correlation: "75" | ||
|
||
# Unreliable network simulation | ||
# packetLoss: | ||
# enabled: true | ||
# loss: "5" | ||
# correlation: "75" | ||
# latency: | ||
# enabled: true | ||
# delay: | ||
# latency: 150ms | ||
# jitter: 30ms | ||
# correlation: "75" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Simulates global network conditions | ||
# High latency, moderate bandwidth | ||
global: | ||
namespace: "smoke" | ||
|
||
networkShaping: | ||
enabled: true | ||
conditions: | ||
latency: | ||
enabled: true | ||
delay: | ||
# Global network latency (e.g., intercontinental) | ||
latency: 200ms | ||
jitter: 40ms | ||
correlation: "75" | ||
bandwidth: | ||
enabled: true | ||
# 20Mbps | ||
rate: 20mbps | ||
limit: 10000000 # 10 MB | ||
buffer: 4000 | ||
packetLoss: | ||
enabled: true | ||
loss: "1" | ||
correlation: "70" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
# Moderate latency, very high bandwidth | ||
global: | ||
namespace: "smoke" | ||
|
||
networkShaping: | ||
enabled: true | ||
conditions: | ||
latency: | ||
enabled: true | ||
delay: | ||
# Typical datacenter-to-datacenter latency | ||
latency: 50ms | ||
jitter: 10ms | ||
correlation: "75" | ||
bandwidth: | ||
enabled: true | ||
# 100Mbps | ||
rate: 100mbps | ||
limit: 50000000 # 50 MB | ||
buffer: 8000 | ||
packetLoss: | ||
enabled: true | ||
loss: "0.1" | ||
correlation: "50" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Simulates regional network conditions | ||
# Higher latency, good bandwidth | ||
global: | ||
namespace: "smoke" | ||
|
||
networkShaping: | ||
enabled: true | ||
conditions: | ||
latency: | ||
enabled: true | ||
delay: | ||
# Regional network latency (e.g., cross-country) | ||
latency: 100ms | ||
jitter: 20ms | ||
correlation: "75" | ||
bandwidth: | ||
enabled: true | ||
# 50Mbps | ||
rate: 50mbps | ||
limit: 25000000 # 25 MB | ||
buffer: 5000 | ||
packetLoss: | ||
enabled: true | ||
loss: "0.5" | ||
correlation: "60" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Simulates congested network conditions | ||
# High latency, limited bandwidth, packet loss | ||
global: | ||
namespace: "smoke" | ||
|
||
networkShaping: | ||
enabled: true | ||
conditions: | ||
latency: | ||
enabled: true | ||
delay: | ||
# Congested network latency | ||
latency: 300ms | ||
jitter: 100ms | ||
correlation: "80" | ||
bandwidth: | ||
enabled: true | ||
# 5Mbps | ||
rate: 5mbps | ||
limit: 2000000 # 2 MB | ||
buffer: 2000 | ||
packetLoss: | ||
enabled: true | ||
loss: "2" | ||
correlation: "75" |
Oops, something went wrong.