Skip to content

Instantly share code, notes, and snippets.

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

Umar Nawawi umardx

🏠
Working from home
View GitHub Profile
admin@instance-20240226-151936:~$ curl https://test.co.id -v
*   Trying 10.94.2.24:443...
^C
admin@instance-20240226-151936:~$ sudo ipsec start
Starting strongSwan 5.9.8 IPsec [starter]...
admin@instance-20240226-151936:~$ curl https://test.co.id -v -I
*   Trying 10.94.2.24:443...
* Connected to test.co.id (10.94.2.24) port 443 (#0)
* ALPN: offers h2,http/1.1
#!/bin/sh
KEYSTORE_PATH=${ARTIFACT_DIR}/client.keystore.p12
TRUSTORE_PATH=${ARTIFACT_DIR}/client.truststore.jks
PRIVKEY_RSA_PATH=${ARTIFACT_DIR}/service_key.pem
PRIVKEY_PATH=${ARTIFACT_DIR}/service.key
PUBKEY_RSA_PATH=${ARTIFACT_DIR}/service_cert.pem
PUBKEY_PATH=${ARTIFACT_DIR}/service.cert
CAKEY_PATH=${ARTIFACT_DIR}/ca.pem

To DNAT the traffic from 10.1.1.1:5432 to 192.168.1.1:5432 using iptables, you can follow these steps:

  1. Enable IP forwarding:

    sysctl net.ipv4.ip_forward=1
  2. Create the DNAT rule:

iptables -t nat -A PREROUTING -i ens4 -p tcp --dport 5432 -j DNAT --to-destination 192.168.1.1:5432

@umardx
umardx / gist:b8ec1ba3abe50728373fc9c47a83eca3
Created January 9, 2022 05:28
Distribute Pods Evenly Across The Cluster
---
apiVersion: v1
kind: Namespace
metadata:
name: net-tools
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: net-tools
@umardx
umardx / delete_namespace
Created October 3, 2021 13:41 — forked from hrittikhere/delete_namespace
Delete Terminating Namespace
kubectl get namespace "terminating-namespace" -o json \
| tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" \
| kubectl replace --raw /api/v1/namespaces/terminating-namespace/finalize -f -
#!/bin/bash
log=/var/log/docker-prune.log
date +'=== docker-prune execute at %Y.%m.%d %H:%M ===' >> $log
docker system prune -af --filter "until=$((30*24))h" >> $log
@umardx
umardx / delete.sh
Last active January 24, 2022 11:08
#!/bin/sh
ECHO='echo '
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$\|main$\|develop$'); do
if ! ( [[ -f "$branch" ]] || [[ -d "$branch" ]] ) && [[ "$(git log $branch --since "3 month ago" | wc -l)" -eq 0 ]]; then
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///')
$ECHO git branch -d "${local_branch_name}"
$ECHO git push origin --delete "${local_branch_name}"
fi
done
#/bin/bash
echo "${DEPLOYMENT_TARGET_CSV}" | while IFS=, read -r serviceName serviceRole serviceCountry others;do
if [ -z "$serviceName" ] || [ -z "$serviceRole" ] || [ -z "$serviceCountry" ];then
continue
fi
QUERY="INSERT IGNORE INTO newton.deployment_target (service_name,role,country_abbrv) VALUES ('${serviceName}','${serviceRole}','${serviceCountry}');"
echo ">${QUERY}"
mysql --user="$mysql_user" --password="$mysql_password" --host="$mysql_host" -ss --execute="${QUERY}" > /dev/null 2>&1
# Dump mongodb
mongodump --uri "mongodb://username:password@mongo-host:27017/db_name?authSource=admin&readPreference=primary" \
--gzip --archive=backup.gz
# Restore
@umardx
umardx / Dockerfile
Created April 16, 2020 13:57
Create slim docker image
FROM python:3.8-alpine as base
FROM base as builder
WORKDIR /source
COPY requirements.txt /requirements.txt
RUN pip install --install-option="--prefix=/source" -r /requirements.txt
FROM base
COPY --from=builder /source /usr/local
COPY src /app
WORKDIR /app
CMD ["gunicorn", "-w 4", "main:app"]