在简单的打印 hello 世界程序中获取 kubernetes 部署中的错误"ErrImagePull"



helloworld.java:

import java.util.*; 
public class helloworld {
public static void main(String[] a)
{
int index;
Scanner scan = new Scanner(System.in);
for(index=0;index<20;index++)
System.out.println("helloworldt"+(index+1));
}
}

Dockerfile.file

FROM openjdk:7
LABEL maintainer="Arun kumar"
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
RUN javac helloworld.java
CMD ["java", "helloworld"]

这将准备一个docker映像,然后我可以使用以下命令创建该映像(在文件所在的存储库中(:docker built -t javaprogram .

然后我使用以下命令运行此图像:docker run -it -d javaprogram

然后我使用以下命令创建容器的副本:docker commit containerId arunkumarduraisamy66/javacontprogram

然后,我使用以下命令以公共模式将图像推送到我的docker hub存储库:docker push arunkumarduraisamy66/javacontprogram

然后我启动MiniKube:minikube start

然后我尝试使用以下命令创建一个容器:kubectl create deployment javakubedeployment --image=arunkumarduraisamy66/javacontprogram

它给出以下错误:ErrImagePull

我不知道如何解决这个问题。

C:UsersthulaDocumentskubernetes and dockerdocker javahelloworld> kubectl describe pod javaprogram-64b48854-ns7jp
Name:         javaprogram-64b48854-ns7jp
Namespace:    default
Priority:     0
Node:         minikube/192.168.49.2
Start Time:   Wed, 30 Dec 2020 09:04:42 +0530
Labels:       app=javaprogram
pod-template-hash=64b48854
Annotations:  <none>
Status:       Running
IP:           172.17.0.3
IPs:
IP:           172.17.0.3
Controlled By:  ReplicaSet/javaprogram-64b48854
Containers:
javacontprogram:
Container ID:   docker://8cb0722bde94704a3dfbec2514958c1cea88bd0f5df0afb2678292835c4f871e
Image:          arunkumarduraisamy66/javacontprogram
Image ID:       docker-pullable://arunkumarduraisamy66/javacontprogram@sha256:fe00f09ebc6a6bc651343a807b1adf9e48b62596ddf9424abc11ef3c6f713291
Port:           <none>
Host Port:      <none>
State:          Terminated
Reason:       Error
Exit Code:    1
Started:      Wed, 30 Dec 2020 09:05:50 +0530
Finished:     Wed, 30 Dec 2020 09:05:51 +0530
Last State:     Terminated
Reason:       Error
Exit Code:    1
Started:      Wed, 30 Dec 2020 09:05:16 +0530
Finished:     Wed, 30 Dec 2020 09:05:17 +0530
Ready:          False
Restart Count:  3
Environment:    <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-bs9b6 (ro)
Conditions:
Type              Status
Initialized       True
Ready             False
ContainersReady   False
PodScheduled      True
Volumes:
default-token-bs9b6:
Type:        Secret (a volume populated by a Secret)
SecretName:  default-token-bs9b6
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  79s                default-scheduler  Successfully assigned default/javaprogram-64b48854-ns7jp to minikube
Normal   Pulled     74s                kubelet            Successfully pulled image "arunkumarduraisamy66/javacontprogram" in 3.4663937s
Normal   Pulled     68s                kubelet            Successfully pulled image "arunkumarduraisamy66/javacontprogram" in 3.5957121s
Normal   Pulled     46s                kubelet            Successfully pulled image "arunkumarduraisamy66/javacontprogram" in 3.8325583s
Normal   Pulling    16s (x4 over 77s)  kubelet            Pulling image "arunkumarduraisamy66/javacontprogram"
Normal   Pulled     13s                kubelet            Successfully pulled image "arunkumarduraisamy66/javacontprogram" in 3.5564947s
Normal   Created    12s (x4 over 74s)  kubelet            Created container javacontprogram
Normal   Started    12s (x4 over 73s)  kubelet            Started container javacontprogram
Warning  BackOff    10s (x5 over 66s)  kubelet            Back-off restarting failed container

我已经重新创建了您的应用程序的映像,正如@mmking在评论中提到的,它被终止了,因为pod已经完成了它的任务。当你检查pod的日志时,你可以看到它已经正确运行并打印了helloworld20次,然后被终止,因为这个pod没有其他事情可做:

$kubectl logs javakubedeployment-7bcfb44b74-8b5zz
helloworld      1
helloworld      2
helloworld      3
[...]
helloworld      19
helloworld      20

要保持pod运行,您可以在其中添加简单的sleep命令。

最新更新