Skip to content

Instantly share code, notes, and snippets.

View Shahid1993's full-sized avatar
🎯
Focusing

Shahid ul Islam Shahid1993

🎯
Focusing
View GitHub Profile

-> % svcs -n twistlock

NAME                TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                      AGE
twistlock-console   ClusterIP   10.103.43.18   <none>        8084/TCP,8083/TCP,8081/TCP   18h

-> % k get ep -n twistlock

NAME                ENDPOINTS                                                  AGE
twistlock-console   10.103.129.17:8081,10.103.129.17:8084,10.103.129.17:8083   18h
livenessProbe:
exec:
command:
- /bin/sh
- -c
- |-
FATAL_ERRORS=$( echo "${LIVENESS_PROBE_FATAL_ERRORS}" | grep -q '\S' && \
grep -F "${LIVENESS_PROBE_FATAL_ERRORS}" /tmp/.liveness_probe )
cp /dev/null /tmp/.liveness_probe
if [ ! -z "${FATAL_ERRORS}" ]; then
kubectl get po -a --all-namespaces -o json | \
jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) |
"kubectl delete po \(.metadata.name) -n \(.metadata.namespace) --grace-period=0 --force " ' | xargs -n 1 bash -c
pinn(){
kubectl get pods --all-namespaces --field-selector spec.nodeName=$1 -o wide
}
@Shahid1993
Shahid1993 / gist:f4a09a238ea9e2c7863851a6a7a0e8f7
Created March 28, 2019 12:28 — forked from ipedrazas/gist:b58c17fd10116b6d39935a6f11365214
Curl to artifactory to publish helm package
@curl --user $(PUBLISH_REPO_USER):$(PUBLISH_REPO_PWD) --upload-file $(PACKAGE) $(PUBLISH_REPO_URL)/$(PUBLISH_REPO_PATH)
@Shahid1993
Shahid1993 / list-images.sh
Created March 28, 2019 12:28 — forked from ipedrazas/list-images.sh
List docker images in a Kubernetes cluster
#!/bin/bash
IMAGES=()
# Get helm releases
helm ls -q | while read i; do
echo "Processing release $i";
# Get docker images per release
helm get "$i" | grep "image: \"" | awk '{print $2}';
done
Name VCPUS RAM Total Disk Root Disk Ephemeral Disk Public
m1.small 1 8 GB 50 GB 50 GB 0 GB Yes
d1.medium 2 16 GB 1.07 TB 100 GB 1000 GB Yes
d1.large 4 32 GB 1.07 TB 100 GB 1000 GB Yes
d1.xlarge 8 64 GB 1.07 TB 100 GB 1000 GB Yes
m1.medium 2 16 GB 100 GB 100 GB 0 GB Yes
m1.large 4 32 GB 200 GB 200 GB 0 GB Yes
m1.xlarge 8 64 GB 400 GB 400 GB 0 GB Yes
m1.2xl 16 128 GB 800 GB 800 GB 0 GB Yes

Debugging in Kubernetes

"How do you debug applications running in Kubernetes?"

The strategy to successfully debugging applications in kubernetes is to be consistent with your approach: application to public traffic or public traffic to application.

The question as it is it's very generic, however, let's see the different components we might have to check in our debugging journey:

  • Container/Pod
  • Service
// https://github.com/stefanprodan/k8s-podinfo/blob/master/pkg/server/instrument.go
func NewInstrument() *Instrument {
// used for monitoring and alerting (RED method)
histogram := prometheus.NewHistogramVec(prometheus.HistogramOpts{
Subsystem: "http",
Name: "requests",
Help: "Seconds spent serving HTTP requests.",
Buckets: prometheus.DefBuckets,
}, []string{"method", "path", "status"})
// setup a signal hander to gracefully exit
func sigHandler() <-chan struct{} {
stop := make(chan struct{})
go func() {
c := make(chan os.Signal, 1)
signal.Notify(c,
syscall.SIGINT, // Ctrl+C
syscall.SIGTERM, // Termination Request
syscall.SIGSEGV, // FullDerp
syscall.SIGABRT, // Abnormal termination