Skip to content

Instantly share code, notes, and snippets.

View prasvats's full-sized avatar

Prashant Vats prasvats

View GitHub Profile
@prasvats
prasvats / deploy.yaml
Created May 14, 2019 09:13
k8-pod-autoscalar
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: rabbit-pod-autoscaler
rules:
- apiGroups: ["*"]
resources: ["deployments"]
verbs: ["get", "list", "update"]
---
@prasvats
prasvats / elastic_kibana.sh
Created May 21, 2019 11:45
Install 3 Node HA ElasticSearch Cluster and Kibana. Version: 5.6.14
#Update apt repository
sudo apt-get update
# Download and install the public signing key
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
#Install apt repo sync
sudo apt-get install apt-transport-https
#Add elastic5.x to apt repository
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
#Update apt repository
sudo apt-get update
@prasvats
prasvats / install_k8.sh
Created May 23, 2019 06:19
Install K8 on CentOS | Pseudo Steps
#!/bin/bash
yum update
#Install repo adder
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum update && yum install docker-ce-18.06.2.ce
mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
@prasvats
prasvats / self-sign-cert
Created June 10, 2019 10:26
Generate Self Sign Certificate
openssl req -new -newkey rsa:2048 -nodes -out magento-2_3_1_suresh_com.csr -keyout magento-2_3_1_suresh_com.key -subj "/C=IN/ST=Delaware/L=Noida/O=TTN/OU=Admin/CN=magento-2.3.1.suresh.com"
openssl x509 -req -days 365 -in magento-2_3_1_suresh_com.csr -signkey magento-2_3_1_suresh_com.key -out magento-2_3_1_suresh_com.crt
@prasvats
prasvats / Jenkins.sh
Created June 25, 2019 15:02
Install Jenkins
sudo apt-get update
sudo locale-gen
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install default-jdk
sudo apt policy jenkins
echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc
echo "export LANG=en_US.UTF-8" >> ~/.bashrc
source ~/.bashrc
@prasvats
prasvats / Exposed_AWS_Resources.sh
Created August 12, 2019 11:13
This Script will check exposed EBS Snapshots, AMI and RDS Snapshots across all AWS region
declare -a regions=("eu-north-1" "ap-south-1" "eu-west-3" "eu-west-2" "eu-west-1" "ap-northeast-2" "ap-northeast-1" "sa-east-1" "ca-central-1" "ap-southeast-1" "ap-southeast-2" "eu-central-1" "us-east-1" "us-east-2" "us-west-1" "us-west-2")
for region in "${regions[@]}"
do
echo "+++++++++++++++++++++++++++++"
echo "Checking for Region: $region"
echo "-----------------------------"
echo "Exposed EBS Snapshots"
aws ec2 --region $region describe-snapshots --owner-id self --restorable-by-user-ids all --no-paginate --output table
echo "Exposed RDS Snapshots"
aws rds --region $region describe-db-snapshots --snapshot-type public --no-paginate --output table
@prasvats
prasvats / trigger_jenkins_job.py
Created September 5, 2019 18:51
Python Script to trigger a Jenkins job remotely
import jenkins
import time
# It comes with pip module python-jenkins
# use pip to install python-jenkins
# Jenkins Authentication URL
JENKINS_URL = "https://xxxx"
JENKINS_USERNAME = "xxxxx"
JENKINS_PASSWORD = "xxxxxxx"
@prasvats
prasvats / debugindocker
Created September 26, 2019 05:07
Debug in Docker Debian
apt-get update
apt-get install telnet -y
apt-get install curl -y
apt-get install net-tools -y
apt-get install procps -y
@prasvats
prasvats / es.py
Created February 26, 2020 06:24
Python Script to test ElasticSearch
import boto3
import json
import requests
from requests_aws4auth import AWS4Auth
#Get Temporary Credentials
credentials = boto3.Session().get_credentials()
service = 'es'
region = 'ap-southeast-2'
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment-50001
spec:
selector:
matchLabels:
app: products
department: sales
replicas: 3