Skip to content

Instantly share code, notes, and snippets.

View vishnuhd's full-sized avatar
🎯
Focusing

Vishnu Hari Dadhich vishnuhd

🎯
Focusing
View GitHub Profile
@vishnuhd
vishnuhd / README.md
Created November 16, 2022 08:01
Quickly deploy a sample deployment

kubectl create deployment hello-app --image=gcr.io/google-samples/hello-app:2.0

@vishnuhd
vishnuhd / commands.md
Last active August 18, 2021 02:18
Helpful daily work commands for mac
  • Top 30 folders directories disk space sorted by size desc
du -h | sort -rh | head -30
  • Find a particular file or dir in current dir recursively
find . -name "darwin_amd64" -type d -print0
@vishnuhd
vishnuhd / mysql-docker.sh
Created May 28, 2020 10:51 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@vishnuhd
vishnuhd / readme.md
Created April 22, 2020 10:28
Export and Import mysql db

Export

mysqldump --column-statistics=0 -h hostname -u root -p dbname > backup.sql

Import

mysql -h hostname -u root -p dbname < backup.sql
@vishnuhd
vishnuhd / app.py
Created April 18, 2020 10:10
Python script to create encrypted secrets in AWS secret manager using KMS Key
import boto3
import os
import json
filename = 'data.json'
kms_id = ''
secretdata= {"username":"chris","password":"BnQw!XDWgaEeT9XGTT29"}
secret_data={}
for k,v in secretdata.items():
encrypt_string = os.popen(("aws kms encrypt --key-id %s --plaintext '%s' --query CiphertextBlob --output text" % (kms_id, v))).read()
secret_data[k] = encrypt_string
@vishnuhd
vishnuhd / readme.md
Created April 14, 2020 06:03
Jenkins generic webhook trigger

Put the following in github webhook section:

https://jenkins.example.com/v1/generic-webhook-trigger/invoke?token=my-token&apiKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

where :

apiKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx is for API Gateway api key token=my-token is same as configured in Jenkins job

@vishnuhd
vishnuhd / readme.md
Last active September 2, 2020 07:09
Setup admin service account
  • Get the context :
CONTEXT=$(kubectl config current-context)
  • Create the required service account and cluster role binding :
apiVersion: v1
kind: ServiceAccount
metadata:
@vishnuhd
vishnuhd / cluster.yaml
Created April 9, 2020 17:51
eksctl managed node group
# cluster.yaml
# A cluster with managed nodegroup
# Setup aws profile if you have many:
# `export AWS_PROFILE=test`
# `export AWS_DEFAULT_PROFILE=test`
# Run the command:
# `eksctl create cluster -f cluster.yaml --write-kubeconfig --set-kubeconfig-context`
---
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1578057396" LAST_MODIFIED="0" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks bar</H3>
<DL><p>
Questions are not from any actual exam!!!
Q: Create a secret that has the following username password data:
username=missawesome
password=123kube321
Create a pod running nginx that has access to those data items in a volume mount path at /tmp/secret-volume
log into the nginx pod you created and list the items and cat the output of the data items to a file "credentials.txt"