k8s tips and tricks

Kubernetes tips & tricks, how to change namespace for a cluster

Sam
Introduction In this article, we will explore various tips and tricks for managing Kubernetes (k8s) clusters using kubectl. These commands will help you efficiently handle namespaces, pods, deployments, and custom resource definitions (CRDs). Change the kubectl namespace while keeping the current context intact # change namespace of kubectl while keeping current context kubectl config set-context --current --namespace=default List pods from default namespace kubectl get pods List pods from all namespaces kubectl get pods -A # list pods from all namespaces List pods from a particular namespace kubectl get pods -n mynamespace How to check logs of a pod kubectl logs nginx-pod -n nginix-ns How to check logs of a pod as it gets generated or watch k8s pod logs ## use -f to follow the log as it generated kubectl logs <pod_name> -n <namespace> -f Deleting a Kubernetes deployment using kubectl If you don’t have proper permissions on the cluster, you will encounter an error like this.

AWS Basics

AWS Basics - How to install aws cli on your macOS

Sam
AWS EC2 Install aws cli via brew brew install awscli Install using package cat << EOF >> choices.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>choiceAttribute</key> <string>customLocation</string> <key>attributeSetting</key> <string>/Users/yourusername</string> <key>choiceIdentifier</key> <string>default</string> </dict> </array> </plist> EOF Download the package curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" Install the package using standard installer installer -pkg AWSCLIV2.pkg \ -target CurrentUserHomeDirectory \ -applyChoiceChangesXML choices.xml

Google Cloud Platform - App Engine Basics

Google Cloud Platform - App Engine Basics

Sam
Google Cloud App Engine Name Value Account Used am..info@gmail.com Date 1 June 2024 Samples URL https://github.com/GoogleCloudPlatform/golang-samples/tree/main/appengine/go11x Local clone dir workspace/p_github/GCP/golang-samples Samples Dir GCP/golang-samples/appengine/helloworld Install Google Cloud SDK on macOS using homebrew brew install --cask google-cloud-sdk ==> Caveats To add gcloud components to your PATH, add this to your profile: for bash users source "$(brew --prefix)/share/google-cloud-sdk/path.

German B1.1

Sam
B1.1 - Schritte Plus DE EN Weßling - Eine Geburtstagsparty sorgte für großen Ärger: Über 500 Gäste folgten der Einladung über ein soziales Netzwerk. Weßling - A birthday party caused a lot of trouble: over 500 guests followed the invitation via a social network. A3 Lesen Sie die Kurzmeldung und ordnen Sie zu. lud …ein störte riefen sollte -sorgte- bemerkte standen feierten sperrte…ab kam schickte gingen dachte

VS Code Tricks

my ssh journey

Sam
How to manually restart an extension in VSCode? I was using Prettier Extension to format my document and I changed my .prettierrc file to singleQuote from true to false. It was still replacing my doubleQuotes to SingleQuotes. It was pretty annoying. Solution: Press Cmd + Shift + P to open Command Palette. Then Type Restart Extension Host. It should reload the extensions installed and enabled. How do I get Intellisense to show my user snippets available ?

Ways to implement CSS in React

Let us look at the ways to implement CSS Modules in React and Next.js

Sam
Define your CSS classes in a file like this: /* styles.module.css */ .container { font-size: 20px; border: 1px solid #000; border-radius: 5px; } .title { color: red; } And then import it in your component like this: // app/page.js import styles from './styles.module.css' export default function Page() { return ( <div className={styles.container}> <h1 className={styles.title}>Hello, World!</h1> </div> ) } How to combine two css classes from your CSS module?

Hyedration issues with Next.js

Uncaught Error: Hydration failed because the initial UI does not match what was rendered on the server

Sam
Uncaught Error: Hydration failed because the initial UI does not match what was rendered on the server Solution From Next.js 13, return jsx once the component is mounted function Component() { const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); if (!mounted) return <></>; // write rest of your code } Error: ```bash Unhandled Runtime Error Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

pnpm tricks

pnpm tips and tricks

Sam
pnpm is a package manager for Node.js. It saves and caches the dependencies of your project. It does not install packages, if they are already installed by another project rather re-use the same packages thus saves lot of space on your disk. $ pnpm install react-router --save ERR_PNPM_UNEXPECTED_STORE Unexpected store location The dependencies at "/Users/sam/Dev/react-all-in-one/node_modules" are currently linked from the store at "/Users/XXXXX/Library/pnpm/store/v3". pnpm now wants to use the store at "/Users/sam/Library/pnpm/store/v3" to link dependencies.

Exclude node modules in tree output

List of latest tools available in the market

Sam
Do you wish to display only the folders excluding the node_modules or bower_components folder ? tree -I "node_modules|bower_components" Now the output should look clean excluding the node_modules or bower_components folder. sam@SamsMacBookPro ~/w/t/t/blog-app (main)> tree -I "node_modules|bower_components" . ├── README.md ├── app │ ├── favicon.ico │ ├── globals.css │ ├── layout.js │ └── page.js ├── jsconfig.json ├── lib │ └── db.js ├── next.config.js ├── package-lock.json ├── package.json ├── pages │ ├── api │ │ └── posts.

Git - Use like a pro

Git - Use like a pro

Sam
git log git log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%an%C(reset)%C(bold yellow)%d%C(reset) %C(dim white)- %s%C(reset)' --all git unwatch all from an organisation Navigate to https://github.com/watching . You have an option to watch and unwatch all or selectively. git log git log --graph --decorate --oneline # git log with patch output git log --patch -2 # -2 represents number of log entries git log -p -2 # git log with stat git log with --stat git log --pretty=format:"%h - %an, %ar : %s" git log --pretty=format:"%h %s" --graph git log --since=4.