applying task in k8s pod

12/17/2018

I'm trying to run kubectl -f pod.yaml but getting this error. Any hint?

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
-- AhmFM
kubectl
kubernetes

1 Answer

12/17/2018

You have an indentation error on your pod.yaml definition with imagePullSecrets and you need to specify the - name: for your imagePullSecrets. Should be something like this:

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
...

Note that imagePullSecrets: is plural and an array so you can specify multiple credentials to multiple registries.

If you are using Docker you can also specify multiple credentials in ~/.docker/config.json.

If you have the same credentials in imagePullSecrets: and configs in ~/.docker/config.json, the credentials are merged.

-- Rico
Source: StackOverflow