How to deploy Ubuntu docker image from Docker Hub to local kubernetes env

511 views Asked by At

I have my own Kubernetes env with 3 nodes. I'm trying to deploy a basic Ubuntu docker image from Docker Hub, but it gives error like below.

Firstly I followed the instructions the link below. I suppose that everything's ok.

https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token

Then I created a basic ubuntu yaml file:

apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: ubuntu:21.04
  imagePullSecrets:
  - name: regcred

But after I apply, pod's status is "ContainerCreating" and it gives error like below;

[root@user]# kubectl describe pod private-reg
Name:         private-reg
Namespace:    kube-system
Priority:     0
Node:         server3/10.100.2.183
Start Time:   Tue, 08 Dec 2020 14:44:41 +0200
Labels:       <none>
Annotations:  <none>
Status:       Pending
IP:
IPs:          <none>
Containers:
  private-reg-container:
    Container ID:
    Image:          ubuntu:21.04
    Image ID:
    Port:           <none>
    Host Port:      <none>
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-57296 (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-57296:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-57296
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason                  Age                From               Message
  ----     ------                  ----               ----               -------
  Normal   Scheduled               18s                default-scheduler  Successfully assigned kube-system/private-reg to server3
  Warning  FailedCreatePodSandBox  74s                kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "aac36b2a8b1af982eeea04bd914c3614ffda31c7881822c2d5dd335780335cf0" network for pod "private-reg": networkPlugin cni failed to set up pod "private-reg_kube-system" network: error getting ClusterInformation: Get "https://[10.96.0.1]:443/apis/crd.projectcalico.org/v1/clusterinformations/default": x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes"), failed to clean up sandbox container "aac36b2a8b1af982eeea04bd914c3614ffda31c7881822c2d5dd335780335cf0" network for pod "private-reg": networkPlugin cni failed to teardown pod "private-reg_kube-system" network: error getting ClusterInformation: Get "https://[10.96.0.1]:443/apis/crd.projectcalico.org/v1/clusterinformations/default": x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")]
  Normal   SandboxChanged          60s (x2 over 74s)  kubelet            Pod sandbox changed, it will be killed and re-created.

Pods are like below:

[root@server ~]# kubectl get pods
NAME                                 READY   STATUS    RESTARTS   AGE
coredns-f9fd979d6-gsksj              1/1     Running   3          35d
coredns-f9fd979d6-r5gr8              1/1     Running   3          35d
etcd-serverkube1                     1/1     Running   4          35d
kube-apiserver-serverkube1           1/1     Running   5          35d
kube-controller-manager-srvkube1     1/1     Running   4          35d
kube-proxy-8ngxt                     1/1     Running   1          22d
kube-proxy-lv5b4                     1/1     Running   4          35d
kube-proxy-xfswt                     1/1     Running   2          22d
kube-scheduler-srvkube1              1/1     Running   4          35d
ubuntu                               1/1     Running   5          26d
weave-net-749h4                      2/2     Running   2          22d
weave-net-cpj5h                      2/2     Running   11         35d
weave-net-fpjqp                      2/2     Running   5          22d

How can I solve this problem? Thanks!

0

There are 0 answers