Getting Error While Deploying Raw Yaml to Kubernetes with Variable for config map

Hi Community ,

Im trying to deploy raw yaml to kubernates cluster under stored on rancher for specific namespace.

I could deploy without using any volume mounts and config map (using for volume) but couldn’t be successfully with using stored config map on rancher for under this namespace value.

my release created from teamcity successfully.

Im getting array error on validation in this step , any suggest to me? would be appreciated

ValidationError(Deployment.spec.template.spec.containers): invalid type for io.k8s.api.core.v1.PodSpec.containers: got “map”, expected “array”; if you choose to ignore these errors, turn validation off with --validate=false
The remote script failed with exit code 1

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: #{rancher.service_name}-#{Octopus.Action[Variable].Output.branch}
  namespace: somenamespace
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  selector:
    matchLabels:
      workload.user.cattle.io/workloadselector: #{rancher.service_name}-#{Octopus.Action[Variable].Output.branch}
  template:
    metadata:
      labels:
        io.emlakjet.dc: somelabel
        io.emlakjet.stack: somelabel
        workload.user.cattle.io/workloadselector: #{rancher.service_name}-#{Octopus.Action[Variable].Output.branch}
    spec:
      containers:
        - envFrom:
            configMapRef:
              name: myconfigmap
              optional: false
          command:
            - /usr/bin/pm2-docker
            - /app/pm2.json
          image: #{docker_hub.path}/#{docker_hub.image_name}:#{Octopus.Action[Variable].Output.branch}-#{Octopus.Release.Number}
          imagePullPolicy: Always
          name: #{rancher.service_name}-#{Octopus.Action[Variable].Output.branch}
          ports:
            - containerPort: 80
              protocol: TCP
          resources: {}
          volumeMounts:
            - mountPath: /app/config
              name: volname
          securityContext:
            allowPrivilegeEscalation: false
            capabilities: {}
            privileged: false
            readOnlyRootFilesystem: false
            runAsNonRoot: false
      serviceAccountName: ""
      imagePullSecrets:
        - name: mysecret
      restartPolicy: Always
      volumes:
        - configMap:
            defaultMode: 256
            name: myconfigmapstoredonrancher
            optional: false
          name: somenamespace

Hi @selcuk.kubur,

Thanks for getting in touch!

With you mentioning that the error occurs after adding the volume mount and config map, and with the error stating got “map”, expected “array” my best guess would be to change the configMap from a map to an array. The examples I can find of the volumes and configMap seem to suggest it needs to be an array too.

e.g.

  volumes:
    # You set volumes at the Pod level, then mount them into containers inside that Pod
    - name: config
      configMap:
        # Provide the name of the ConfigMap you want to mount.
        name: game-demo

I hope this helps.

Regards,
Paul

1 Like

Thank you so much, @paul.calvert I could deploy with this.

1 Like