无法在我的GKE群集中将服务用作“类型:ClusterIP”

我想将我的服务部署为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
lxt2015 回答:无法在我的GKE群集中将服务用作“类型:ClusterIP”

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

kubectl describe ingress teamcity

您会看到一个错误,根据您的Yaml,如果您使用的是Nginx控制器,则必须使用NodePort类型的服务

Somo文档:

https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer https://github.com/kubernetes/ingress-nginx/blob/master/docs/deploy/index.md#gce-gke

,

通过文件名将配置应用于资源:

kubectl apply -f [.yaml file] --force

如果该资源尚不存在,将创建它。要使用“应用”,请始终始终首先使用“应用”或“创建--save-config”创建资源。

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

kubectl replace -f grav-deployment.yml

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

,

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

那么可能就是这个问题github.com/kubernetes/kubectl/issues/221

您需要使用kubectl replacekubectl apply --force

本文链接:https://www.f2er.com/3168383.html

大家都在问