Skip to content

Instantly share code, notes, and snippets.

Avatar

Ivan Pedrazas ipedrazas

View GitHub Profile
@ipedrazas
ipedrazas / dump
Created Apr 22, 2017
Mongo dump/restore with docker
View dump
# Backup DB
docker run \
--rm \
--link running_mongo:mongo \
-v /data/mongo/backup:/backup \
mongo \
bash -c ‘mongodump --out /backup --host $MONGO_PORT_27017_TCP_ADDR’
# Download the dump
scp -r USER@REMOTE:/data/mongo/backup ./backup
View gist:9c622404fb41f2343a0db85b3821275d
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
View gist:6d6c31144636d586dcc3

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
View gist:95391ffd88190bea94ca188d3d2c1cbe
## Useful Commands
Get kubectl version
kubectl version
Get cluster info:
@ipedrazas
ipedrazas / gist:2c93f6e74737d1f8a791
Created Sep 18, 2014
List Docker Container Names and IPs
View gist:2c93f6e74737d1f8a791
function drips(){
docker ps -q | xargs -n 1 docker inspect --format '{{ .NetworkSettings.IPAddress }} {{ .Name }}' | sed 's/ \// /'
}
@ipedrazas
ipedrazas / deployment.yaml
Created Oct 17, 2017
iterate over secrets in helm
View deployment.yaml
env:
{{- range $secret := .Values.secrets }}
{{- if eq $secret.type "env" }}
{{- range $key := $secret.keys }}
{{- $envPrefix := $secret.prefix | default "" | upper }}
{{- $envKey := $key | upper | replace "." "_" | replace "-" "_" }}
- name: {{ $envPrefix }}{{ $envKey }}
valueFrom:
secretKeyRef:
name: {{ $secret.name }}
View gist:f25075f03f87c669025854f99e14f836
minikube start --vm-driver=xhyve --container-runtime=docker --show-libmachine-logs --v=10 --alsologtostderr --cpus 4 --memory 8192
@ipedrazas
ipedrazas / flask-signal.py
Created Aug 22, 2020
Processing SIGTERM in python
View flask-signal.py
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):
View knife cheat
# knife cheat
## Search Examples
knife search "name:ip*"
knife search "platform:ubuntu*"
knife search "platform:*" -a macaddress
knife search "platform:ubuntu*" -a uptime
knife search "platform:ubuntu*" -a virtualization.system
knife search "platform:ubuntu*" -a network.default_gateway
@ipedrazas
ipedrazas / gist:b58c17fd10116b6d39935a6f11365214
Created Dec 4, 2018
Curl to artifactory to publish helm package
View gist:b58c17fd10116b6d39935a6f11365214
@curl --user $(PUBLISH_REPO_USER):$(PUBLISH_REPO_PWD) --upload-file $(PACKAGE) $(PUBLISH_REPO_URL)/$(PUBLISH_REPO_PATH)
You can’t perform that action at this time.