Skip to content

Instantly share code, notes, and snippets.

@dkeightley
dkeightley / proxyConfiguration.json
Last active April 12, 2019 02:30
ecs-proxyConfiguration
"proxyConfiguration": {
"type": "APPMESH",
"containerName": "envoy",
"properties": [
[...]
{
"name": "AppPorts",
"value": "80"
},
{
@dkeightley
dkeightley / app-mesh-initcontainer.yaml
Created April 12, 2019 03:07
initContainer Pod listening on Port 80
initContainers:
- name: proxyinit
image: 111345817488.dkr.ecr.us-west-2.amazonaws.com/aws-appmesh-proxy-route-manager:latest
securityContext:
capabilities:
add:
- NET_ADMIN
env:
- name: "APPMESH_START_ENABLED"
value: "1"
@dkeightley
dkeightley / python-signal.py
Created May 31, 2019 14:41
Example signal handling in Python
import signal
import sys
def exit_gracefully(signumber, frame):
print("Received signal", signumber, "cleaning up...")
sys.exit(0)
signal.signal(signal.SIGTERM, exit_gracefully)
## Do stuff here
@dkeightley
dkeightley / deployment-nginx-not-ready.yml
Created June 1, 2019 03:42
Nginx deployment demonstrating liveness and readiness probes, it won't reach a ready state until /ready succeeds
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-not-ready
spec:
replicas: 1
selector:
matchLabels:
app: nginx-not-ready
template:
@dkeightley
dkeightley / pod-requests-limits.yml
Created June 1, 2019 05:14
Example of an Nginx Pod with CPU/Mem requests and limits
apiVersion: v1
kind: Pod
metadata:
name: nginx-requests-limits
spec:
containers:
- name: nginx-requests-limits
image: nginx
resources:
requests:
#!/bin/bash
CLUSTER="cluster name"
/etc/eks/bootstrap.sh $CLUSTER --kubelet-extra-args \
'--kube-reserved=cpu=200m,memory=256Mi,ephemeral-storage=1Gi \
--system-reserved=cpu=200m,memory=256Mi,ephemeral-storage=1Gi'
apiVersion: v1
kind: Service
metadata:
name: hostname-app
spec:
ports:
- port: 80
targetPort: 9376
selector:
app: hostname
Content-Type: multipart/mixed; boundary="==BOUNDARY=="
MIME-Version: 1.0
--==BOUNDARY==
Content-Type: text/cloud-boothook; charset="us-ascii"
# Set the proxy hostname and port
PROXY="proxy.local:3128"
# Set the proxy for future processes, and use as an include file
cat << EOF >> /etc/proxy.conf
@dkeightley
dkeightley / curl-format.txt
Created October 18, 2019 02:22
Curl with stats
http_code: %{http_code}\n
http_connect: %{http_connect}\n
time_total: %{time_total}\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
size_download: %{size_download}\n
@dkeightley
dkeightley / ingress-to-pod.sh
Last active February 2, 2020 21:21
Rancher ingress to Pod curl
SERVICE=nginx
NAMESPACE=default
for ingresspod in $(kubectl -n ingress-nginx get pods -l app=ingress-nginx --template '{{range.items}}{{.metadata.name}}{{"\n"}}{{end}}')
do
echo $ingresspod
for svcep in $(kubectl -n $NAMESPACE get ep $SERVICE -o json | jq -r .subsets[].addresses[].ip)
do
echo "=> ${svcep}"
kubectl -n ingress-nginx exec $ingresspod -- curl -o /dev/null -s -w 'Connect: %{time_connect}\nStart Transfer: %{time_starttransfer}\nTotal: %{time_total}\nResponse code: %{http_code}\n' -k http://${svcep}