You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将已创建的Pod部署为Service时遭遇deployments.apps "wordpress" NotFound错误求助

Troubleshooting "Error from server (NotFound): deployments.apps 'wordpress' not found" When Creating a Service

Let's break down why you're hitting this error and how to fix it step by step:

First, the error is telling you that Kubernetes can't find a Deployment named wordpress in your cluster. This almost always happens because either:

  • You're trying to expose a Deployment that no longer exists (even if its old Pods are still running), or
  • You accidentally used a command that targets a Deployment instead of your existing standalone Pod.

Step 1: Verify Your Cluster Resources

First, let's confirm what's actually running in your cluster:

  1. Check for existing Deployments:
    kubectl get deployments
    
    If wordpress doesn't show up here, that's the root cause—your command is looking for a Deployment that's gone.
  2. Check your existing WordPress Pod(s) and their labels:
    kubectl get pods -o wide
    
    Look at the LABELS column for your WordPress Pod—this will tell you what tags we can use to link a Service to it.

Step 2: Fix the Issue Based on Your Setup

Scenario 1: You don't need a Deployment (just want to expose your existing Pod)

If your WordPress Pod was created directly (not via a Deployment), you need to expose the Pod itself instead of a Deployment.

Option 1: Use the expose command directly on the Pod:

# Replace <your-pod-name> with the actual name of your WordPress Pod from the previous step
kubectl expose pod <your-pod-name> --port=80 --type=ClusterIP

Option 2: Create a Service YAML file (more flexible):
Create a file named wordpress-service.yaml with this content, making sure the selector matches the labels from your Pod:

apiVersion: v1
kind: Service
metadata:
  name: wordpress-service
spec:
  selector:
    # Replace this with your Pod's actual label (e.g., app=wordpress)
    app: wordpress
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: ClusterIP

Then apply it with:

kubectl apply -f wordpress-service.yaml

Scenario 2: You want to use a Deployment (recommended for reliability)

Deployments are better for managing Pods—they handle self-healing, scaling, and updates. If your original Deployment was deleted, recreate it first:

  1. Use your original Deployment YAML file (if you have it):
    kubectl apply -f your-wordpress-deployment.yaml
    
  2. Wait for the Deployment to spin up new Pods (check with kubectl get pods until they show Running).
  3. Now you can expose the Deployment safely:
    kubectl expose deployment wordpress --port=80 --type=ClusterIP
    

Scenario 3: You made a typo

Double-check the name of your Deployment—Kubernetes resource names are case-sensitive. If your Deployment was named WordPress (with a capital W) instead of wordpress, fix the command to match the correct name.


内容的提问来源于stack exchange,提问作者Dev Rao

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 17:22:46