Skip to content

Instantly share code, notes, and snippets.

View mmehta-10's full-sized avatar

Megha Mehta mmehta-10

  • DevOps and Cloud Consultant
  • India
View GitHub Profile
@mmehta-10
mmehta-10 / get-node-ips.sh
Last active April 15, 2024 12:03
Get count of spare IPs left on each EKS worker node, sorted from oldest to newest node
#!/bin/bash
REGION=us-east-1
# Get a list of all the nodes in the cluster
NODES=$(kubectl get nodes --sort-by=.metadata.creationTimestamp -o=jsonpath='{.items[*].metadata.name}')
K8S_NODES_DATA=$(kubectl get no -ojson)
# Create a temporary file to store combined output
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
# Use alias to fetch from remote and delete any untracked local branches
[alias]
nuke = "!f() { git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == \"[gone]\" {sub(\"refs/heads/\", \"\", $1); print $1}'); do git branch -D $branch; done }; f"
@mmehta-10
mmehta-10 / OFFLINE KUBEADM INSTALLATION.txt
Last active January 9, 2022 08:12
Commands for offline KUBEADM installation
docker pull gcr.io/google_containers/kube-apiserver-amd64:v1.14.2
docker pull gcr.io/google_containers/kube-controller-manager-amd64:v1.14.2
docker pull gcr.io/google_containers/kube-proxy-amd64:v1.14.2
docker pull gcr.io/google_containers/kube-scheduler-amd64:v1.14.2
docker pull gcr.io/google_containers/kubernetes-dashboard-amd64:v1.10.1
docker pull weaveworks/weave-npc:1.8.2
docker pull weaveworks/weave-kube:1.8.2
docker pull gcr.io/google-containers/kube-addon-manager:v6.1
@mmehta-10
mmehta-10 / network-policy.yaml
Last active June 16, 2021 17:50
network-policy-allow-traffic-on-port-8080-from-another-ns
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: NP1
namespace: NS1
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
@mmehta-10
mmehta-10 / kubectl-aliases.txt
Last active April 8, 2023 19:23
Aliases for kubectl commands
alias kc='kubectl'
alias kclf='kubectl logs --tail=200 -f'
alias kcgs='kubectl get service -o wide'
alias kcgd='kubectl get deployment -o wide'
alias kcgp='kubectl get pod -o wide'
alias kcgn='kubectl get node -o wide'
alias kcdp='kubectl describe pod'
alias kcds='kubectl describe service'
alias kcgsa='kubectl get service -o wide --all-namespaces'
alias kcgda='kubectl get deployment -o wide --all-namespaces'

ECS/FARGATE

describe-services
[--cluster <value>]
--services <value>
[--include <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
@mmehta-10
mmehta-10 / kubeadm-troubleshooting-guide.md
Created July 14, 2019 18:38
This doc records solutions to issues faced with setting kubeadm on RHEL EC2, some useful kubectl commands and finally Selenium Grid setup commands at the end

Errors

1. The connection to the server localhost:8080 was refused - did you specify the right host or port?

SOLUTION:

(1)

cp /etc/kubernetes/admin.conf $HOME/
chown $(id -u):$(id -g) $HOME/admin.conf