Skip to content

Instantly share code, notes, and snippets.

@harsh4870
harsh4870 / k8s-aws-ecr-secret-refresh-cronjob.yaml
Created June 19, 2024 19:07
Refresh K8s secret for ECR to pull the private image from AWS
apiVersion: v1
kind: Secret
metadata:
name: ecr-registry-secrets
stringData:
AWS_SECRET_ACCESS_KEY: "rgsssdfasdf"
AWS_ACCESS_KEY_ID: "AFIK"
AWS_ACCOUNT: "12345"
---
apiVersion: v1
@harsh4870
harsh4870 / docker-compose.yaml
Created November 3, 2023 13:59
Docker compose basic Ubuntu & Nginx
version: "3"
services:
ubuntu:
container_name: ubuntu
image: ubuntu
restart: on-failure
command: ["sleep","infinity"]
ports:
- '6379:80'
nginx:
@harsh4870
harsh4870 / docker-compose.yaml
Created February 22, 2023 16:08
Docker compose Redis, MySQL, Elasticsearch, RabbitMQ, Adminer
version: "3.7"
services:
mysql:
container_name: mysql
image: mysql
command: --default-authentication-plugin=mysql_native_password
hostname: mysql
restart: always
volumes:
@harsh4870
harsh4870 / rabbitmq.yaml
Created February 3, 2023 14:28
minikube my gist to install rabbitmq and nginx ingress contoller
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
component: rabbitmq
name: rabbitmq
spec:
serviceName: rabbitmq
replicas: 1
selector:
/* HTTP function get data from event and resize the GKE cluster pools based on data */
const container = require("@google-cloud/container");
const client = new container.v1.ClusterManagerClient();
exports.helloHTTP = async (req, res) => {
console.log(`Request Body`, req.body);
const request = {
projectId: req.body.projectId,
/* PubSub function get data from PubSub and resize the GKE cluster pools based on data */
const Buffer = require("safe-buffer").Buffer;
const container = require("@google-cloud/container");
const client = new container.v1.ClusterManagerClient();
exports.helloPubSub = async (message, context) => {
const payload = JSON.parse(Buffer.from(message.data, "base64").toString());
const request = {
@harsh4870
harsh4870 / import_data.js
Created September 8, 2022 05:22
Import data CSV to Redis
const csvFilePath = 'data/Blocks-IPv4.csv'
const City_csvFilePath = 'data/City-Locations.csv'
const csv = require('csvtojson')
const ipInt = require("ip-to-int");
const IPCIDR = require("ip-cidr");
var redis = require("redis");
const client = redis.createClient();
client.on("error", function(err) {
console.log("Error " + err);
});
@harsh4870
harsh4870 / create_index.js
Created September 8, 2022 05:21
Create index in Redis database using Node js
import {createClient, SchemaFieldTypes, AggregateGroupByReducers, AggregateSteps} from 'redis';
const client = createClient();
client.on("error", function(err) {
console.log("Error " + err);
});
client.connect()
try {
@harsh4870
harsh4870 / client_ip.js
Created September 8, 2022 05:21
Redis to client get IP from index
var redis = require("redis");
const ipInt = require("ip-to-int");
const client = redis.createClient();
client.on("error", function(err) {
console.log("Error " + err);
});
function int_to_ip(ip) {
try {
@harsh4870
harsh4870 / jwt-user-asseration.js
Created August 9, 2022 18:21
JWT assertion Node JS
var jwt = require('jsonwebtoken');
const fs = require('fs');
var request = require("request");
var querystring = require('querystring');
var privateKey = fs.readFileSync('./private_key.pem');
#idcs or keycloak URL
var url = "https://example.com/oauth2/v1/token"
var headers = {
'Authorization': 'Basic <BASE-64 ENCODED client ID & Secret>',