diff --git a/README.md b/README.md index 42ab31c..84518c4 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ Kubernetes is an open‑source platform that automates the deployment, scaling, and management of containerized applications. It acts as an orchestrator, ensuring your containers run reliably across clusters of machines, handling networking, storage, and updates without downtime. - [kubernetes](#kubernetes) + - [kubectl](#kubectl) + - [Env variables](#env-variables) + - [Resources](#resources) - [Namespaces](#namespaces) - [Create namespace](#create-namespace) - [namespace stuck on delete](#namespace-stuck-on-delete) @@ -13,6 +16,7 @@ Kubernetes is an open‑source platform that automates the deployment, scaling, - [Failed pods](#failed-pods) - [delete all pods with prefix](#delete-all-pods-with-prefix) - [OOMKilled](#oomkilled) + - [network testing](#network-testing) - [Attach to an pod](#attach-to-an-pod) - [Run command on pod](#run-command-on-pod) - [Keep pod Alive](#keep-pod-alive) @@ -24,10 +28,6 @@ Kubernetes is an open‑source platform that automates the deployment, scaling, - [check orphans](#check-orphans) - [persistent volume claims](#persistent-volume-claims) - [Create an pod with PVC](#create-an-pod-with-pvc) - - [kubectl](#kubectl) - - [Helper pods](#helper-pods) - - [network testing](#network-testing) - - [Resources](#resources) - [Services Accounts](#services-accounts) - [configMap](#configmap) - [Secrets](#secrets) @@ -81,6 +81,24 @@ Kubernetes is an open‑source platform that automates the deployment, scaling, - [hosting](#hosting) - [misc](#misc) +## kubectl + +kubectl is the command‑line tool used to interact with Kubernetes clusters. Think of it as the “remote control” for Kubernetes: it lets you deploy applications, inspect resources, and manage cluster operations directly from your terminal. + +### Env variables + +``` bash +export KUBECONFIG=/path/to/kubeconfig +``` + +### Resources + +**List all resources:** + +```bash +kubectl get all -n kube-system | grep traefik +``` + ## Namespaces ### Create namespace @@ -222,6 +240,24 @@ spec: type: DirectoryOrCreate ``` +**Example using yaml and hostNetwork:** + +```yaml +apiVersion: v1 +kind: Pod +metadata: + name: dns-test + namespace: tests +spec: + hostNetwork: true + containers: + - name: dns-test + image: busybox + command: ["sh"] + stdin: true + tty: true +``` + ### Get Pod **Get pod name by label ap:** @@ -257,7 +293,6 @@ kubectl delete pod -n appNamespace -l app=myAppName ### Failed pods - List all. ``` bash @@ -316,6 +351,19 @@ sudo journalctl -k --since "1 hour ago" | grep -Ei "oom|kill" sudo journalctl -k -o short-iso | grep -Ei "oom|kill" ``` +### network testing + +``` bash +kubectl run -i --tty dns-test --namespace tests --image=busybox --restart=Never -- +kubectl delete pod dns-test --namespace tests || 0 +``` + +- Execute command inside pod. + +``` bash +nslookup google.com +``` + ### Attach to an pod Attach connects your terminal to the main process of the container (PID 1), or another running process if specified. @@ -503,73 +551,6 @@ spec: claimName: data-pvc ``` -## kubectl - -kubectl is the command‑line tool used to interact with Kubernetes clusters. Think of it as the “remote control” for Kubernetes: it lets you deploy applications, inspect resources, and manage cluster operations directly from your terminal. - -### Helper pods - -#### network testing - -``` bash -kubectl run -i --tty dns-test --namespace tests --image=busybox --restart=Never -- -kubectl delete pod dns-test --namespace tests || 0 -``` - -**Example using yaml and hostNetwork:** - -- Create Pod - -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: dns-test - namespace: tests -spec: - hostNetwork: true - containers: - - name: dns-test - image: busybox - command: ["sh"] - stdin: true - tty: true -``` - -- Attach to Pod - -```bash -kubectl attach -it dns-test -n tests -``` - -- Execute command inside pod. - -``` bash -nslookup google.com -``` - -- Delete pod - -```bash -kubectl delete pod dns-test --namespace tests -``` - -### Resources - -**List all resources:** - -```bash -kubectl get all -n kube-system | grep traefik -``` - -**List service accounts:** - -```bash -kubectl get serviceAccount --all-namespaces -``` - - - ### Services Accounts **List all:**