Skip to content

[others]: 部署在k8s后,无法exec -it登入huatuo pod的shell #62

@Dongrc

Description

@Dongrc

你的问题

报错如下

Internal error occurred: 
	error executing command in container: 
		failed to exec in container: 
			failed to start exec "720c6ece92ef26568130c69c3283171f77ea5a2c469281e52e4b6b2cb663d446": 
				OCI runtime exec failed: 
					exec failed: 
						unable to start container process: 
							error adding pid 300656 to cgroups: 
								failed to write 300656: 
									openat2 /sys/fs/cgroup/blkio/kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-pod7ab5c773_63c2_44e8_8a7b_b10e17dc6fa6.slice/cri-containerd-9b23430f3f530e13da69c14de3ec474f7d5a3abad4e5cdc3a619ad1ef591642d.scope/cgroup.procs:
										no such file or directory: unknown
Internal error occurred: 
	error executing command in container: 
		failed to exec in container: 
			failed to start exec "e9929e03fa844acf65d5ee5eb05f3a886d315a33731dd53fdead42f50fce0f62": 
				OCI runtime exec failed: 
					exec failed: 
						unable to start container process: 
							error adding pid 300725 to cgroups: 
								failed to write 300725: 
									openat2 /sys/fs/cgroup/blkio/kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-pod7ab5c773_63c2_44e8_8a7b_b10e17dc6fa6.slice/cri-containerd-9b23430f3f530e13da69c14de3ec474f7d5a3abad4e5cdc3a619ad1ef591642d.scope/cgroup.procs:
										no such file or directory: unknown
Unable to open a shell to the container (none of the shell commmands succeeded)

部署yaml如下

kind: DaemonSet
metadata:
  name: huatuo-bamai
  namespace: sre-common
spec:
  selector:
    matchLabels:
      app: huatuo-bamai
  template:
    metadata:
      labels:
        app: huatuo-bamai
    spec:
      nodeSelector:
        #huatuo: "true"
        kubernetes.io/hostname: ip-xxx.ap-southeast-1.compute.internal
      hostNetwork: true
      hostPID: true
      containers:
        - name: huatuo-bamai
          image: huatuo/huatuo-bamai:latest
          securityContext:
            privileged: true
          env:
            # - name: ELASTICSEARCH_HOST
            #   value: "elasticsearch.monitoring"
            - name: ELASTIC_PASSWORD
              value: "huatuo-bamai"
            - name: RUN_PATH
              value: "/home/huatuo-bamai"
          command:  ["/bin/sh", "/run/huatuo/run.sh"]
          volumeMounts:
            - name: sys
              mountPath: /sys
            - name: proc
              mountPath: /proc
            - name: run
              mountPath: /run
            - name: etc
              mountPath: /etc
              readOnly: true
            - name: var
              mountPath: /var
              readOnly: true
            - name: huatuo-conf
              mountPath: /home/huatuo-bamai/conf/huatuo-bamai.conf
              subPath: huatuo-bamai.conf
            - name: huatuo-script
              mountPath: /run/huatuo/run.sh
              subPath: run.sh
      resources:
        limits:
          cpu: 200m
          memory: 300Mi
        requests:
          cpu: 100m
          memory: 200Mi
      volumes:
        - name: sys
          hostPath:
            path: /sys
        - name: proc
          hostPath:
            path: /proc
        - name: run
          hostPath:
            path: /run
        - name: etc
          hostPath:
            path: /etc
        - name: var
          hostPath:
            path: /var
        - name: huatuo-conf
          configMap:
            name: huatuo-bamai-config
            items:
              - key: huatuo-bamai.conf
                path: huatuo-bamai.conf
        - name: huatuo-script
          configMap:
            name: huatuo-bamai-scripts
            items:
              - key: run.sh
                path: run.sh
      tolerations:
        - operator: Exists
      restartPolicy: Always
      dnsPolicy: ClusterFirstWithHostNet```

似乎和挂载/sys目录有关,如果去掉挂载/sys的话是可以登入shell的,但是huatuo启动后会有类似这样的报错
level="error" msg="start tracing memory_free: attach: attach tracepoint: can't attach tracepoint vmscan/mm_vmscan_direct_reclaim_end in TracePoint(tracepoint_try_to_free_pages_end)#62: neither debugfs nor tracefs are mounted" func="huatuo-bamai/pkg/tracing.(*EventTracing).doStart" file="tracing.go:88"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions