Skip to content

Instantly share code, notes, and snippets.

View aramalipoor's full-sized avatar
🎯
Focusing

aram.eth aramalipoor

🎯
Focusing
View GitHub Profile
@aramalipoor
aramalipoor / okd-share-resources.yml
Last active December 30, 2018 17:02
OKD Role and RoleBinding suitable to share Templates and ImageStreams with other users and projects
apiVersion: v1
kind: Template
metadata:
name: shared-resource-viewer
parameters:
- displayName: Project / Namespace
description: Name of the project (might be current project) from which you want to publish/share Templates and ImageStreams
name: NAMESPACE
required: true
value: my-project-name

Keybase proof

I hereby claim:

  • I am aramalipoor on github.
  • I am alipoor (https://keybase.io/alipoor) on keybase.
  • I have a public key ASBjjvuvZdOlwS8JHQWRBzYVx9d4L05-8oGdJcVpA-7SQQo

To claim this, I am signing this object:

@aramalipoor
aramalipoor / 0-README.md
Last active November 21, 2023 15:52
Secure Kafka brokers with SSL and expose externally in OpenShift/Kubernetes via a passthrough Route

Kafka SSL + OpenShift Routes

To expose Kafka port externally enable SSL/TLS configuration in Kafka.

  1. Build the image based on this Dockerfile
  2. Generate all keys and certificates based on gen.sh. Note Replace <YOUR_KAFKA_DOMAIN_HERE> and passphrase (i.e. test1234).
  3. Create a secret based to store all certificates:
    oc create secret generic kafka-ssl --from-file=/absolute/path/to/generated/certs/dir
  4. Update Kafka's Statefulset to enable SSL (statefulset.yml holds already patched version of our template):
@aramalipoor
aramalipoor / .env
Last active March 28, 2019 07:36
Elasticsearch 6.x + OSS Repository Plugin
# For ES 6.x Java XML Bind module must be explicitly added
ES_JAVA_OPTS=-Xms1000m -Xmx1000m -Des.logger.level=DEBUG --add-modules java.xml.bind
@aramalipoor
aramalipoor / buildconfig.yml
Last active June 24, 2018 15:18
How to use Input Secrets to clone multiple repositories in OpenShift's BuildConfig?
# You can edit a BuildConfig's YAML either via UI
# or by running `oc edit bc/MY_APP`
spec:
# ...
source:
# ...
secrets:
# This path must be relative when BuildConfig's "strategy" is Docker
- destinationDir: secrets/github-myorg
secret:
@aramalipoor
aramalipoor / Dockerfile
Last active April 7, 2022 12:17
How to use Input Secrets to clone multiple repositories in OpenShift's BuildConfig?
FROM debian
RUN apt-get update -y && \
# SSH and git binaries are required
apt-get install -y curl ssh git && \
# Prepare required configurations and directories
mkdir -p /root/.ssh && \
git config --global user.name "example" && \

Nginx Config for real IP when using CloudFlare

If CloudFlare cache is disabled (the cloud icon in DNS settings is turned off, i.e. gray), the nginx config in our examples would work and gives you the real IP in REMOTE_ADDR variable.

If you need to keep CF cache enabled (the cloud icon is active and orange) adding code below to nginx config will give you user's real IP in REMOTE_ADDR variable:

server {
    // ...
    
    real_ip_recursive on;
    real_ip_header X-Forwarded-For;
@aramalipoor
aramalipoor / README.md
Last active February 22, 2018 17:18
Custom WRK (https://github.com/wg/wrk) script to count a response header useful for A/B load testing

Example

wrk -t 5 -c 10 -d 10s -s wrk-hostname-counter.lua https://example.com/

 ------------------------------------------------
 server-b-pxchg: 50.3333% (151 total)
 server-a-n82cc: 3.33333% (10 total)
 server-a-lr665: 3.33333% (10 total)
 server-a-7cnws: 3.33333% (10 total)
@aramalipoor
aramalipoor / Dockerfile
Last active November 23, 2023 14:05
Docker + Alpine + Newrelic + PHP (Kubernetes / AbarCloud)
# Prepare required directories for Newrelic installation
RUN mkdir -p /var/log/newrelic /var/run/newrelic && \
touch /var/log/newrelic/php_agent.log /var/log/newrelic/newrelic-daemon.log && \
chmod -R g+ws /tmp /var/log/newrelic/ /var/run/newrelic/ && \
chown -R 1001:0 /tmp /var/log/newrelic/ /var/run/newrelic/ && \
# Download and install Newrelic binary
export NEWRELIC_VERSION=$(curl -sS https://download.newrelic.com/php_agent/release/ | sed -n 's/.*>\(.*linux-musl\).tar.gz<.*/\1/p') && \
cd /tmp && curl -sS "https://download.newrelic.com/php_agent/release/${NEWRELIC_VERSION}.tar.gz" | gzip -dc | tar xf - && \
cd "${NEWRELIC_VERSION}" && \
@aramalipoor
aramalipoor / README.md
Last active November 25, 2017 17:12
Re-commit snippet to commit your last commit again with same message to your remote, without adding a new commit to history

Install

sudo curl -L -o /usr/local/bin/recommit https://gist.githubusercontent.com/aramalipoor/fa0a501d985b095b4d8ec453e1ba8e56/raw/032275f887799c139a6b06e148b1146c914313b9/recommit.sh
sudo chmod +x /usr/local/bin/recommit

Disclaimer

Although this snippet checks last commit's ID on your remote branch before tying to force commit, use it at your own risk.