Mastering Three Core Methods to Manage Kubernetes Resources
This tutorial walks through the three fundamental approaches—imperative CLI commands, declarative manifest files, and GUI tools—for managing Kubernetes core resources such as namespaces, deployments, pods, and services, providing practical examples, code snippets, and best‑practice recommendations.
1. Three Basic Methods to Manage Kubernetes Core Resources
Imperative (CLI) management
Declarative (manifest) management
GUI (Web) management
2. Imperative Resource Management
Using kubectl commands to create, view, and delete namespaces, deployments, pods, and services.
2.1 Namespace Management
kubectl get namespaces
kubectl get ns
kubectl get all -n default
kubectl create namespace app
kubectl delete namespace app2.2 Deployment Management
# Create deployment
kubectl create deployment nginx-dp --image=harbor.od.com/public/nginx:v1.7.9 -n kube-public
# View deployment
kubectl get deployment -n kube-public
kubectl describe deployment nginx-dp -n kube-public
# Scale deployment
kubectl scale deployment nginx-dp --replicas=2 -n kube-public
# Delete deployment
kubectl delete deployment nginx-dp -n kube-public2.3 Service Management
# Expose deployment as a Service
kubectl expose deployment nginx-dp --port=80 -n kube-public
# View Service details
kubectl describe svc nginx-dp -n kube-public
kubectl get svc -n kube-public3. Declarative Resource Management
Resources are defined in YAML/JSON manifests and applied with kubectl.
3.1 View Manifest
kubectl get pod nginx-dp-xxxxx -o yaml -n kube-public
kubectl get svc nginx-dp -o yaml -n kube-public3.2 Create Manifest
apiVersion: v1
kind: Service
metadata:
name: nginx-ds
labels:
app: nginx-ds
spec:
type: ClusterIP
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx-ds3.3 Apply Manifest
kubectl apply -f nginx-ds-svc.yaml
# Force apply if needed
kubectl apply -f nginx-ds-svc.yaml --force3.4 Edit Manifest Online
kubectl edit svc nginx-ds
# Change port, save and exit3.5 Delete Manifest
# Imperative delete
kubectl delete svc nginx-ds
# Declarative delete
kubectl delete -f nginx-ds-svc.yaml4. Summary
kubectl is the primary CLI for interacting with the Kubernetes API server.
Imperative commands are quick for ad‑hoc tasks but become verbose for complex operations.
Declarative manifests provide version‑controlled, repeatable configurations.
GUI tools offer visual management but still rely on the same API calls.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
