Additions
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
Kubernetes-Dont's.key
|
||||
.DS_Store
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# The next line is for a minikube environment
|
||||
eval $(minikube -p minikube docker-env)
|
||||
|
||||
# https://docs.docker.com/engine/reference/commandline/stats/
|
||||
|
||||
docker stats --format "table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl get events -w
|
||||
kubectl get events -w -A
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl apply -f depolyment.yaml
|
||||
kubectl apply -f memory-waster.yaml
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl delete -f deployment.yaml
|
||||
kubectl delete -f memory-waster.yaml
|
||||
7
Demo-1/README.md
Normal file
7
Demo-1/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# This demo will show resource settings
|
||||
|
||||
Using the provided scripts it will be made visible how resource limits limit the number of pods that can be deployed on a cluster.
|
||||
|
||||
This demo will deploy as many nginx pods that each will have a reservation of 512Mb.
|
||||
|
||||
Run the different scripts in different terminals to get the full picture.
|
||||
20
Demo-2/01 - stats.sh
Executable file
20
Demo-2/01 - stats.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
# The next line is for a minikube environment
|
||||
eval "$(minikube -p minikube docker-env)"
|
||||
|
||||
# https://docs.docker.com/engine/reference/commandline/stats/
|
||||
|
||||
docker stats --format "table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}"
|
||||
|
||||
exit
|
||||
|
||||
# .Container Container name or ID (user input)
|
||||
# .Name Container name
|
||||
# .ID Container ID
|
||||
# .CPUPerc CPU percentage
|
||||
# .MemUsage Memory usage
|
||||
# .NetIO Network IO
|
||||
# .BlockIO Block IO
|
||||
# .MemPerc Memory percentage (Not available on Windows)
|
||||
# .PIDs Number of PIDs (Not available on Windows)
|
||||
3
Demo-2/02 - events.sh
Executable file
3
Demo-2/02 - events.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl get events -w -A
|
||||
5
Demo-2/03 - deploy.sh
Executable file
5
Demo-2/03 - deploy.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl create namespace mem-example
|
||||
|
||||
kubectl apply -f memory-request-limit-1.yaml
|
||||
6
Demo-2/04 - deploy.sh
Executable file
6
Demo-2/04 - deploy.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl create namespace mem-example
|
||||
|
||||
kubectl delete -f memory-request-limit-1.yaml
|
||||
kubectl apply -f memory-request-limit-2.yaml
|
||||
6
Demo-2/05 - deploy.sh
Executable file
6
Demo-2/05 - deploy.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl create namespace mem-example
|
||||
|
||||
kubectl delete -f memory-request-limit-2.yaml
|
||||
kubectl apply -f memory-request-limit-3.yaml
|
||||
5
Demo-2/06- cleanup.sh
Executable file
5
Demo-2/06- cleanup.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl delete -f memory-request-limit-3.yaml
|
||||
kubectl delete namespace mem-example
|
||||
|
||||
27
Demo-2/memory-request-limit-1.yaml
Normal file
27
Demo-2/memory-request-limit-1.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: memory-waster
|
||||
namespace: mem-example
|
||||
labels:
|
||||
app: memory-waster
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: memory-waster
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: memory-waster
|
||||
spec:
|
||||
containers:
|
||||
- name: memory-demo-ctr
|
||||
image: polinux/stress
|
||||
resources:
|
||||
limits:
|
||||
memory: "200Mi"
|
||||
requests:
|
||||
memory: "100Mi"
|
||||
command: ["/bin/sh"]
|
||||
args: ["-c", "sleep 1; stress --vm 1 --vm-bytes 150M --vm-hang 1"]
|
||||
27
Demo-2/memory-request-limit-2.yaml
Normal file
27
Demo-2/memory-request-limit-2.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: memory-waster
|
||||
namespace: mem-example
|
||||
labels:
|
||||
app: memory-waster
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: memory-waster
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: memory-waster
|
||||
spec:
|
||||
containers:
|
||||
- name: memory-demo-ctr
|
||||
image: polinux/stress
|
||||
resources:
|
||||
limits:
|
||||
memory: "200Mi"
|
||||
requests:
|
||||
memory: "100Mi"
|
||||
command: ["/bin/sh"]
|
||||
args: ["-c", "sleep 1; stress --vm 1 --vm-bytes 250M --vm-hang 1"]
|
||||
28
Demo-2/memory-request-limit-3.yaml
Normal file
28
Demo-2/memory-request-limit-3.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: memory-waster
|
||||
namespace: mem-example
|
||||
labels:
|
||||
app: memory-waster
|
||||
spec:
|
||||
replicas: 15
|
||||
selector:
|
||||
matchLabels:
|
||||
app: memory-waster
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: memory-waster
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: memory-demo-ctr
|
||||
image: polinux/stress
|
||||
resources:
|
||||
limits:
|
||||
memory: "200Mi"
|
||||
requests:
|
||||
memory: "50Mi"
|
||||
command: ["/bin/sh"]
|
||||
args: ["-c", "sleep 30; stress --vm 1 --vm-bytes 150M --vm-hang 1"]
|
||||
4
Demo-3/01 - start.sh
Executable file
4
Demo-3/01 - start.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl create namespace probes
|
||||
kubectl apply -f configmap-probes.yaml
|
||||
4
Demo-3/02 - deploy-1.sh
Executable file
4
Demo-3/02 - deploy-1.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl apply -f deployment-1.yaml
|
||||
kubectl apply -f service.yaml
|
||||
3
Demo-3/03 - deploy-2.sh
Executable file
3
Demo-3/03 - deploy-2.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl apply -f deployment-2.yaml
|
||||
4
Demo-3/04 - port forward.sh
Executable file
4
Demo-3/04 - port forward.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
kill $(ps -ef | grep kube | grep port-forward | awk '{print $2}')
|
||||
kubectl -n probes port-forward service/probes 9876:80 &
|
||||
9
Demo-3/05 - browser.sh
Executable file
9
Demo-3/05 - browser.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# https://github.com/mhausenblas/simpleservice
|
||||
|
||||
# On a Mac this will open a browser session
|
||||
/Applications//Google\ Chrome.app/Contents/MacOS/Google\ Chrome http://127.0.0.1:9876/env
|
||||
/Applications//Google\ Chrome.app/Contents/MacOS/Google\ Chrome http://127.0.0.1:9876/info
|
||||
/Applications//Google\ Chrome.app/Contents/MacOS/Google\ Chrome http://127.0.0.1:9876/health
|
||||
/Applications//Google\ Chrome.app/Contents/MacOS/Google\ Chrome http://127.0.0.1:9876/endpoint0
|
||||
3
Demo-3/06 - scale.sh
Executable file
3
Demo-3/06 - scale.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl -n probes scale deployment --replicas=10 probes
|
||||
5
Demo-3/07 - clean up.sh
Executable file
5
Demo-3/07 - clean up.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
kubectl delete namespaces probes
|
||||
|
||||
pkill -f port-forward
|
||||
97
Demo-3/configmap-probes.yaml
Normal file
97
Demo-3/configmap-probes.yaml
Normal file
@@ -0,0 +1,97 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: probes
|
||||
namespace: probes
|
||||
data:
|
||||
readinessprobe.sh: |-
|
||||
#!/bin/bash
|
||||
|
||||
# This script is used to check the readiness of a POD.
|
||||
# If a pod works fine the script exits with exit code 0
|
||||
# otherwise, a non exit code is used.
|
||||
#
|
||||
# Add the following (or similar) code to the helm chart
|
||||
# files in order to use it.
|
||||
#
|
||||
# readinessProbe:
|
||||
# periodSeconds: 3
|
||||
# successThreshold: 1
|
||||
# failureThreshold: 2
|
||||
# initialDelaySeconds: 30
|
||||
# timeoutSeconds: 5
|
||||
# exec:
|
||||
# command:
|
||||
# - /bin/bash
|
||||
# - /probes/readinessprobe.sh
|
||||
#
|
||||
# Consider various tests such as availability of certain filesystems, environment variables
|
||||
# or connectivity/responses from/to (web)servers.
|
||||
|
||||
function probe_log() {
|
||||
echo "$( date +%D-%T ): ${1}" > /proc/1/fd/1
|
||||
exit 1
|
||||
}
|
||||
#
|
||||
# Debug checks:
|
||||
#
|
||||
# Report a NOT READY status if the file /tmp/notready does exist:
|
||||
cat /tmp/notready > /dev/null 2>&1 && probe_log "File /tmp/notready exists"
|
||||
|
||||
# Report A NOT READY status if the file /etc/passwd does NOT exist:
|
||||
cat /etc/passwd > /dev/null 2>&1 || probe_log "File /etc/passwd does not exist"
|
||||
|
||||
# Check if the following filesystem exist.
|
||||
df /dev > /dev/null 2>&1 || probe_log "Filesystem /dev not found"
|
||||
|
||||
# If we reached this point we can assume that everything is fine.
|
||||
# Exit with an okay status
|
||||
exit 0
|
||||
livenessprobe.sh: |-
|
||||
#!/bin/bash
|
||||
|
||||
# This script is used to check the readiness of a POD.
|
||||
# If a pod works fine the script exits with exit code 0
|
||||
# otherwise, a non exit code is used.
|
||||
#
|
||||
# Add the following (or similar) code to the helm chart
|
||||
# files in order to use it.
|
||||
#
|
||||
# livenessProbe:
|
||||
# periodSeconds: 1
|
||||
# successThreshold: 1
|
||||
# failureThreshold: 2
|
||||
# initialDelaySeconds: 30
|
||||
# timeoutSeconds: 5
|
||||
# exec:
|
||||
# command:
|
||||
# - /bin/bash
|
||||
# - /probes/livenessprobe.sh
|
||||
#
|
||||
# Consider various tests such as availability of certain filesystems, environment variables
|
||||
# or connectivity/responses from/to (web)servers.
|
||||
|
||||
function probe_log() {
|
||||
echo "$( date +%D-%T ): ${1}" > /proc/1/fd/1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check the local health page
|
||||
# Use wget and not curl... wget has easier exit codes!
|
||||
wget http://localhost:9876/health -o /dev/null || probe_log "Restarting because healt page is not responding"
|
||||
|
||||
#
|
||||
# Debug checks:
|
||||
#
|
||||
# Report a NOT ALIVE status if the file /tmp/notready does exist:
|
||||
cat /tmp/notalive > /dev/null 2>&1 && probe_log "File /tmp/notalive exists"
|
||||
|
||||
# Report A NOT ALIVE status if the file /etc/passwd does NOT exist:
|
||||
cat /etc/passwd > /dev/null 2>&1 || probe_log "File /etc/passwd does not exist"
|
||||
|
||||
# Check if the following filesystem exist.
|
||||
df /dev > /dev/null 2>&1 || probe_log "Filesystem /dev not found"
|
||||
|
||||
# If we reached this point we can assume that everything is fine.
|
||||
# Exit with an okay status
|
||||
exit 0
|
||||
34
Demo-3/deployment-1.yaml
Normal file
34
Demo-3/deployment-1.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: probes
|
||||
name: probes
|
||||
namespace: probes
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: probes
|
||||
strategy: {}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: probes
|
||||
spec:
|
||||
containers:
|
||||
- image: mhausenblas/simpleservice:0.5.0
|
||||
# https://github.com/mhausenblas/simpleservice
|
||||
name: simpleservice
|
||||
resources:
|
||||
limits:
|
||||
memory: "200Mi"
|
||||
volumeMounts:
|
||||
- name: probes
|
||||
mountPath: "/probes"
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: probes
|
||||
configMap:
|
||||
name: probes
|
||||
status: {}
|
||||
54
Demo-3/deployment-2.yaml
Normal file
54
Demo-3/deployment-2.yaml
Normal file
@@ -0,0 +1,54 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: probes
|
||||
name: probes
|
||||
namespace: probes
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: probes
|
||||
strategy: {}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: probes
|
||||
spec:
|
||||
containers:
|
||||
- image: mhausenblas/simpleservice:0.5.0
|
||||
# https://github.com/mhausenblas/simpleservice
|
||||
name: simpleservice
|
||||
resources:
|
||||
limits:
|
||||
memory: "200Mi"
|
||||
livenessProbe:
|
||||
periodSeconds: 1
|
||||
successThreshold: 1
|
||||
failureThreshold: 2
|
||||
initialDelaySeconds: 30
|
||||
timeoutSeconds: 5
|
||||
exec:
|
||||
command:
|
||||
- /bin/bash
|
||||
- /probes/livenessprobe.sh
|
||||
readinessProbe:
|
||||
periodSeconds: 3
|
||||
successThreshold: 1
|
||||
failureThreshold: 2
|
||||
initialDelaySeconds: 30
|
||||
timeoutSeconds: 5
|
||||
exec:
|
||||
command:
|
||||
- /bin/bash
|
||||
- /probes/readinessprobe.sh
|
||||
volumeMounts:
|
||||
- name: probes
|
||||
mountPath: "/probes"
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: probes
|
||||
configMap:
|
||||
name: probes
|
||||
status: {}
|
||||
18
Demo-3/service.yaml
Normal file
18
Demo-3/service.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: probes
|
||||
name: probes
|
||||
namespace: probes
|
||||
spec:
|
||||
ports:
|
||||
- name: tcp-9876
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 9876
|
||||
selector:
|
||||
app: probes
|
||||
type: ClusterIP
|
||||
status:
|
||||
loadBalancer: {}
|
||||
Reference in New Issue
Block a user