Skip to content

Instantly share code, notes, and snippets.

View anokun7's full-sized avatar
🎯
Focusing

Anoop Kumar anokun7

🎯
Focusing
View GitHub Profile
@anokun7
anokun7 / random-logs.md
Created March 9, 2020 19:11
To generate random strings (simulate logging) to a file

To generate random strings (simulate logging)

 while true ; do head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 | tee /var/log/100.log ; echo "" >> /var/log/100.log ; sleep 1; done
@anokun7
anokun7 / ab-cmd.md
Last active December 22, 2019 17:47

Example of using Apache Bench command to post data to a url (on a mac):

I use bat instead of cat

$$>> bat data.json
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: delete.json
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 1 │ {"Another": "Echo"}
@anokun7
anokun7 / current-sa.md
Created December 20, 2019 15:55
To find the real current service account being used by kubectl
awk '{print $2" "$3}' <(k get secret --all-namespaces -o custom-columns=token:.data.token,namespace:.metadata.namespace,name:.metadata.name | grep `k config view -o jsonpath='{.users[].user.token}' | base64`) | xargs
@anokun7
anokun7 / pods-per-namespace.md
Last active December 30, 2019 17:23
To find pods per namespace
k get ns -o custom-columns=X:.metadata.name --no-headers | \
xargs  -I {} sh -c "kubectl get ns {} -o jsonpath='{.metadata.name}' && \
printf ' ' && kubectl get pod -n {} | wc -l"

To get pods from only two namespaces:

 k get pod -o wide --all-namespaces -o \
 go-template='{{range .items}}{{if or (eq .metadata.namespace "das-linux-qtadata.namespace}}\

Get missing nodes:

[anoopkumar@a-d-docucp01 ~]$ sdiff -s <(!!) <(docker node ls | grep -Eiv 'HOSTNAME|a-d-docucp01|DOCWWN0' | awk '{ print $2 }' | sort)
sdiff -s <(for i in {2..18} ; do ssh a$i hostname ; done | sort) <(docker node ls | grep -Eiv 'HOSTNAME|a-d-docucp01|DOCWWN0' | awk '{ print $2 }' | sort)
a-d-docwn01                                                   <
a-d-docwn02                                                   <
a-d-docwn03                                                   <
a-d-docwn05                                                   <
a-d-docwn08 &lt;
@anokun7
anokun7 / main.go
Created August 1, 2017 16:05 — forked from filewalkwithme/main.go
Listening multiple ports on golang http servers
package main
import (
"net/http"
)
func main() {
finish := make(chan bool)
server8001 := http.NewServeMux()
@anokun7
anokun7 / vim_on_mac.md
Last active May 6, 2016 23:35
Key mappings for copy paste from Vim on Mac (Yosemite)

Add these key mappings in ~/.vimrc

vmap <C-x> :!pbcopy<CR>
nmap <C-a> ggVG:w !pbcopy<CR><CR>
vmap <C-c> :w !pbcopy<CR><CR>

In visual selection mode, hit Ctrl-c to copy selected text. (Command key will never work within Vim) In visual selection mode, hit Ctrl-x to cut selected text. Hit Ctrl-a to copy the entire file contents in vim.

@anokun7
anokun7 / UCP-installation-aws.md
Created March 17, 2016 02:25
hands-free installation of UCP [aka Single command install] on aws
docker run -it --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v docker_subscription.lic:/docker_subscription.lic \
--name ucp docker/ucp install --fresh-install \
--san $(curl http://169.254.169.254/latest/meta-data/public-hostname)

The user id & password will default to admin/orca

docker-machine create -d virtualbox kv
docker $(docker-machine config kv) login
docker $(docker-machine config kv) run -d -p 8500:8500 -h consul progrium/consul -server -bootstrap
docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery="consul://$(docker-machine ip kv):8500" --engine-opt="cluster-store=consul://$(docker-machine
 ip kv):8500" --engine-opt="cluster-advertise=eth1:2376" swarm-manager
docker-machine create -d virtualbox --swarm --swarm-discovery="consul://$(docker-machine ip kv):8500" --engine-opt="cluster-store=consul://$(docker-machine ip kv):8500" -
-engine-opt="cluster-advertise=eth1:2376" node1
docker-machine create -d virtualbox --swarm --swarm-discovery="consul://$(docker-machine ip kv):8500" --engine-opt="cluster-store=consul://$(docker-machine ip kv):8500" --engine-opt="cluster-advertise=eth1:2376" node2
eval "$(docker-machine env --swarm swarm-manager)"
version: "2"
services:
  voting-app:
      image: docker/example-voting-app-voting-app
      ports:
      - "80"
      networks:
      - votenet
 result-app: