Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
kubedl() {
echo "Downloading ${2} v${1}..."
curl -LO --progress-bar https://dl.k8s.io/v${1}/bin/linux/amd64/${2}
check ${1} ${2}
mkdir -p "v${1}"
mv ${2} "v${1}/"
}
@naingyeminn
naingyeminn / create-k8s-user.sh
Created January 21, 2023 19:51
Generate kubeconfig with user-based client certificate and assign role.
#!/bin/bash
if [ -z "${1}" ]; then
echo "Please provide a username and the namespace or the username only for the cluster role..."
echo "Usage: ${0} USERNAME [NAMESPACE] [ROLE]"
echo "Example: ${0} auditor default view"
exit
fi
USERNAME=${1}
#!/bin/bash
# usage: kubeadd new_kubeconfig_file
cp ~/.kube/config ~/.kube/config.$(date +%F)
KUBECONFIG=~/.kube/config:$1 kubectl config view --flatten > /tmp/config
mv /tmp/config ~/.kube/config
chmod 600 ~/.kube/config
@naingyeminn
naingyeminn / setkube
Created June 11, 2022 17:13
Manage and maintain multiple kubectl versions
#!/bin/bash
BIN_PATH="$HOME/.local/bin"
help_msg () {
echo "Usage: setkube -v [kubectl_version_number | stable]"
echo " setkube -d [kubectl_version_number]"
echo ""
echo " kubectl_version_number = 1.23.5, 1.22.2, etc."
@naingyeminn
naingyeminn / kubeswitch
Last active August 2, 2022 02:46
Switch K8S cluster context easily
#!/bin/bash
# run `kubeswitch` to list the contexts from .kube/config and set current context
# run `source <(kubeswitch)` to use the selected context in active shell environment only
# or add `alias kswitch='source <(kubeswitch)'` in ~/.bashrc
unset KUBECONFIG
select context in $(kubectl config get-contexts -o name); do
kubectl config use-context $context &> /dev/null
kubectl config view --minify --context $context --flatten > ${HOME}/.kube/$context.conf
chmod 600 ${HOME}/.kube/$context.conf
@naingyeminn
naingyeminn / mm-kb-install.sh
Last active March 9, 2020 16:18
MM-KB Quick Install
#!/bin/bash
FONTCFG=~/.config/fontconfig/
mm_kb=https://github.com/naingyeminn/mm-kb/archive/master.zip
wget -N $mm_kb 2> /dev/null || curl -OL $mm_kb
unzip -o master.zip
cd mm-kb-master
sudo apt install make ibus-table -y
sudo make install
ibus-daemon -rdx
@naingyeminn
naingyeminn / ntfsmount
Last active October 6, 2022 16:02
NTFS-3G Mount Script for MacOS
#!/bin/bash
#---- ---- ---- ----
# Copyright (C) Naing Ye Minn <naingyeminn@gmail.com>
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#---- ---- ---- ----
# Install osxfuse and ntfs-3g via brew
# $ brew cask install osxfuse
# $ brew install ntfs-3g
[tower-cli]
baseurl = https://releases.ansible.com/ansible-tower-cli/rpm/epel-7-x86_64/
sslverify = 0
name = Ansible Tower-cli
enabled = 1
gpgcheck = 0
@naingyeminn
naingyeminn / con_check.yml
Last active March 31, 2021 13:15
Ansible - Listen module
---
- hosts: servera.example.com
tasks:
- name: serverB listen on port 8888
listen:
port: "8888"
async: 5
poll: 0
delegate_to: serverb.example.com
@naingyeminn
naingyeminn / suid_test.c
Created December 25, 2018 11:28
some codes
#include <stdio.h>
#include <stdlib.h>
int main()
{
char sometext[256];
FILE *fptr;
fptr = fopen("/tmp/suid_test.txt","w");
if(fptr == NULL)
{