Skip to content

Instantly share code, notes, and snippets.

View mvillarrealb's full-sized avatar
🏠
Working from home

Marco Villarreal mvillarrealb

🏠
Working from home
View GitHub Profile
@mvillarrealb
mvillarrealb / port_forward.sh
Created April 7, 2019 02:52
SImple port forward demo
#create a port forward wich exposes your mysql service to the local machine
kubectl port-forward svc/local-database-mysql 3306 -n test
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_ROOT_PASSWORD=FUnIsntSOmethingOneConsiderWhenBalancingTheUniverse
#Use mysql-client to connect to the host
mysql -h $MYSQL_HOST -P$MYSQL_PORT -u root -p$MYSQL_ROOT_PASSWORD
@mvillarrealb
mvillarrealb / install_mysql.sh
Created April 7, 2019 02:51
Install Mysql using helm
helm install --name local-database --namespace test -f mysql.yaml stable/mysql
@mvillarrealb
mvillarrealb / mysql.yaml
Created April 7, 2019 02:50
values.yaml for stable/mysql helm deployment test
---
mysqlUser: localUsr
mysqlPassword: localUsrxPwd#
mysqlRootPassword: FUnIsntSOmethingOneConsiderWhenBalancingTheUniverse
persistence:
enabled: true
storageClass: local-path
@mvillarrealb
mvillarrealb / init_tiller_helm.sh
Created April 7, 2019 02:48
Create tiller service account and links to kubernetes cluster
#Create tiller service account
kubectl -n kube-system create serviceaccount tiller
#Create cluster role binding for tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
#Initialize tiller
helm init --service-account tiller
@mvillarrealb
mvillarrealb / install_helm.sh
Created April 7, 2019 02:46
Install helm on linux
#download helm
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > install-helm.sh
#Make instalation script executable
chmod u+x install-helm.sh
#Install helm
./install-helm.sh
@mvillarrealb
mvillarrealb / create_storage_class.sh
Created April 7, 2019 02:45
Create a storage class for a local kubernetes cluster
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
kubectl get storageclass
@mvillarrealb
mvillarrealb / recursiveScanAsync.js
Created March 1, 2019 14:23
Scans a directory in a recursive way using promises with async and await
const fs = require('fs');
const path = require('path');
const {
promisify
} = require('util');
/**
Add Promise sugar to the fs.readdir and fs.stat functions
*/
const fsReadDir = promisify(fs.readdir);
const fsStat = promisify(fs.stat);
@mvillarrealb
mvillarrealb / RecursiveScan.js
Created March 1, 2019 13:54
Scan recursively a directory to find all files, in the example we filter markdown(.md) files
const fs = require('fs');
const path = require('path');
/**
*
* @param {String} Directory to scan
* @param {Array} allFiles partial list of files(used for recursivity)
*/
const recursiveScan = function (directory, allFiles) {
const files = fs.readdirSync(directory);
allFiles = allFiles || [];
@mvillarrealb
mvillarrealb / build-images.sh
Created September 23, 2018 17:52
Script to build custom docker images spark-base, spark-master, spark-worker and spark-submit
#!/bin/bash
set -e
docker build -t spark-base:2.3.1 ./docker/base
docker build -t spark-master:2.3.1 ./docker/spark-master
docker build -t spark-worker:2.3.1 ./docker/spark-worker
docker build -t spark-submit:2.3.1 ./docker/spark-submit
@mvillarrealb
mvillarrealb / spark-cluster-docker-compose.yml
Created September 23, 2018 17:37
A docker compose to create a spark standalone cluster using custom base images spark-master:2.3.1 and spark-worker:2.3.1
version: "3.7"
services:
spark-master:
image: spark-master:2.3.1
container_name: spark-master
hostname: spark-master
ports:
- "8080:8080"
- "7077:7077"
networks: