<p>I want to deploy my service as a ClusterIP but am not able to apply it for the given error message:</p>

<pre><code>[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'
</code></pre>

<p>This here is my .yaml file:</p>

<pre><code>---
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
</code></pre>

xetra11
<p>Apply a configuration to the resource by filename:</p>

<pre><code>kubectl apply -f [.yaml file] --force
</code></pre>

<p>This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.</p>

<p>2) If the first one fails, you can force replace, delete and then re-create the resource:</p>

<pre><code>kubectl replace -f grav-deployment.yml
</code></pre>

<p>This command is only used when grace-period=0. If true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.</p>
