Skip to content

Instantly share code, notes, and snippets.

@bernardoVale
bernardoVale / cleanJob.groovy
Last active July 12, 2018 19:51
Delete all Builds && Restore to Build 1
def jobName = "folder/job/branch"
def job = Jenkins.instance.getItemByFullName(jobName)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.save()
@bernardoVale
bernardoVale / stress.sh
Created January 28, 2018 18:47
Stress test
wrk -c 20 -t 4 -d 600s https://acob-service-staging.avenuecode.com/api/v1/thirdpartyservices
@bernardoVale
bernardoVale / certificate.sh
Last active January 29, 2018 12:21
Converting certificates
# Download ca from
openssl x509 -in ~/Downloads/COMODORSAAddTrustCA.crt -inform DER -out hostname.crt.pem -outform PE
openssl x509 -inform DER -in comodo.crt -out comodo.pem -text
@bernardoVale
bernardoVale / vim.sh
Created January 26, 2018 12:37
Vim Utils
# Base64
:.!base64
# Decode
:.!base64 -D
# . = line
# % = file
# Enter mode visual, select and :!base64
@bernardoVale
bernardoVale / RECREATE.md
Created January 17, 2018 14:06
Recreate Lost PVC with unexistent PV

State, due to a bug Kubernetes lost the state of a persistent volume. The volume existed in AWS, so I've decided to recover the state.

PVC existed but with state Lost:

kubectl -n acdc-legacy get pvc
NAME                                            STATUS    VOLUME                                     CAPACITY   ACCESSMODES   STORAGECLASS   AGE
acdclegacy-staging-data-acdclegacy-postgres-0   Lost      pvc-dbd2ac08-f32e-11e7-b70d-1212ccc85de2   0                        default        10d
@bernardoVale
bernardoVale / expimp.sh
Created January 7, 2018 00:16
Export/Import Postgres
pg_dump -h 54.162.150.192 -d alpha-quester -U aquser -W > alpha.dmp
psql -h 127.0.0.1 -U aquser -W alpha-quester < alpha.dmp
@bernardoVale
bernardoVale / k8s.sh
Created January 5, 2018 12:52
Kubernetes Sheet
# Copy file from pod to my host
kubectl cp kube-system/nginx-ingress-controller-3224139886-92k85:/etc/nginx/nginx.conf nginx.conf
@bernardoVale
bernardoVale / app.py
Last active November 23, 2017 01:08
Flask mysql start
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://flask:flask@127.0.0.1/flask'
db = SQLAlchemy(app)
class Example(db.Model):
__tablename__ = 'example'
@bernardoVale
bernardoVale / update_traefik_acme.sh
Created October 10, 2017 01:03
Update traefik ACME data using Consul
# Download ACME data
consul kv get traefik/acme/account/object > object.txt
# Decode and load into a json file
cat object.txt | base64 -D > object.json
# Do operations in your json file
# Transform into base64 again
cat object.json | base64 > new_object
@bernardoVale
bernardoVale / mount_ebs.sh
Created September 28, 2017 15:43
Mount EBS volume
lsblk
# Check if the disk is empty: Should return /dev/xvdf: data if empty
file -s /dev/xvdf
# Create a fs
mkfs -t ext4 /dev/xvdf
# Allocale folder to hold volume