在k8s pod中应用任务

问题描述 投票:1回答:1

我正在尝试运行kubectl -f pod.yaml但收到此错误。任何提示?

error: error validating "/pod.yaml": error validating data: [ValidationError(Pod): unknown field "imagePullSecrets" in io.k8s.api.core.v1.Pod, ValidationError(Pod): unknown field "nodeSelector" in io.k8s.api.core.v1.Pod, ValidationError(Pod): unknown field "tasks" in io.k8s.api.core.v1.Pod]; if you choose to ignore these errors, turn validation off with --validate=false

pod.yaml:

apiVersion: v1
kind: Pod
metadata:
  name: gpu-pod-10.0.1
  namespace: e6a5089f-8e9e-4647-abe3-b8d775079565
spec:
  containers:
  - name: main
    image: bded587f4604
  imagePullSecrets: ["testo", "awsecr-cred"]
  nodeSelector:
    kubernetes.io/hostname: 11-4730
tasks:
- name: traind
  command: et estimate -e v/lat/exent_sps/enet/default_sql.spec.txt -r /out
  completions: 1
  inputs:
    datasets:
    - name: poa
      version: 2018-
      mountPath: /in/0
kubernetes kubectl
1个回答
1
投票

你的pod.yaml定义中有imagePullSecrets的缩进错误,你需要为你的- name:指定imagePullSecrets。应该是这样的:

apiVersion: v1
kind: Pod
metadata:
  name: gpu-test-test-pod-10.0.1.11-e8b74730
  namespace: test-e6a5089f-8e9e-4647-abe3-b8d775079565
spec:
  containers:
  - name: main
    image: test.io/tets/maglev-test-bded587f4604
  imagePullSecrets:
  - name: testawsecr-cred
...

请注意,imagePullSecrets:是复数和array,因此您可以为多个注册表指定多个凭据。

如果您使用的是Docker,还可以在~/.docker/config.json中指定多个凭据。

如果您在imagePullSecrets:中具有相同的凭据并且在~/.docker/config.json中具有配置,则会合并凭据。

© www.soinside.com 2019 - 2024. All rights reserved.