0

我正在创建一个我想在本地树莓 k3s 集群上运行的微服务 API。

目的是在开发过程中使用 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-compose.yaml 文件定义的本地 docker 注册表:

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

我真的不知道这有什么问题。

你有什么线索吗?

4

2 回答 2

0

请更改docker.io参考,因为它令人困惑;

mirrors:
  docker.io:
    endpoint:
      - "http://192.168.1.10:8080"

并使用image完整的注册表路径,就像: registry.local:5000/epos_auth

https://devopsspiral.com/articles/k8s/k3d-skaffold/

于 2021-02-13T10:24:06.920 回答
0
  • 我在主节点上安装了 docker-ce。--docker然后我在命令中使用参数创建了主节点。

  • 当我创建 k3s 节点时,我定义了一个上下文。我忘了替换default上下文~/.skaffold/config

于 2021-02-15T17:55:52.883 回答