Warm tip: This article is reproduced from serverfault.com, please click

Kubectl apply command for updating existing service resource

发布于 2018-12-18 09:51:19

Currently I'm using Kubernetes version 1.11.+. Previously I'm always using the following command for my cloud build scripts:

- name: 'gcr.io/cloud-builders/kubectl'
  id: 'deploy'
  args:
  - 'apply'
  - '-f'
  - 'k8s'
  - '--recursive'
  env:
  - 'CLOUDSDK_COMPUTE_ZONE=${_REGION}'
  - 'CLOUDSDK_CONTAINER_CLUSTER=${_CLUSTER_NAME}'

And the commands just working as expected, at that time I'm using k8s version 1.10.+. However recently I got the following error:

  • spec.clusterIP: Invalid value: "": field is immutable
  • metadata.resourceVersion: Invalid value: "": must be specified for an update

So I'm wondering if this is an expected behavior for Service resources?

Here's my YAML config for my service:

apiVersion: v1
kind: Service
metadata:
  name: {name}
  namespace: {namespace}
  annotations:
    beta.cloud.google.com/backend-config: '{"default": "{backend-config-name}"}'
spec:
  ports:
   - port: {port-num}
     targetPort: {port-num}
  selector:
    app: {label}
    environment: {env}
type: NodePort
Questioner
irvifa
Viewed
0
Jordan Liggitt 2018-12-19 08:16:31