Docker Community Forums

Share and learn in the Docker community.

Kubernetes Stack Deploy error PersistentVolumeClaim "-api-0" is invalid: metadata.name: Invalid value


(Adam Duro) #1

I am trying to migrate my local development environment over to the new Kubernetes setup built into Docker for Mac. I followed the instructions here:

As in documentation I run: docker stack deploy --compose-file docker-compose.yml my-app

I have a host volume in my docker-compose defined nearly identically as the tutorial above:

volumes:
  - /opt/app/node_modules/
  - .:/opt/app

The StatefulSet that docker creates does not come up, and I get the following error in the Kubernetes dashboard event log:

create Claim -api-0 for Pod api-0 in StatefulSet api failed error: PersistentVolumeClaim "-api-0" is invalid: metadata.name: Invalid value: "-api-0": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

Here is my full docker-compose for reference:

version: '3.3'
services:
  mongo:
    image: mongo:3.4
    ports:
      - "27017:27017"
    command: mongod --smallfiles --rest
  api:
    build: .
    environment:
      - <ENVVARS_REDACTED>
    ports:
      - "3000:3000"
      - "9333:9333"
    links:
      - mongo
    depends_on:
      - mongo
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/hello"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - /opt/app/node_modules/
      - .:/opt/app

It would appear that docker stack deploy when it creates the underlying K8 configs is adding a dash to the beginning of the volume name. Any idea how to fix, or if I am doing something wrong?