diff --git a/README.md b/README.md index a9d8df2..b9e4707 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Kubernetes is an open‑source platform that automates the deployment, scaling, - [Patch pv - change to retain policy](#patch-pv---change-to-retain-policy) - [Patch pv - remove finalizers](#patch-pv---remove-finalizers) - [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) @@ -113,8 +114,6 @@ metadata: name: ubuntu-test namespace: tests spec: - #### deploy to an specific node - nodeName: chimera-gluten containers: - name: ubuntu-test image: ubuntu @@ -126,15 +125,34 @@ spec: command: ["sh"] # PID 1 = interactive shell stdin: true # keep STDIN open tty: true # allocate a terminal +``` - volumeMounts: - - name: data - mountPath: /data +or using only CLI (auto removes on exiting). - volumes: - - name: data - persistentVolumeClaim: - claimName: data-pvc +``` bash +kubectl run ubuntu-test \ + --image=ubuntu \ + --restart=Never \ + --rm \ + -it -- bash +``` + +*Example with busybox, good for network testing.* + +``` bash +kubectl run net-test \ + --image=busybox \ + --restart=Never \ + --rm -it -- sh +``` + +*Example with curl, good for network testing.* + +``` bash +kubectl run curl-test \ + --image=curlimages/curl \ + --restart=Never \ + --rm -it -- sh ``` **Create an ubuntu pod with and execute command:** @@ -316,6 +334,41 @@ spec: storage: 1Gi ``` +### Create an pod with PVC + +**Create an ubuntu pod for tty access example:** + +``` bash +apiVersion: v1 +kind: Pod +metadata: + name: ubuntu-test + namespace: tests +spec: + #### deploy to an specific node + nodeName: chimera-gluten + containers: + - name: ubuntu-test + image: ubuntu + # In Kubernetes, the pod stays alive as long as PID 1 is running. + # so with this options: + # - It does not exit automatically. + # - It waits for user input forever. + # - It behaves like an interactive shell session. + command: ["sh"] # PID 1 = interactive shell + stdin: true # keep STDIN open + tty: true # allocate a terminal + + volumeMounts: + - name: data + mountPath: /data + + volumes: + - name: data + persistentVolumeClaim: + 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.