Cloud Native 17 min read

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.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Mastering Three Core Methods to Manage Kubernetes Resources

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 app

2.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-public

2.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-public

3. 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-public

3.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-ds

3.3 Apply Manifest

kubectl apply -f nginx-ds-svc.yaml
# Force apply if needed
kubectl apply -f nginx-ds-svc.yaml --force

3.4 Edit Manifest Online

kubectl edit svc nginx-ds
# Change port, save and exit

3.5 Delete Manifest

# Imperative delete
kubectl delete svc nginx-ds

# Declarative delete
kubectl delete -f nginx-ds-svc.yaml

4. 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.

Kubernetes management diagram
Kubernetes management diagram
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

KubernetesResource ManagementYAMLDeclarativekubectlImperative
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.