update kuber to working

This commit is contained in:
2025-06-24 20:47:06 +03:30
parent a028612669
commit b0cf699d74
10 changed files with 265 additions and 172 deletions

View File

@@ -0,0 +1,72 @@
# Kubernetes Namespaces Guide
Kubernetes **namespaces** allow you to organize and isolate resources within your cluster.
---
## 🧾 Listing Namespaces
To list all namespaces:
```bash
kubectl get namespaces
```
or the shorthand:
```bash
kubectl get ns
```
---
## 🛠️ Creating a Namespace
Create a new namespace:
```bash
kubectl create namespace <namespace-name>
```
or:
```bash
kubectl create ns <namespace-name>
```
---
## 🗑️ Deleting a Namespace
Delete a namespace:
```bash
kubectl delete ns <namespace-name>
```
---
## ⚠️ Best Practices & Notes
* **Namespaces are isolated**, but they **can still communicate** with each other by default.
* It is **not recommended to create namespaces that start with `kube-`**, as those are typically reserved for system components.
---
## 📄 Creating a Namespace with a Manifest
You can define a namespace using a YAML manifest:
```yaml
apiVersion: v1
kind: Namespace
metadata:
name: namespace-test
```
Apply it using:
```bash
kubectl apply -f namespace.yaml
```

View File

@@ -0,0 +1,95 @@
## Pod Management
### Listing Pods
- **List Pods in the Default Namespace**
```bash
kubectl get pods
```
- **List Pods with Detailed Information (Wide Output)**
```bash
kubectl get pods -o wide
```
- **List Pods in a Specific Namespace**
```bash
kubectl get pods -o wide -n <namespace-name>
```
### Running a Pod
> **Note:** The `kubectl run` command is best suited for running single pods. For more complex deployments, consider using YAML manifests.
```bash
kubectl run <pod-name> --image=<image-name>
```
```bash
kubectl run <pod-name> --image=<image-name> -n <namespace>
```
```bash
kubectl delete pod <pod-name> -n <namespace-name>
```
```bash
kubectl delete pod <pod-name> -n <namespace-name> --force
```
```bash
kubectl delete pod <pod-name> -n <namespace-name> --force --grace-period 0
```
```bash
kubectl edit pod -n <namepsace> <podname>
```
Pod Can not been edit (not editable)
```bash
kubectl exec -it -n <namespace> <podname> -- <command or shell>
```
```yaml
apiVersion: v1
kind: Pod
metadata:
namespace: dev
name: pod-1
labels:
label1: test
label2: test2
app.kubernetes.io/label3: test3
app.kubernetes.io/label4: test4
spec:
containers:
- name: nginx-server
image: nginx
- name: nginx-exporter
image: nginx-exporter
- name: ubuntu-c0
image: ubuntu
command: ["/bin/bash","-c","while true; do echo hello-world; sleep 5; done"]
resources:
limits:
memory: "256Mi"
cpu: "250m"
requests:
memory: "128Mi"
cpu: "125m"
nodeSelector:
hostname: k3s
app.kubernetes.io/disk: ssd
```