问题

Failed to get D-Bus connection: Operation not permitted

解决方案

添加参数

.yaml文件中spec指定securityContext.privileged=true给予容器权限。

使用该参数container内的root拥有真正的root权限,否则container内的root只是外部的一个普通用户权限。

cat pod1.yaml
apiVersion: v1
kind: Pod
metadata:
  name: lhr2019ocpasm
spec:
  containers:
  - name: oracle19casmlhr
    image: lhrbest/oracle19casm_lhr:1.0
    command: ["/usr/sbin/init", "-c","--"]
    securityContext:
      privileged: true

跑pod

ko apply -f pod1.yaml
pod/lhr2019ocpasm created

运行

ko get pod
NAME            READY   STATUS    RESTARTS   AGE
lhr2019ocpasm   1/1     Running   0          7s
ko describe pod lhr2019ocpasm
Name:         lhr2019ocpasm
Namespace:    oracle-server
Priority:     0
Node:         */*
Start Time:   Wed, 06 Jul 2022 23:30:37 +0800
Labels:       <none>
Annotations:  Status:  Running
IP:           10.244.2.250
IPs:
  IP:  10.244.2.250
Containers:
  oracle19casmlhr:
    Container ID:  docker://d666caef547454d857f35df94a2ef58ee6afea40c28600064e943061503756e4
    Image:         lhrbest/oracle19casm_lhr:1.0
    Image ID:      docker-pullable://lhrbest/oracle19casm_lhr@sha256:215a96506d0cacf9dd7c78dceef3d5a9afdf6b8d7ae3664e65bc5217a2b67981
    Port:          <none>
    Host Port:     <none>
    Command:
      /usr/sbin/init
      -c
      --
    State:          Running
      Started:      Wed, 06 Jul 2022 23:30:39 +0800
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-994kl (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-994kl:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-994kl
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  27s   default-scheduler  Successfully assigned oracle-server/lhr2019ocpasm to 100-10-1-165
  Normal  Pulled     26s   kubelet            Container image "lhrbest/oracle19casm_lhr:1.0" already present on machine
  Normal  Created    26s   kubelet            Created container oracle19casmlhr
  Normal  Started    26s   kubelet            Started container oracle19casmlhr
ko exec -it lhr2019ocpasm bash

在这里插入图片描述
在这里插入图片描述

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐