Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodeSelector: validation failed: must not set the field(s): spec.template.spec.nodeSelector #15190

Closed
springCozyRock opened this issue May 7, 2024 · 11 comments
Labels
kind/question Further information is requested

Comments

@springCozyRock
Copy link

springCozyRock commented May 7, 2024

hi, I really need you guys help. I need to use nodeSelector to place my service on specific node following https://knative.dev/docs/serving/configuration/feature-flags/#kubernetes-host-aliases. But it failed with following error messages.

beatles@kmaster:~$ sudo kubectl apply -f helloworld-go.yaml 
[sudo] password for beatles: 
Warning: Kubernetes default value is insecure, Knative may default this to secure in a future release: spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation, spec.template.spec.containers[0].securityContext.capabilities, spec.template.spec.containers[0].securityContext.runAsNonRoot, spec.template.spec.containers[0].securityContext.seccompProfile
Error from server (BadRequest): error when creating "helloworld-go.yaml": admission webhook "validation.webhook.serving.knative.dev" denied the request: validation failed: must not set the field(s): spec.template.spec.nodeSelector
beatles@kmaster:~$ 

My yaml file

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: helloworld-go
  namespace: example
spec:
  template:
    spec:
      nodeSelector:
        kubernetes.io/hostname: kmaster
      containers:
      - image: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8
        env:
        - name: TARGET
          value: "Go Sample v1"

@springCozyRock springCozyRock added the kind/question Further information is requested label May 7, 2024
@ReToCode
Copy link
Member

ReToCode commented May 7, 2024

@springCozyRock
Copy link
Author

hi @ReToCode , thx a lot. I was actually refering to this url. Is there anything else I have to do?

@ReToCode
Copy link
Member

ReToCode commented May 7, 2024

No that should work. Are you sure you set kubernetes.podspec-nodeselector at the correct place (not in the _example section)?

@springCozyRock
Copy link
Author

I didnot know I should edit Config Map before. Pretty stupid. Let me try and I willclose the issue. Thanks a lot!

    # Indicates whether Kubernetes nodeSelector support is enabled
    #
    # WARNING: Cannot safely be disabled once enabled.
    # See: https://knative.dev/docs/serving/feature-flags/#kubernetes-node-selector
    kubernetes.podspec-nodeselector: "disabled"

@springCozyRock
Copy link
Author

I failed to edit this.

beatles@kmaster:~$ sudo kubectl edit configmap config-features -n knative-serving
error: configmaps "config-features" could not be patched: admission webhook "config.webhook.serving.knative.dev" denied the request: validation failed: the update modifies a key in "_example" which is probably not what you want. Instead, copy the respective setting to the top-level of the ConfigMap, directly below "data"
You can run `kubectl replace -f /tmp/kubectl-edit-3003085152.yaml` to try this update again.

@springCozyRock
Copy link
Author

springCozyRock commented May 7, 2024

I failed to edit this.

No that should work. Are you sure you set kubernetes.podspec-nodeselector at the correct place (not in the _example section)?

oh! I didn't notice it before!

@springCozyRock
Copy link
Author

  kubernetes.podspec-nodeselector: enabled
kind: ConfigMap
metadata:
  annotations:
    knative.dev/example-checksum: f2fc138e
    kubectl.kubernetes.io/last-applied-configuration: |

yes I should put it in the right place and beatles@kmaster:~$ sudo kubectl edit configmap config-features -n knative-serving configmap/config-features edited

@springCozyRock
Copy link
Author

Yes. It totally worked now. I am so excited! Thanks!

@shauryagoel
Copy link

@ReToCode Was this changed recently? I have a cluster in which I installed knative a few months back and in its config-map config-features, I have this set-

  kubernetes.podspec-nodeselector: enabled
  kubernetes.podspec-volumes-emptydir: enabled

However, when I installed knative today in a new cluster (same knative version), the config-map does not have those fields.

@dprotaso
Copy link
Member

@shauryagoel someone must have edited the config map by default we don't set anything

@shauryagoel
Copy link

That seems improbable to me, but, I use kserve (which uses knative), and maybe that is modifying some things. I will check there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants