0

我正在使用下面的 docker-compose。它工作稳定。但我在 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

我将我的应用程序移至 Kubernetes yaml。我将 docker compose 转换为 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

在 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

我在 ubernetes 中收到上述错误。

你能帮助我吗?

4

0 回答 0