0

我有点困惑如何skaffold在我的情况下正确设置。这是我的skaffold.yaml

apiVersion: skaffold/v2beta17
kind: Config
build:
  tagPolicy:
    gitCommit: {}
  artifacts:
    - image: zero-x/spring-cloud-kubernetes/config-map-it
      custom:
        buildCommand: ./build.sh
  local:
    useDockerCLI: false
    useBuildkit: false
    push: false


deploy:
  helm:
    releases:
      - name: config-map-it
        chartPath: src/main/helm
        artifactOverrides:
          # skaffold will override this with a different tag
          image: zero-x/spring-cloud-kubernetes/config-map-it
        valuesFiles:
          - src/main/helm/values.yaml
        wait: true
        setValues:
          namespace: spring-k8s

build.sh

#!/usr/bin/env bash

# build jar only, no tests, no chart
.././gradlew clean build bootjar -x test -x helmChartBuild --quiet
docker build --quiet --build-arg JAR_FILE='build/libs/*.jar'  -t ${IMAGE} .

${IMAGE}由 提供skaffold

所以我需要构建第jar一个,将其打包到映像中并进行部署。我依次调用两件事:

skaffold build // builds the image just fine
skaffold deploy

失败:

 You either need to:
 run [skaffold deploy] with [--images TAG] for each pre-built artifact
 or [skaffold run] instead, to let Skaffold build, tag and deploy artifacts.
 no tag provided for image [zero-x/spring-cloud-kubernetes/config-map-it]

这里发生了什么?没有太多的抨击,我无法让这个工作。至少可以说,关于 skaffold 以及如何正确做事的教程和文档很少。

编辑

所以我确实在做:

kind create cluster --name spring-k8s --wait 5m

在那个程度上,我认为如果我这样做:

deploy:
   kubeContext: kind-spring-k8s
   helm:
   ...

事情会奏效,但事实并非如此。

如果我从头开始一切并运行:

skaffold deploy --file-output=images.json -vdebug

我确实看到了:

Tags used in deployment:
 - zero-x/spring-cloud-kubernetes/config-map-it -> zero-x/spring-cloud-kubernetes/config-map-it:78da248b669d2fafacbd144cf22d7251dfde57c664c70a5fd7d53793d9d5efd7
DEBU[0000] Local images can't be referenced by digest.
They are tagged and referenced by a unique, local only, tag instead.
See https://skaffold.dev/docs/pipeline-stages/taggers/#how-tagging-works

或者以后:

helm --kube-context kind-spring-k8s dep build src/main/helm

所以这是相当混乱的。我还缺少什么

4

1 回答 1

3

您需要将内置的图像传递skaffold buildskaffold deploy

skaffold build --file-output=images.json
skaffold deploy --build-artifacts=images.json

skaffold deploy不(重新)构建图像:它只是部署一组图像。所以deploy需要知道要部署的图像。

skaffold run将这些步骤组合成一个命令。

于 2021-07-16T20:08:40.923 回答