Skip to content

Instantly share code, notes, and snippets.

@ipedrazas
ipedrazas / gist:2c93f6e74737d1f8a791
Created September 18, 2014 22:13
List Docker Container Names and IPs
function drips(){
docker ps -q | xargs -n 1 docker inspect --format '{{ .NetworkSettings.IPAddress }} {{ .Name }}' | sed 's/ \// /'
}
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
## Useful Commands
Get kubectl version
kubectl version
Get cluster info:
@ipedrazas
ipedrazas / gist:b58c17fd10116b6d39935a6f11365214
Created December 4, 2018 20:09
Curl to artifactory to publish helm package
@curl --user $(PUBLISH_REPO_USER):$(PUBLISH_REPO_PWD) --upload-file $(PACKAGE) $(PUBLISH_REPO_URL)/$(PUBLISH_REPO_PATH)
@ipedrazas
ipedrazas / gist:403df2ed30ea8682e2b709ddc1c24bcf
Created January 23, 2019 20:24
curl internal service kubernetes kubectl proxy
# To call from outside the cluster a service type `ClusterIP`
# We use `kubectl proxy`
kubectl proxy
# Then, the service can be accessed by calling:
curl http://localhost:8001/api/v1/namespaces/status/services/x01-kstatus-api:5000/proxy/api/jobs
# This is
# curl http://localhost:8001/api/v1/namespaces/[NAMESPACE]/services/[SERVICE:PORT]/proxy/[QUERY_STRING]

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
@ipedrazas
ipedrazas / flask-signal.py
Created August 22, 2020 04:47
Processing SIGTERM in python
import signal
import time
class GracefulKiller:
kill_now = False
def __init__(self):
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
def exit_gracefully(self,signum, frame):
@ipedrazas
ipedrazas / gist:6d6c31144636d586dcc3
Last active July 10, 2023 16:24
Nginx ssl config

The process starts by creating the CSR and the private key:

openssl req -nodes -newkey rsa:2048 -nodes -keyout dotmarks.net.key -out dotmarks.net.csr -subj "/C=GB/ST=London/L=London/O=dotmarks/OU=IT/CN=dotmarks.net"

Generates

  • dotmarks.net.key
  • dotmarks.net.csr
@ipedrazas
ipedrazas / gist:3cf8eb6ae8e77c7c97a5
Created August 22, 2014 21:15
IRSSI: IGNORE JOINS, PARTS, QUITS AND NICKS MESSAGES
/ignore -channels #channel * JOINS PARTS QUITS NICKS
@ipedrazas
ipedrazas / pod.yaml
Created January 17, 2023 12:09
Kubernetes DNS - Adding additional entries with hostAliases
apiVersion: v1
kind: Pod
metadata:
name: hostaliases-pod
spec:
restartPolicy: Never
hostAliases:
- ip: "127.0.0.1"
hostnames:
- "foo.local"