Skip to content

Instantly share code, notes, and snippets.

View nirbhabbarat's full-sized avatar
🎯
Focusing

Nirbhab Barat nirbhabbarat

🎯
Focusing
  • Gurgaon
View GitHub Profile
@nirbhabbarat
nirbhabbarat / Readme.md
Created August 15, 2020 10:47
Integrate gitlab installed in minikube and kubenetes running in same minikube
@nirbhabbarat
nirbhabbarat / gitlab-on-minikube-helm3.md
Last active October 16, 2024 08:32
setup gitlab on minikube using helm3

Setup gitlab on minikube using helm3

Start minikube with virtualbox driver

minikube start \
  --driver=virtualbox \
  --cpus 4 \
  --memory 8192

Recomended: 8 CPU and 30 GB RAM (for demo we are going to use minimal setup)

@nirbhabbarat
nirbhabbarat / Vagrantfile
Created July 20, 2020 13:35
Vagrant file to install 1 master and 1 node in local (node will not join) as its for dev env for CKAD learning. Check kubeadm_init.log for join command in master.
Vagrant.configure("2") do |config|
config.vm.provision :shell, privileged: true, inline: $install_common_tools
config.vm.define :master do |master|
master.vm.provider :virtualbox do |vb|
vb.name = "master"
vb.memory = 4048
vb.cpus = 2
end
master.vm.box = "ubuntu/bionic64"
#master.disksize.size = "25GB"
@nirbhabbarat
nirbhabbarat / custom-build-python3-openssl.sh
Created March 24, 2020 09:39
Installing python 3 from source with custom version of openssl
## Install OpenSSL
wget https://www.openssl.org/source/openssl-1.1.1e.tar.gz
./config shared --prefix=/opt/openssl --openssldir=/opt/openssl/openssl
make && make install
export LDFLAGS="-L/opt/openssl/lib/"
export LD_LIBRARY_PATH="/opt/openssl/lib/"
export CPPFLAGS="-I/opt/openssl/include -I/opt/openssl/include/openssl"
@nirbhabbarat
nirbhabbarat / elasticsearch.yml
Created July 1, 2019 13:42
elasticsearch and kibana - single node in minikube for testing only
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: es-master
labels:
component: elasticsearch
role: master
app: elasticsearch
spec:
replicas: 1
@nirbhabbarat
nirbhabbarat / s3_tag_name.py
Created September 10, 2018 09:04
Add Name tag to S3 bucket same as bucket name
import boto3
s3 = boto3.client('s3')
response = s3.list_buckets()
buckets = [bucket['Name'] for bucket in response['Buckets']]
for bucket in buckets:
print bucket
tag={'TagSet':[{'Key': 'Name', 'Value': bucket}]}
try:
response = s3.put_bucket_tagging(Bucket=bucket, Tagging=tag)
@nirbhabbarat
nirbhabbarat / rotate_ondemand_spotinst_groups.py
Last active February 19, 2018 08:23
Rotate all the ondemand machines which are not in spot - spotinst
import time
import datetime
import requests
import boto3
aws_profile_name = 'default'
token = 'XXX' # generate token from http://docs.spotinst.com/#page:authentication,header:header-permanent-access-token
headers = {'Authorization': 'Bearer '+token}
def get_instance_by_id(id):
@nirbhabbarat
nirbhabbarat / cleanup_aws_volume_snapshot.py
Created February 18, 2018 06:48
Delete AWS volume snapshots older than 30 days via python boto3
#!/usr/bin/env python
##### USE ON YOUR OWN RISK - THIS IS GOING TO delete_snapshot OLDER THAN 30 DAYS
import datetime
import sys
import boto3
age = 30
aws_profile_name = 'prod'
def days_old(date):
date_obj = date.replace(tzinfo=None)
diff = datetime.datetime.now() - date_obj
@nirbhabbarat
nirbhabbarat / delete_unused_eip.py
Created February 12, 2018 17:37
As EIP are billed if unused in AWS, simple script to delete all unused EIPs
import os
import boto3
key=os.environ['TF_VAR_aws_access_key']
secret=os.environ['TF_VAR_aws_secret_key']
client = boto3.client('ec2', region_name=os.environ['TF_VAR_region'], aws_access_key_id=key, aws_secret_access_key=secret)
def elastic_ips_cleanup(client_connection):
""" Cleanup elastic IPs that are not being used """
addresses_dict = client_connection.describe_addresses()
@nirbhabbarat
nirbhabbarat / create_status_check_90_cpu_ec2.py
Created February 12, 2018 17:34
Create status check and 90% CPU alert on all EC2 machines in AWS
#!/usr/bin/env python
# find REPLACE_WITH_ARN and replace with real SNS ARN
import boto3
from dateutil.parser import parse
import datetime
aws_profile_name = 'prod'
def get_instance_name(fid):