Cloud Native 5 min read

Kubernetes Pod Usage, Creation, Management, and Harbor Image Pull Secret

This guide explains Kubernetes Pod concepts, how to create and manage Pods using YAML and kubectl commands, outlines basic Pod management operations, describes image pull policies, and shows how to configure a Harbor private registry secret for Pods.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Kubernetes Pod Usage, Creation, Management, and Harbor Image Pull Secret

1. Pod Usage

A Pod should consist of at least two containers: a base container and a business container (maximum 1+4). The core principle is to distribute multiple applications across multiple Pods, allowing independent scaling and resource allocation. If containers do not need to run together, they should be placed in separate Pods.

2. Creating Pod Resources

Pods can be created via command‑line arguments or, preferably, through a YAML manifest. The creation flow is:

1) kubectl sends a REST request to the Kubernetes API. 2) The scheduler assigns the Pod to a worker node. 3) The node’s kubelet pulls the image and starts the container.

2.1 Main Components of a Kubernetes YAML

apiVersion

: API version kind: Resource type (e.g., Pod) metadata: Name, namespace, labels, etc. spec: Detailed specification of containers, volumes, and other settings.

2.2 Creating a Pod with a YAML File

Command: kubectl create -f k8s_pod.yml Example k8s_pod.yml:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    app: web
spec:
  containers:
    - name: nginx
      image: 10.0.0.107/linux/nginx:v1.18.1
      ports:
        - containerPort: 80
  imagePullSecrets:
    - name: secret-name

2.3 Basic Pod Management

1) List Pods (add -o wide for details): kubectl get pod -o wide 2) Describe a Pod to troubleshoot creation issues: kubectl describe pod [PodName] 3) View Pod logs (use -c to specify a container when multiple exist):

kubectl logs nginx

3. Image Pull Policies

Kubernetes supports three pull policies:

Always : Always pull the image from the registry.

Never : Never pull; use only local images.

IfNotPresent : Pull only if the image is not present locally (default).

4. Adding a Harbor Private Registry Secret to a Pod

1) Create a Docker registry secret:

kubectl create secret docker-registry harbor-auth \
  --namespace=wordpress \
  --docker-server=http://10.0.0.107 \
  --docker-username=admin \
  --docker-password=mzl123 \
  [email protected]

2) Reference the secret in the Pod spec (the secret and Pod must be in the same namespace):

imagePullSecrets:
  - name: <secret-name>

Example Pod manifest with the secret attached:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    app: web
spec:
  containers:
    - name: nginx
      image: 10.0.0.107/linux/nginx:v1.18.1
      ports:
        - containerPort: 80
  imagePullSecrets:
    - name: harbor-auth
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.

Cloud NativeKubernetesYAMLPodkubectlImagePullSecrets
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

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.