diff --git a/README.md b/README.md index ba31157..18fedbb 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Kubernetes is an open‑source platform that automates the deployment, scaling, - [k3s](#k3s) - [Install / Setup](#install--setup) +- [Kubernetes DNS](#kubernetes-dns) + - [Services DNS Name](#services-dns-name) - [kubectl](#kubectl) - [Pod delete](#pod-delete) - [OOMKilled](#oomkilled) @@ -32,10 +34,28 @@ K3s is a lightweight, certified Kubernetes distribution designed to run in resou curl -sfL https://get.k3s.io | sh - ``` +## Kubernetes DNS + +**Automatic DNS Records:** Kubernetes automatically creates DNS entries for Services and Pods. This allows workloads to connect using predictable names instead of IPs, which may change. + +### Services DNS Name + +```text +..svc. +``` + +*Example: [test-services.services.svc.cluster.local](test-services.services.svc.cluster.local).* + ## 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. +**Create namespace:** + +``` bash + kubectl create namespace tests +``` + ### Pod delete **Restart local Path Provizionizer:** @@ -79,17 +99,48 @@ kubectl get crds | grep traefik #### network testing ``` bash - kubectl run -i --tty dns-test --image=busybox --restart=Never -- -# Inside the pod: -nslookup google.com +kubectl run -i --tty dns-test --namespace tests --image=busybox --restart=Never -- +kubectl delete pod dns-test --namespace tests || 0 ``` -**from inside the pod:** +**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 +``` + ### Set Replicas **Set deployment replicas to 0:**