我正在开发一个Spring Boot应用程序,我使用docker-compose来创建我的容器。对于Kubernetes,我使用kompose via minikubes。我把我的图像推到了Docker hub,我尝试用两种方式部署我的容器
组成
和
kompose convert -f docker-compose.yaml kubectl create -f(deplymentfiles)
但我得到了这个回复
WARN Volume mount on the host "/home/App/src/main/docker/postgres-data" isn't supported - ignoring path on the host
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
INFO Deploying application in "default" namespace
INFO Successfully created Service: adminer
INFO Successfully created Service: app
INFO Successfully created Service: mypostgres
INFO Successfully created Deployment: adminer
INFO Successfully created Deployment: app
INFO Successfully created Deployment: mypostgres
INFO Successfully created PersistentVolumeClaim: mypostgres-claim0 of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work
当我运行kubectl get pods
NAME READY STATUS RESTARTS AGE
adminer-6cd96f8846-69qb8 1/1 Running 0 2m
app-5796c489ff-m46xk 0/1 ImagePullBackOff 0 2m
mypostgres-649865b4d8-nhglj 1/1 Running 0 2m
kubectl描述pod app-5796c489ff-m46xk
显示了这个
Name: app-5796c489ff-m46xk
Namespace: default
Node: minikube/192.168.99.100
Start Time: Mon, 11 Jun 2018 11:02:32 +0200
Labels: io.kompose.service=app
pod-template-hash=1352704599
Annotations: <none>
Status: Pending
IP: 172.17.0.3
Controlled By: ReplicaSet/app-5796c489ff
Containers:
app:
Container ID:
Image: iroolapp
Image ID:
Port: 8086/TCP
Host Port: 0/TCP
State: Waiting
Reason: ImagePullBackOff
Ready: False
Restart Count: 0
Environment:
DATABASE_HOST: mypostgres
DATABASE_NAME: test
DATABASE_PASSWORD: root
DATABASE_PORT: 5432
DATABASE_USER: root
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-wdb8n (ro)
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
Volumes:
default-token-wdb8n:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-wdb8n
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 3m default-scheduler Successfully assigned app-5796c489ff-m46xk to minikube
Normal SuccessfulMountVolume 3m kubelet, minikube MountVolume.SetUp succeeded for volume "default-token-wdb8n"
Normal Pulling 1m (x4 over 3m) kubelet, minikube pulling image "iroolapp"
Warning Failed 1m (x4 over 3m) kubelet, minikube Failed to pull image "iroolapp": rpc error: code = Unknown desc = Error response from daemon: pull access denied for iroolapp, repository does not exist or may require 'docker login'
Warning Failed 1m (x4 over 3m) kubelet, minikube Error: ErrImagePull
Normal BackOff 1m (x6 over 3m) kubelet, minikube Back-off pulling image "iroolapp"
Warning Failed 1m (x6 over 3m) kubelet, minikube Error: ImagePullBackOff
最后这是我的docker-compose文件
version: '3'
services:
app:
image: iroolapp
depends_on:
- mypostgres
ports:
- "9000:8086"
environment:
- DATABASE_HOST=mypostgres
- DATABASE_USER=root
- DATABASE_PASSWORD=root
- DATABASE_NAME=test
- DATABASE_PORT=5432
networks:
default:
mypostgres:
image: postgres:9.6-alpine
container_name: mypostgres
ports:
- "5433:5432"
environment:
- POSTGRES_PASSWORD=root
- POSTGRES_USER=root
- POSTGRES_DB=irooldb
volumes:
- ./postgres-data:/var/lib/postgresql/data
adminer:
image: adminer
ports:
- 8080:8080
networks:
default:
networks:
default:
external:
name: mynetwork
我的问题是:ImagePullBackoff指的是什么?使用kompose是一个很好的方法吗?在使用kubernetes之前将图像推送到docker hub是必要的步骤
答案 0 :(得分:0)
Q1
ImagePullBackoff引用什么
从日志中,您可以看到它多次尝试拉动图像&#34; iroolapp&#34; pod app-5796c489ff-m46xk的容器需求(请参阅pod image
的{{1}}字段)来自注册表并且都失败了。 container
发生在那些失败之后。
Q2
使用kompose是一种很好的方法吗?
Havn没用过它......
Q3
并且是在使用kubernetes之前将图像推送到docker hub的必要步骤
不是。如果只是为了进行简单测试,您可以将ImagePullBackoff
设置为imagePullPolicy
或IfNotPreset
来使用本地图像(确保图像已加载)。或者,您可以拥有私人注册表。
答案 1 :(得分:0)
public void AbbeyNational (String AbbeyNationalURL, String AN_AccCookiesButton, String AN_MortgageTabButton, String AN_ExistingCustomerButton, String AN_FollowRateButton, String AN_SVRButton, String AN_RateFld)throws InterruptedException {
driver.get(AbbeyNationalURL);
driver.findElement(By.xpath(AN_AccCookiesButton)).click();
driver.findElement(By.linkText(AN_MortgageTabButton)).click();
driver.findElement(By.xpath(AN_ExistingCustomerButton)).click();
driver.findElement(By.xpath(AN_FollowRateButton)).click();
driver.findElement(By.xpath(AN_SVRButton)).click();
String a = driver.findElement(By.cssSelector(AN_RateFld)).getText();
String AN_Rate = a.substring(54,58);
System.out.println(AN_Rate);
}
表示您无法获取图片。
您是否真的阅读过错误消息?它说public void writeToExcel(String AN_Rate) throws IOException{
File file = new File(filePath+"\\"+fileName);
XSSFWorkbook IRWorkbook = new XSSFWorkbook();
XSSFSheet Sheet0 = IRWorkbook.createSheet();
Sheet0.createRow(0).createCell(0).setCellValue(AN_Rate);
try {
FileOutputStream fos = new FileOutputStream(file);
IRWorkbook.write(fos);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
您是否登录了泊坞中心?你的形象是在码头工人中心吗?因为那是它试图拉动图像的地方。
答案 2 :(得分:0)
我想通了,实际上在我的docker-compose文件中,我应该指定图像,引用在docker hub中推送的存储库中发布的图像:
image: docker.io/<dockerHub username>/<imagename>
答案 3 :(得分:0)
我认为图像名称根本没有正确的方向。如果您存储在仓库中,请提供完整的路径,例如“ username / repo:tag”,否则请首先在终端“ docker search imagename”中通过命令进行搜索。 Kubernetes一次又一次地拉映像直到运行状态,因此RESTART计数可能很高。因此,为其提供正确的url或私有回购路径。