Menu

Dipesh Majumdar

Blog and Paintings

Common Mistakes in declarative yaml manifests and imperative commands

Its a common mistake - you need to know yaml properly. so here i first did this

    readinessProbe:
     httpGet:
     - port: 80
       path: /

and got this error - 

 got "array", expected "map";

The correct way is this

    readinessProbe:
     httpGet:
       port: 80
       path: /

******************************************************

got map expected array - 

    volumeMounts:
      name: xyz
      mountPath: /etc/foo

should be - 

    volumeMounts:
      - name: xyz
        mountPath: /etc/foo

**********************************

 unknown field "name"

spec:
  volumes:
     name: xyz
     secret:
       name: mysecret3

should be - 

spec:
  volumes:
   - name: xyz
     secret:
       secretName: mysecret3

 

*************************************

Attaching service account with pod. one tends to do it this way - 

  serviceAccount:
    name: myuser

Correct way is this:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
spec:
  serviceAccountName: myuser
  containers:
  - image: nginx
    name: nginx
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}

***************************************

While creating secret from a file create the password or username as the file and then value of password or username should be entered in the file. only one value - remember... otherwise its better to create secret from literal

[dipesh.majumdar@demo ~]$ echo pass >password
[dipesh.majumdar@demo ~]$ k create secret generic mysecret2 --from-file=password

***********************************************************************

This is not the way to create configmap

[dipesh.majumdar@demo ~]$ k -n temp create cm cm1 --from-literal=db=mysqldipz22,user=dipz22,password=password123
configmap/cm1 created
[dipesh.majumdar@demo ~]$ k -n temp get cm cm1 -o yaml
apiVersion: v1
data:
  db: mysqldipz22,user=dipz22,password=password123
kind: ConfigMap
metadata:
  creationTimestamp: "2019-04-15T18:54:54Z"
  name: cm1
  namespace: temp
  resourceVersion: "1948893"
  selfLink: /api/v1/namespaces/temp/configmaps/cm1
  uid: f4d36380-5faf-11e9-9e93-42010a8400d9
[dipesh.majumdar@demo ~]$ k -n temp

THIS IS THE CORRECT WAY:

[dipesh.majumdar@demo ~]$ k -n temp create cm cm1 --from-literal=db=mysqldipz22 --from-literal=user=dipz22 --from-literal=password=password123
configmap/cm1 created

 

Go Back

Comment