Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

abdennour abdennour

🌴
On vacation
Block or report user

Report or block abdennour

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@abdennour
abdennour / nginx.repo
Created Oct 11, 2019
Yum Repo for Nginx
View nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1
@abdennour
abdennour / read-pipe-stdin
Created Oct 4, 2019
Bash script reads from pipe, stdin < or first argument
View read-pipe-stdin
#!/bin/bash
# Available SYNTAX:
# --- $0 /path/file
# --- $0 < /path/file
# --- echo "my content" | $0
# either comes from first argument or from /dev/stdin.
content_to_replace="${1:-/dev/stdin}"
@abdennour
abdennour / Dockerfile
Created Oct 4, 2019
Dynamically replace environment variable names by its values inside file
View Dockerfile
FROM perl:5-slim
WORKDIR /data
COPY myfile.txt .
RUN perl -pe 's/\$([_A-Z]+)/$ENV{$1}/g' < myfile.txt > /tmp/myfile.txt
RUN perl -pe 's/\$(\{)?([a-zA-Z_]\w*)(?(1)\})/$ENV{$2}/g' < /tmp/myfile.txt > myfile.txt
# Only substitute variable that are defined perl -pe 's{\$(\{)?(\w+)(?(1)\})}{$ENV{$2} // $&}ge'
@abdennour
abdennour / bitbucket_backup.sh
Created Sep 17, 2019
Backup All Git Repos with All branches
View bitbucket_backup.sh
#!/bin/bash
team=${1};
repos_list_file=${2};
while read repo; do
if [[ ! -d "$repo" ]]; then
echo $repo clone...
git clone git@bitbucket.org:${team}/${repo}.git;
TIMEOUT=$((5 + RANDOM % 10));
@abdennour
abdennour / README.md
Created Sep 15, 2019
Sketch Shortcut Cheat Sheet
@abdennour
abdennour / 00-infra.yaml
Last active Sep 21, 2019
Jenkins declarative Pipeline in Kubernetes with Parallel and Sequential steps
View 00-infra.yaml
apiVersion: v1
kind: Pod
spec:
# dnsConfig:
# options:
# - name: ndots
# value: "1"
containers:
- name: dind
image: abdennour/docker:19-dind-bash
@abdennour
abdennour / vault-policy-sample.sh
Last active Sep 13, 2019
Create ACL policy in Vault and Create User with that Policy
View vault-policy-sample.sh
#!/bin/bash
# vault server -dev -dev-root-token-id="root"
policy_name=mypolicy
# export VAULT_ADDR='http://127.0.0.1:8200';
# pre-validation
vault secrets list
vault policy list
# add policy
@abdennour
abdennour / k8s_node_maintenance_done.sh
Created Sep 7, 2019
Scripts for Maintaining Kubernetes Nodes
View k8s_node_maintenance_done.sh
#!/bin/bash
node=${1};
k uncordon ${node}
@abdennour
abdennour / df_k8s_nodes.sh
Last active Sep 7, 2019
Check K8s Nodes Disk Space without SSH
View df_k8s_nodes.sh
cat <<EOF | kubectl apply -f -
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: disk-checker
labels:
tier: monitoring
app: disk-checker
version: v1
spec:
@abdennour
abdennour / kind_up.sh
Created Sep 7, 2019
Run Cluster Command in one Command
View kind_up.sh
#!/bin/bash
kind_version=${1:-"v0.5.1"}
kind_bin_path=/usr/local/bin/kind
if [ ! -f ${kind_bin_path} ]; then
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${kind_version}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv ./kind ${kind_bin_path}
fi
You can’t perform that action at this time.