0

I am using the docker-compose below. It works stably. but i get error in kubernetes.

docker-compose.yaml

version: "3.3"
services:

  test:
    image: docker.local/test/test:1.0
    container_name: test
    environment:
      RUN_USER: test
      RUN_USER_ID: 1000
      JAVA_OPTS:
          "-Dspring.profiles.active=pg,scm,api,admin,fts,ocr,async,task,proxy
          -Xms64m -Xmx4g"
    ports:
      - "8080:8000"
    extra_hosts:
      - "logserver:172.17.0.1"
    network_mode: bridge

I moved my app to Kubernetes yaml. I converted docker compose to kubernetes.

kubernetes.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-deployment
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
      - env:
        - name: JAVA_OPTS
          value: -Dspring.profiles.active=sqlserver,scm,api,asyncOcr,task -Xms64m -Xmx2g"
        image: docker.local/test/test:0.1
        name: test
        ports:
        - containerPort: 8000
        resources: {}
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: test
  labels:
    app: test
spec:
  selector:
    app: test
  ports:
  - name: "8000"
    port: 8000
    targetPort: 8000

Error received in Kubernetes

Events:
  Type     Reason     Age                From                    Message
  ----     ------     ----               ----                    -------
  Normal   Scheduled  <unknown>          default-scheduler       Successfully assigned test/test-deployment-5754b65d8d-pdk6f to test-k8s-02
  Warning  Failed     37s                kubelet, test-k8s-02  Error: failed to start container "test": Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/kubelet/pods/4b7e15a3-d4e1-4259-8a5d-928cfa7d7ddb/volumes/kubernetes.io~secret/default-token-srrnd\\\" to rootfs \\\"/var/lib/docker/overlay2/bb226214b793aca2352989f2126a746a5e0c5c229f9e4cbbd58981d4ac3db1e3/merged\\\" at \\\"/var/lib/docker/overlay2/bb226214b793aca2352989f2126a746a5e0c5c229f9e4cbbd58981d4ac3db1e3/merged/run/secrets/kubernetes.io/serviceaccount\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

I get the above error in ubernetes.

Can you help me?

public_html
  • 309
  • 1
  • 4
  • 10
  • Can you try to use any other image on the docker hub> ?Just to test. It seems there something wrong with that image. – ALex Jul 26 '20 at 19:06
  • It works with the docker image docker compose I use. – public_html Jul 26 '20 at 19:12
  • 1
    What is docker.local? Is it a private registry you are using? Anyways the error looks as if you are mounting something on to a directory that doesn't exist on the host on which the pod is getting deployed. You might want to share the dockerfile for the same and the docker compose commands as well. Also maybe the cluster is not made well. The service accounts file is mapped on to the host as well with the info as a layer of overlay on the host. You might need to check that as well. – redzack Jul 26 '20 at 21:26
  • Please push your docker image to Docker Hub so that your kubernetes cluster can find it (assuming you are not using a private registry). – David Medinets Jul 29 '20 at 04:04
  • Please show the command you are using to see that error message. – David Medinets Jul 29 '20 at 04:04

0 Answers0