Skip to content

Instantly share code, notes, and snippets.

@aemneina
aemneina / mem_dump.sh
Created February 7, 2019 05:26
memory dump for rancher server
#!/bin/bash
# Create temp directory
TMPDIR=$(mktemp -d)
cd /tmp/debug
curl localhost:6060/debug/pprof/goroutine -o $TMPDIR/goroutine
curl localhost:6060/debug/pprof/heap -o $TMPDIR/heap
curl localhost:6060/debug/pprof/threadcreate -o $TMPDIR/threadcreate
curl localhost:6060/debug/pprof/block -o $TMPDIR/block
#documented steps, in the rancher docs, to identify/clean up network policies from rancher/k8s. if your k8s cluster started with an early version of rancher, chances are you have network policies defined. This could prevent traffic routing from the ingress controller to rancher.
#check if cluster has a network policy enabled
kubectl get cluster -o=custom-columns=ID:.metadata.name,NAME:.spec.displayName,NETWORKPOLICY:.spec.enableNetworkPolicy
#disable the network policy at the cluster level
kubectl get cluster -o jsonpath='{range .items[*]}{@.metadata.name}{"\n"}{end}' | xargs -I {} kubectl patch cluster {} --type merge -p '{"spec": {"enableNetworkPolicy": false}}'
#delete network policies for each of the following namespaces
for namespace in kube-system kube-public cattle-system cattle-alerting cattle-logging cattle-pipeline ingress-nginx; do
kubectl -n $namespace delete networkpolicy --all;
@aemneina
aemneina / websocket-proxy-dump
Created March 20, 2018 04:17
websocket-proxy thread dump
SIGQUIT: quit
PC=0x45e53a m=0
goroutine 0 [idle]:
runtime.rtsigprocmask(0xc800000002, 0xc820009894, 0x0)
/usr/local/go/src/runtime/sys_linux_amd64.s:206 +0x1a
runtime.updatesigmask(0x0, 0x0)
/usr/local/go/src/runtime/os1_linux.go:381 +0xfd
runtime.dieFromSignal(0x2)
/usr/local/go/src/runtime/signal1_unix.go:191 +0x3c
2018-01-08T14:26:22.852-0700 [DEBUG] plugin.terraform-provider-rancher_v1.2.0_x4: 2018/01/08 14:26:22 [INFO] Rancher Client configured for url: http://<some.host>:8080/v2-beta
2018-01-08T14:26:22.872-0700 [DEBUG] plugin.terraform-provider-rancher_v1.2.0_x4: panic: runtime error: invalid memory address or nil pointer dereference
2018-01-08T14:26:22.872-0700 [DEBUG] plugin.terraform-provider-rancher_v1.2.0_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x165f234]
2018-01-08T14:26:22.872-0700 [DEBUG] plugin.terraform-provider-rancher_v1.2.0_x4:
2018-01-08T14:26:22.872-0700 [DEBUG] plugin.terraform-provider-rancher_v1.2.0_x4: goroutine 97 [running]:
2018-01-08T14:26:22.872-0700 [DEBUG] plugin.terraform-provider-rancher_v1.2.0_x4: github.com/terraform-providers/terraform-provider-rancher/rancher.(*Config).EnvironmentClient(0xc4203ba1b0, 0xc420574014, 0x4, 0x170e620, 0xc4201b2aa0, 0x70)
2018-01-08T14:26:22.872-0700 [DEBUG] plugin.terraform-provider-rancher_v1.2.0_x4: /opt/teamcity-agent/work/22
for i in `curl -s rancher-metadata/latest/self/service/containers/| cut -f1 -d=` ; do ping -c2 `curl -s curl rancher-metadata/latest/self/service/containers/$i/primary_ip` ; done