added some file and updated
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
Below is an improved version of your Kubernetes Command Reference. This revision enhances clarity, fixes typos, organizes related commands into logical sections, and standardizes formatting for readability.
|
Below is an enhanced version of your Kubernetes Command Reference. This revision further refines the structure, improves consistency, and adds a few extra sections for clarity and ease of use.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Kubernetes Command Reference
|
# Kubernetes Command Reference
|
||||||
|
|
||||||
This document provides a concise reference for common `kubectl` commands used to manage Kubernetes clusters. Whether you’re managing nodes, namespaces, pods, deployments, or autoscaling, the examples below will help you perform everyday tasks with ease.
|
This guide provides a concise reference for common `kubectl` commands used to manage Kubernetes clusters. Whether you’re managing nodes, namespaces, pods, deployments, or autoscaling, the examples below will help you perform everyday tasks with confidence.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -22,13 +22,14 @@ This document provides a concise reference for common `kubectl` commands used to
|
|||||||
- [Listing Pods](#listing-pods)
|
- [Listing Pods](#listing-pods)
|
||||||
- [Running a Pod](#running-a-pod)
|
- [Running a Pod](#running-a-pod)
|
||||||
- [Deleting a Pod](#deleting-a-pod)
|
- [Deleting a Pod](#deleting-a-pod)
|
||||||
- [API Resources and Documentation](#api-resources-and-documentation)
|
- [API Resources \& Documentation](#api-resources--documentation)
|
||||||
- [Logs and Pod Information](#logs-and-pod-information)
|
- [Logs \& Pod Information](#logs--pod-information)
|
||||||
- [Applying YAML Files](#applying-yaml-files)
|
- [Applying YAML Files](#applying-yaml-files)
|
||||||
- [Viewing Cluster Resources](#viewing-cluster-resources)
|
- [Viewing Cluster Resources](#viewing-cluster-resources)
|
||||||
- [ReplicaSet and Deployment Management](#replicaset-and-deployment-management)
|
- [ReplicaSet \& Deployment Management](#replicaset--deployment-management)
|
||||||
- [Scaling and Rollouts](#scaling-and-rollouts)
|
- [Scaling and Rollouts](#scaling-and-rollouts)
|
||||||
- [Autoscaling](#autoscaling)
|
- [Autoscaling](#autoscaling)
|
||||||
|
- [Port Forwarding](#port-forwarding)
|
||||||
- [Additional Information](#additional-information)
|
- [Additional Information](#additional-information)
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -36,7 +37,6 @@ This document provides a concise reference for common `kubectl` commands used to
|
|||||||
## General Commands
|
## General Commands
|
||||||
|
|
||||||
- **List API Resources**
|
- **List API Resources**
|
||||||
|
|
||||||
Display all available API resources along with their short names:
|
Display all available API resources along with their short names:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -88,7 +88,7 @@ This document provides a concise reference for common `kubectl` commands used to
|
|||||||
kubectl drain <node-name> --ignore-daemonsets --delete-local-data
|
kubectl drain <node-name> --ignore-daemonsets --delete-local-data
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Warning:** Draining a node will evict running pods. Ensure this action is planned to avoid service disruption.
|
> **Warning:** Draining a node will evict running pods. Ensure that you plan this action to avoid service disruption.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ This document provides a concise reference for common `kubectl` commands used to
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl get namespaces
|
kubectl get namespaces
|
||||||
# Or use the shorthand:
|
# Or the shorthand:
|
||||||
kubectl get ns
|
kubectl get ns
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ This document provides a concise reference for common `kubectl` commands used to
|
|||||||
|
|
||||||
### Running a Pod
|
### Running a Pod
|
||||||
|
|
||||||
> **Note:** While `kubectl run` is a versatile command, note that in recent Kubernetes versions it is primarily used for running single pods (not deployments). For more complex configurations, consider using YAML manifests.
|
> **Note:** The `kubectl run` command is best suited for running single pods. For more complex deployments, consider using YAML manifests.
|
||||||
|
|
||||||
- **Basic Example:**
|
- **Basic Example:**
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ This document provides a concise reference for common `kubectl` commands used to
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## API Resources and Documentation
|
## API Resources & Documentation
|
||||||
|
|
||||||
- **Get Detailed Documentation for an API Resource**
|
- **Get Detailed Documentation for an API Resource**
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ This document provides a concise reference for common `kubectl` commands used to
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Logs and Pod Information
|
## Logs & Pod Information
|
||||||
|
|
||||||
- **Stream Logs for a Running Pod**
|
- **Stream Logs for a Running Pod**
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ This document provides a concise reference for common `kubectl` commands used to
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## ReplicaSet and Deployment Management
|
## ReplicaSet & Deployment Management
|
||||||
|
|
||||||
### Scaling and Rollouts
|
### Scaling and Rollouts
|
||||||
|
|
||||||
@@ -265,7 +265,6 @@ This document provides a concise reference for common `kubectl` commands used to
|
|||||||
### Autoscaling
|
### Autoscaling
|
||||||
|
|
||||||
- **Autoscale a Deployment**
|
- **Autoscale a Deployment**
|
||||||
|
|
||||||
Automatically scale a deployment based on CPU utilization:
|
Automatically scale a deployment based on CPU utilization:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -280,8 +279,24 @@ This document provides a concise reference for common `kubectl` commands used to
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Port Forwarding
|
||||||
|
|
||||||
|
Sometimes you need to access a service or pod directly from your local machine. Use the following command to forward a port:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl port-forward -n <namespace-name> svc/<service-name> <local-port>:<target-port>
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Example:** Forward local port 8080 to port 80 of the service named `my-service` in the `mynamespace` namespace:
|
||||||
|
>
|
||||||
|
> ```bash
|
||||||
|
> kubectl port-forward -n mynamespace svc/my-service 8080:80
|
||||||
|
> ```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Additional Information
|
## Additional Information
|
||||||
|
|
||||||
- **Static Manifest Files**
|
- **Static Manifest Files**
|
||||||
|
|
||||||
Any YAML files placed in `/etc/kubernetes/manifests/` are automatically loaded when the kubelet starts (for example, after a server reboot).
|
Any YAML files placed in `/etc/kubernetes/manifests/` are automatically loaded when the kubelet starts (for example, after a server reboot).
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: app-deployment
|
||||||
|
namespace: ns-test
|
||||||
|
labels:
|
||||||
|
name: deployment-test
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
replicas: 2
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
name: app1
|
||||||
|
app: nginx
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
name: app1
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: nginx-deployment
|
||||||
|
image: nginx:1.26
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: nginx
|
||||||
|
namespace: ns-test
|
||||||
|
labels:
|
||||||
|
app: nginx
|
||||||
|
spec:
|
||||||
|
type: NodePort # ClusterIP Or LoadBalancer
|
||||||
|
selector:
|
||||||
|
app: nginx
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 80
|
||||||
|
targetPort: 80
|
||||||
Reference in New Issue
Block a user