Operations 17 min read

Mastering Kubernetes Core Resource Management: 3 Declarative Methods Explained

This guide walks through three fundamental ways to manage Kubernetes core resources—imperative CLI commands, declarative manifest files, and GUI tools—covering namespaces, deployments, services, scaling, and cleanup with practical kubectl examples.

Raymond Ops
Raymond Ops
Raymond Ops
Mastering Kubernetes Core Resource Management: 3 Declarative Methods Explained

1. Three basic methods to manage Kubernetes core resources

Imperative (CLI) method: use kubectl commands

Declarative method: use manifest files

GUI method: use web UI

2. Imperative resource management

The imperative approach performs create, read, update, and delete (CRUD) operations directly via kubectl.

2.1 Manage Namespace resources

2.1.1 View namespaces kubectl get namespaces 2.1.2 View resources in a namespace kubectl get all -n default 2.1.3 Create a namespace kubectl create namespace app 2.1.4 Delete a namespace

kubectl delete ns app

2.2 Manage Deployment resources

2.2.1 Create a deployment

kubectl create deployment nginx-dp --image=harbor.od.com/public/nginx:v1.7.9 -n kube-public

2.2.2 View the deployment kubectl get deployment -n kube-public 2.2.3 View pods created by the deployment kubectl get pod -n kube-public -o wide 2.2.4 Exec into a pod

kubectl exec -it nginx-dp-<span>pod-id</span> -n kube-public -- bash

2.2.5 Delete a pod (forces restart)

kubectl delete pod nginx-dp-<span>pod-id</span> -n kube-public

2.2.6 Delete the deployment

kubectl delete deployment nginx-dp -n kube-public

2.3 Manage Service resources

2.3.1 Create a service by exposing the deployment

kubectl expose deployment nginx-dp --port=80 -n kube-public

2.3.2 View the service details kubectl describe svc nginx-dp -n kube-public 2.3.3 View IPVS proxy table and scale the deployment

ipvsadm -Ln
kubectl scale deployment nginx-dp --replicas=2 -n kube-public

2.4 Summary of the imperative method

Kubernetes clusters are managed through API‑server calls.

kubectl is the official CLI tool for communicating with the API server.

The imperative method satisfies most CRUD needs but commands can be verbose and harder to remember.

3. Declarative resource management

The declarative approach relies on YAML or JSON manifests that describe the desired state of resources.

3.1 View resource manifests

kubectl get pod nginx-dp-... -o yaml -n kube-public

3.2 Explain manifest fields

kubectl explain service.metadata

3.3 Create resources from a manifest

kubectl create -f nginx-ds-svc.yaml

3.4 Apply changes to a manifest

Offline edit the YAML file then apply: kubectl apply -f nginx-ds-svc.yaml Online edit with kubectl edit:

kubectl edit svc nginx-ds

3.5 Delete resources

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

3.6 Summary of the declarative method

Manifests define resources and are applied with kubectl.

Changes are version‑controlled, reproducible, and easier to audit.

Typical workflow uses create/apply/delete with -f files.

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.

CLIKubernetesYAML
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

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.