简体   繁体   English

为什么Kubernetes没有将我的秘密附加到我的Pod中?

[英]Why Kubernetes is not attaching my secret into my pod?

I already created my secret as recommend by Kubernetes and followed the tutorial, but the pod isnt with my secret attached. 我已经按照Kubernetes的建议创建了我的秘密,并按照教程进行操作,但是pod并没有附加我的秘密。

As you can see, i created the secret and described it. 如您所见,我创建并描述了秘密。 After i created my pod. 创建完我的广告连播之后。

$ kubectl get secret my-secret --output="jsonpath={.data.\.dockerconfigjson}" | base64 --decode
{"auths":{"my-private-repo.com":{"username":"<username>","password":"<password>","email":"<email>","auth":"<randomAuth>="}}}

$ kubectl create -f my-pod.yaml
pod "my-pod" created

$ kubectl describe pods trunfo
Name:         my-pod
Namespace:    default
Node:         gke-trunfo-default-pool-07eea2fb-3bh9/10.233.224.3
Start Time:   Fri, 28 Sep 2018 16:41:59 -0300
Labels:       <none>
Annotations:  kubernetes.io/limit-ranger=LimitRanger plugin set: cpu request for container container-trunfo
Status:       Pending
IP:           10.10.1.37
Containers:
  container-trunfo:
    Container ID:   
    Image:          <my-image>
    Image ID:       
    Port:           9898/TCP
    State:          Waiting
      Reason:       ErrImagePull
    Ready:          False
    Restart Count:  0
    Requests:
      cpu:        100m
    Environment:  <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-hz4mf (ro)
Conditions:
  Type           Status
  Initialized    True 
  Ready          False 
  PodScheduled   True 
Volumes:
  default-token-hz4mf:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-hz4mf
    Optional:    false
QoS Class:       Burstable
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              4s    default-scheduler                               Successfully assigned trunfo to gke-trunfo-default-pool-07eea2fb-3bh9
  Normal   SuccessfulMountVolume  4s    kubelet, gke-trunfo-default-pool-07eea2fb-3bh9  MountVolume.SetUp succeeded for volume "default-token-hz4mf"
  Normal   Pulling                3s    kubelet, gke-trunfo-default-pool-07eea2fb-3bh9  pulling image "my-private-repo.com/my-image:latest"
  Warning  Failed                 3s    kubelet, gke-trunfo-default-pool-07eea2fb-3bh9  Failed to pull image "my-private-repo.com/my-image:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://my-private-repo.com/v1/_ping: dial tcp: lookup my-private-repo.com on 169.254.169.254:53: no such host
  Warning  Failed                 3s    kubelet, gke-trunfo-default-pool-07eea2fb-3bh9  Error: ErrImagePull
  Normal   BackOff                3s    kubelet, gke-trunfo-default-pool-07eea2fb-3bh9  Back-off pulling image "my-private-repo.com/my-image:latest"
  Warning  Failed                 3s    kubelet, gke-trunfo-default-pool-07eea2fb-3bh9  Error: ImagePullBackOff

What can i do to fix it? 我该如何解决?

EDIT 编辑

This is my pod: 这是我的豆荚:

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
  - name: my-container
    image: my-private-repo/images/<my-image>
    ports:
    - containerPort: 9898
  imagePullSecrets:
  - name: my-secret

As we can see, the secret is defined as expected, but not attached correctly. 我们可以看到,机密已按预期定义,但未正确附加。

You did not get as far as secrets yet. 您还没有得到秘密。 Your logs say 你的日志说

Failed to pull image "my-private-repo.com/my-image:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://my-private-repo.com/v1/_ping : dial tcp: lookup my-private-repo.com on 169.254.169.254:53: no such host Warning Failed 3s kubelet, gke-trunfo-default-pool-07eea2fb-3bh9 Error: ErrImagePull 无法提取图像“ my-private-repo.com/my-image:latest”:rpc错误:代码=未知desc =来自守护程序的错误响应:获取https://my-private-repo.com/v1/_ping :拨打tcp:在169.254.169.254:53上查找my-private-repo.com:没有这样的主机警告3s kubelet失败,gke-trunfo-default-pool-07eea2fb-3bh9错误:ErrImagePull

Which means that your pod cannot event start because the image is not available. 这意味着您的Pod无法启动,因为该图像不可用。 Fix that, and if you still have problem with secrets after you observer pod state "ready" post your yaml definition. 修复此问题,如果在观察者窗格状态“就绪”发布yaml定义后,您仍然对机密有疑问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在我的 Kubernetes 吊舱中使用 OpenSSL 命令 - using OpenSSL command in my Kubernetes pod 如何修改我的 DOCKERFILE 以将 wget 安装到 kubernetes pod 中? - How do I modify my DOCKERFILE to install wget into kubernetes pod? 在我的kubernetes Pod中使用本地系统中的数据 - Use data from local system in my kubernetes Pod 尝试上传我的kubernetes pod时出现错误状态 - Getting error status trying to upload my kubernetes pod 如何将我的 Kube.netes pod 连接到远程 Jaeger? - How can I connect my Kubernetes pod to a remote Jaeger? 如何使Kubernetes复制控制器使用某个秘密来提取映像? - How do I make my Kubernetes replication controller use a certain secret to pull an image? 为什么我的广告连播为什么不响应裸露端口上的请求? - Why doesn't my pod respond to requests on the exposed port? Kubernetes PersistentVolume和PersistentVolumeClaim可能会导致我的pod出现问题,该问题在复制日志时崩溃 - Kubernetes PersistentVolume and PersistentVolumeClaim could be causing issues for my pod which crashes while copying logs 如何在 kubernetes 中将具有数据(我需要此数据)的 pod 容器路径挂载到我的本地主机路径 - How to mount pod container path which is having data (I need this data)to my local host path in kubernetes 为什么 kubernetes pod 无法运行 docker 镜像 - Why kubernetes pod fails to run docker image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM