k3s with skaffold: container can't be pulled
k3s with skaffold: container can't be pulled
我正在创建一个微服务 API 我想 运行 在本地 raspberry k3s 集群上。
目的是在开发的时候使用skaffold来部署
我遇到的问题是每次我使用 skaffold dev
我都有同样的错误:
deployment/epos-auth-deploy: container epos-auth is waiting to start: 192.168.1.10:8080/epos_auth:05ea8c1@sha256:4e7f7c7224ce1ec4831627782ed696dee68b66929b5641e9fc6cfbfc4d2e82da can't be pulled
我尝试设置一个本地 docker 注册表,它是用这个 docker-compose.yaml 文件定义的:
version: '2.0'
services:
registry:
image: registry:latest
volumes:
- ./registry-data:/var/lib/registry
networks:
- registry-ui-net
ui:
image: joxit/docker-registry-ui:static
ports:
- 8080:80
environment:
- REGISTRY_TITLE=Docker Registry
- REGISTRY_URL=http://registry:5000
depends_on:
- registry
networks:
- registry-ui-net
networks:
registry-ui-net:
它正在 http://192.168.1.10:8080
我的本地网络上工作。
构建和推送镜像时似乎没问题。
我也在本地电脑上设置了/etc/docker/daemon.json
{
"insecure-registries": ["192.168.1.10:8080"],
"registry-mirrors": ["http://192.168.1.10:8080"]
}
我在所有节点上设置了 /etc/rancher/k3s/registries.yaml:
mirrors:
docker.io:
endpoint:
- "http://192.168.1.10:8080"
skaffold.yaml 看起来像这样:
apiVersion: skaffold/v2alpha3
kind: Config
metadata:
name: epos-skaffold
deploy:
kubectl:
manifests:
- ./infra/k8s/skaffold/*
build:
local:
useBuildkit: true
artifacts:
- image: epos_auth
context: epos-auth
docker:
dockerfile: Dockerfile
sync:
manual:
- src: 'src/**/*.ts'
dest: .
而 ./infra/k8s/skaffold/epos-auth-deploy.yaml 看起来像这样:
apiVersion: apps/v1
kind: Deployment
metadata:
name: epos-auth-deploy
spec:
replicas: 1
selector:
matchLabels:
app: epos-auth
template:
metadata:
labels:
app: epos-auth
spec:
containers:
- name: epos-auth
image: epos_auth
env:
- name: NATS_URL
value: http://nats-srv:4222
- name: NATS_CLUSTER_ID
value: epos
- name: NATS_CLIENT_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: JWT_KEY
valueFrom:
secretKeyRef:
name: jwt-keys
key: key
- name: JWT_PRIVATE_KEY
valueFrom:
secretKeyRef:
name: jwt-keys
key: private_key
- name: JWT_PUBLIC_KEY
valueFrom:
secretKeyRef:
name: jwt-keys
key: public_key
- name: MONGO_URI
value: mongodb://mongodb-srv:27017/auth-service
---
apiVersion: v1
kind: Service
metadata:
name: epos-auth-srv
spec:
selector:
app: epos-auth
ports:
- name: epos-auth
protocol: TCP
port: 3000
targetPort: 3000
我做到了
skaffold config set default-repo 192.168.1.10:8080
skaffold config set insecure-registries 192.168.1.10:8080
真不知道这是怎么回事
你有什么线索吗?
请更改 docker.io
参考,因为它令人困惑;
mirrors:
docker.io:
endpoint:
- "http://192.168.1.10:8080"
并使用带有完整注册表路径的 image
,就像:
registry.local:5000/epos_auth
我在主节点上安装了docker-ce。然后我在命令中使用 --docker
参数创建了主节点。
我在创建k3s节点的时候,定义了一个context。我忘了在 ~/.skaffold/config
中替换 default
上下文
我正在创建一个微服务 API 我想 运行 在本地 raspberry k3s 集群上。
目的是在开发的时候使用skaffold来部署
我遇到的问题是每次我使用 skaffold dev
我都有同样的错误:
deployment/epos-auth-deploy: container epos-auth is waiting to start: 192.168.1.10:8080/epos_auth:05ea8c1@sha256:4e7f7c7224ce1ec4831627782ed696dee68b66929b5641e9fc6cfbfc4d2e82da can't be pulled
我尝试设置一个本地 docker 注册表,它是用这个 docker-compose.yaml 文件定义的:
version: '2.0'
services:
registry:
image: registry:latest
volumes:
- ./registry-data:/var/lib/registry
networks:
- registry-ui-net
ui:
image: joxit/docker-registry-ui:static
ports:
- 8080:80
environment:
- REGISTRY_TITLE=Docker Registry
- REGISTRY_URL=http://registry:5000
depends_on:
- registry
networks:
- registry-ui-net
networks:
registry-ui-net:
它正在 http://192.168.1.10:8080
我的本地网络上工作。
构建和推送镜像时似乎没问题。
我也在本地电脑上设置了/etc/docker/daemon.json
{
"insecure-registries": ["192.168.1.10:8080"],
"registry-mirrors": ["http://192.168.1.10:8080"]
}
我在所有节点上设置了 /etc/rancher/k3s/registries.yaml:
mirrors:
docker.io:
endpoint:
- "http://192.168.1.10:8080"
skaffold.yaml 看起来像这样:
apiVersion: skaffold/v2alpha3
kind: Config
metadata:
name: epos-skaffold
deploy:
kubectl:
manifests:
- ./infra/k8s/skaffold/*
build:
local:
useBuildkit: true
artifacts:
- image: epos_auth
context: epos-auth
docker:
dockerfile: Dockerfile
sync:
manual:
- src: 'src/**/*.ts'
dest: .
而 ./infra/k8s/skaffold/epos-auth-deploy.yaml 看起来像这样:
apiVersion: apps/v1
kind: Deployment
metadata:
name: epos-auth-deploy
spec:
replicas: 1
selector:
matchLabels:
app: epos-auth
template:
metadata:
labels:
app: epos-auth
spec:
containers:
- name: epos-auth
image: epos_auth
env:
- name: NATS_URL
value: http://nats-srv:4222
- name: NATS_CLUSTER_ID
value: epos
- name: NATS_CLIENT_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: JWT_KEY
valueFrom:
secretKeyRef:
name: jwt-keys
key: key
- name: JWT_PRIVATE_KEY
valueFrom:
secretKeyRef:
name: jwt-keys
key: private_key
- name: JWT_PUBLIC_KEY
valueFrom:
secretKeyRef:
name: jwt-keys
key: public_key
- name: MONGO_URI
value: mongodb://mongodb-srv:27017/auth-service
---
apiVersion: v1
kind: Service
metadata:
name: epos-auth-srv
spec:
selector:
app: epos-auth
ports:
- name: epos-auth
protocol: TCP
port: 3000
targetPort: 3000
我做到了
skaffold config set default-repo 192.168.1.10:8080
skaffold config set insecure-registries 192.168.1.10:8080
真不知道这是怎么回事
你有什么线索吗?
请更改 docker.io
参考,因为它令人困惑;
mirrors:
docker.io:
endpoint:
- "http://192.168.1.10:8080"
并使用带有完整注册表路径的 image
,就像:
registry.local:5000/epos_auth
我在主节点上安装了docker-ce。然后我在命令中使用
--docker
参数创建了主节点。我在创建k3s节点的时候,定义了一个context。我忘了在
中替换~/.skaffold/config
default
上下文