Skip to content

Instantly share code, notes, and snippets.

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

hatem ben tayeb hatembentayeb

🏠
Working from home
View GitHub Profile
@hatembentayeb
hatembentayeb / argocd-app-of-apps-generation.sh
Created October 24, 2023 20:53
generate argocd app of apps from an existing project/applications
#!/bin/bash
output_file="all_applications-$project_name.yaml"
echo "" > "$output_file"
project_yaml=$(kubectl get AppProject "$project_name" -n argocd -o yaml)
updated_project_yaml=$(echo "$project_yaml" | yq eval 'del(.metadata.creationTimestamp, .metadata.generation, .metadata.resourceVersion,.status, .metadata.uid, .metadata.annotations."kubectl.kubernetes.io/last-applied-configuration")' -)
echo "$updated_project_yaml" >> "$output_file"
echo '---' >> "$output_file"
for app_name in $(kubectl get applications -n argocd -o custom-columns=:.metadata.name --no-headers); do
@Dainerx
Dainerx / chapatti-simulation.go
Last active November 30, 2020 17:17
Simulating a chapatti store
package main
import (
"fmt"
"log"
"math/rand"
"time"
)
type ChappatiStore struct {
@hatembentayeb
hatembentayeb / backup_mongo.sh
Last active August 5, 2020 14:06
effective mongodb backup using docker containers
#!/bin/bash
#maintainer : hatem ben tayeb <hatemtayeb2@gmail.com>
# usage : ./backup.sh <container name> <container network>
if [ ! -z $1 ]
then
declare log_path="/backups/backup.log" # make sure to create them manually or change it with your customized path
declare IP=$(docker inspect $1 | jq ".[].NetworkSettings.Networks.$2.IPAddress" -r)
ping -c2 $IP 2>/dev/null 1>/dev/null
if [ $? = 0 ]
#!/bin/bash
# Provide your own unique aksname within the Azure AD tenant
aksname="run-it-on-cloud"
resourcegroup="runItOnCloud"
location="westeurope"
# Create the Azure AD application Server
serverApplicationId=$(az ad app create \
--display-name "${aksname}Server" \
@tvvignesh
tvvignesh / .gitlab-ci.yml
Created December 22, 2019 17:46
Example on running Skaffold with GITLAB CI for Kubernetes in GKE (Make sure you modify it appropriately and set GCP_SERVICE_KEY and GCP_PROD_SERVICE_KEY variable in Gitlab with the service account json value)
services:
- docker:dind
stages:
- development
- production
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ''
@hatembentayeb
hatembentayeb / .gitlab-ci.yml
Created November 10, 2019 04:29
my gitlab-ci configuration
.caching_rust: &caching_rust
cache:
paths:
- .cargo/
- .cache/sccache
- target/x86_64-unknown-linux-musl/release/material
stages:
- build_binary
- build_docker
@hatembentayeb
hatembentayeb / Dockerfile
Last active November 10, 2019 03:43
My Dockerfile for a Rust Project
FROM rustdocker/rust:nightly as cargo-build
RUN apt-get update
RUN apt-get install musl-tools -y
RUN /root/.cargo/bin/rustup target add x86_64-unknown-linux-musl
RUN USER=root /root/.cargo/bin/cargo new --bin material
WORKDIR /material
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
RUN RUSTFLAGS=-Clinker=musl-gcc /root/.cargo/bin/cargo build --release --target=x86_64-unknown-linux-musl --features vendored
RUN rm -f target/x86_64-unknown-linux-musl/release/deps/material*
@6aditya8
6aditya8 / nginx.conf
Last active July 7, 2022 08:00
Nginx SSL/TLS configuration for getting "A+" in Qualys SSL Labs test
# Configuration options are limited to SSL/TLS
# Enable SSL session caching for improving performance by avoiding the costly session negotiation process where possible
# SSL Labs doesn't assume that SNI is available to the client, so it only tests the default virtual server
# setting this globally to make it work across all the nginx virtual servers (including the default virtual server)
ssl_session_cache shared:ssl_session_cache:10m;
ssl_session_timeout 10m;
server {
listen 443 ssl;
@marcopaga
marcopaga / lets-encrypt-wildcard-certs-using-azure-dns-on-aks.md
Last active November 2, 2022 09:52
Let's encrypt wildcard TLS certificates for Azure DNS using cert-manager on AKS (Azure Kubernetes Service)

This gist will guide you through the setup of a wildcard Let's encrypt TLS certificate.

Let's encrypt

Let’s encrypt is one of a new kind of Certificate Authority. You can get a TLS certificate from them for your website free of charge and without any manual overhead. These certificates are trusted in most browsers that are out there and will show up as valid. Instead of sending Mails or even paper around you can call an API and prove your domain ownership with simple challenges. Basically you call the API with a hostname or domain name you need a TLS certificate for and you get back a challenge string that you need to put in a well known location on your http host or as a txt record in your dns system.

The little helper for Kubernetes: Cert-Manager

You can find many clients that manage the proces

@5car1z
5car1z / fail2ban-playbook.yml
Last active December 9, 2023 18:42
Simple Ansible playbook to install Fail2ban.
---
- name: installs fail2ban on ansible hosts
hosts: fail2ban-hosts
become: yes
tasks:
- name: install apt fail2ban packages
apt:
name: "{{ item }}"
state: latest