Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 不能将服务作为“应用”;类型:ClusterIP“;在我的GKE集群中_Kubernetes_Google Kubernetes Engine_Kubernetes Ingress_Kubernetes Service - Fatal编程技术网

Kubernetes 不能将服务作为“应用”;类型:ClusterIP“;在我的GKE集群中

Kubernetes 不能将服务作为“应用”;类型:ClusterIP“;在我的GKE集群中,kubernetes,google-kubernetes-engine,kubernetes-ingress,kubernetes-service,Kubernetes,Google Kubernetes Engine,Kubernetes Ingress,Kubernetes Service,我想将服务部署为ClusterIP,但无法将其应用于给定的错误消息: [xetra11@x11-work coopr-infrastructure]$ kubectl apply -f teamcity-deployment.yaml deployment.apps/teamcity unchanged ingress.extensions/teamcity unchanged The Service "teamcity" is invalid: spec.ports[0].nodePort:

我想将服务部署为ClusterIP,但无法将其应用于给定的错误消息:

[xetra11@x11-work coopr-infrastructure]$ kubectl apply -f teamcity-deployment.yaml 
deployment.apps/teamcity unchanged
ingress.extensions/teamcity unchanged
The Service "teamcity" is invalid: spec.ports[0].nodePort: Forbidden: may not be used when `type` is 'ClusterIP'
这是我的.yaml文件:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: teamcity
  labels:
    app: teamcity
spec:
  replicas: 1
  selector:
    matchLabels:
      app: teamcity
  template:
    metadata:
      labels:
        app: teamcity
    spec:
      containers:
      - name: teamcity-server
        image: jetbrains/teamcity-server:latest
        ports:
        - containerPort: 8111
---
apiVersion: v1
kind: Service
metadata:
  name: teamcity
  labels:
    app: teamcity
spec:
  type: ClusterIP
  ports:
  - port: 8111
    targetPort: 8111
    protocol: TCP
  selector:
    app: teamcity
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: teamcity
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  backend:
    serviceName: teamcity
    servicePort: 8111

在GKE上,入口只能指向类型为
LoadBalancer
NodePort
的服务。您可以通过运行以下命令查看入口的错误输出:

kubectl describe ingress teamcity
根据yaml,您可以看到一个错误。如果您使用的是nginx控制器,则必须使用
NodePort类型的服务

Somo文件:


在GKE上,入口只能指向
负载平衡器
节点端口
类型的服务。您可以通过运行以下命令查看入口的错误输出:

kubectl describe ingress teamcity
根据yaml,您可以看到一个错误。如果您使用的是nginx控制器,则必须使用
NodePort类型的服务

Somo文件:


按文件名对资源应用配置:

kubectl apply -f [.yaml file] --force
如果此资源尚不存在,将创建此资源。要使用“apply”,请始终首先使用“apply”或“create--save config”创建资源

2) 如果第一个失败,您可以强制替换、删除,然后重新创建资源:

kubectl replace -f grav-deployment.yml

此命令仅在宽限期=0时使用。如果为true,则立即从API中删除资源并绕过删除。请注意,立即删除某些资源可能会导致不一致或数据丢失,需要确认。

按文件名对资源应用配置:

kubectl apply -f [.yaml file] --force
如果此资源尚不存在,将创建此资源。要使用“apply”,请始终首先使用“apply”或“create--save config”创建资源

2) 如果第一个失败,您可以强制替换、删除,然后重新创建资源:

kubectl replace -f grav-deployment.yml

此命令仅在宽限期=0时使用。如果为true,则立即从API中删除资源并绕过删除。请注意,立即删除某些资源可能会导致不一致或数据丢失,需要确认。

您最近是否将服务描述从
NodePort
更改为
ClusterIP

那么可能就是这个问题


您需要使用
kubectl replace
kubectl apply--force

您最近是否将服务描述从
NodePort
更改为
ClusterIP

那么可能就是这个问题


您需要使用
kubectl replace
kubectl apply--force

您最近是否将服务描述从
NodePort
更改为
ClusterIP
?也许是这个问题?你有没有试过用kubectl替换
--force
?是的,不知怎么回事。该服务现在是“类型:ClusterIP”,但入口中没有发生任何事件。@yvesonline请回答。它解决了我的问题。接下来的每个问题都超出了问题范围,很高兴@xetra11成功了!我添加了它作为答案。您最近是否将服务描述从
NodePort
更改为
ClusterIP
?也许是这个问题?你有没有试过用kubectl替换
--force
?是的,不知怎么回事。该服务现在是“类型:ClusterIP”,但入口中没有发生任何事件。@yvesonline请回答。它解决了我的问题。接下来的每个问题都超出了问题范围,很高兴@xetra11成功了!我添加了它作为答案。我正在使用nginx入口/控制器。此外,Ingress不指向
LoadBalancer
服务,而只指向
NodePort
。由于
LoadBalancer
已经包含
NodePort
,它可以工作。我正在使用nginx入口/控制器。此外,Ingress不指向
LoadBalancer
服务,而只指向
NodePort
。由于
LoadBalancer
已经包括
NodePort
,因此它可以工作。