错误:无法找到名为“容器名称”的容器

错误:无法找到名为“容器名称”的容器

当我使用此命令在 GitHub Actions 中更新 kubernetes 集群中的容器时:

 - name: deploy to cluster
      uses: steebchen/[email protected]
      with: # defaults to latest kubectl binary version
        config: ${{ secrets.KUBE_CONFIG_DATA }}
        command: set image --record deployment/dolphin-post-service container-name=registry.cn-hangzhou.aliyuncs.com/reddwarf-pro/dolphin-post:${{ github.sha }} -n reddwarf-pro
    

但显示此错误:

Run steebchen/[email protected]
/usr/bin/docker run --name bec5f6492abb1d7d240cb997ecb72c649186a_87c72d --label 3bec5f --workdir /github/workspace --rm -e JAVA_HOME_11.0.12_x64 -e JAVA_HOME -e JAVA_HOME_11_0_12_X64 -e INPUT_CONFIG -e INPUT_COMMAND -e INPUT_VERSION -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/retire/retire":"/github/workspace" 3bec5f:6492abb1d7d240cb997ecb72c649186a  "latest" "***" "set image --record deployment/dolphin-post-service container-name=***/reddwarf-pro/dolphin-post:db9f88cf905016159a2fb0f1ba4d54246f671116 -n reddwarf-pro"
using [email protected]
Flag --record has been deprecated, --record will be removed in the future
error: unable to find container named "container-name"
deployment.apps/dolphin-post-service image updated

我应该怎么做才能解决这个问题?

答案1

我终于明白容器名称不是kubernetes控制(kubectl)的关键,它是kubernetes中的容器名称,我这样做并修复它:

- name: deploy to cluster
  uses: steebchen/[email protected]
  with: # defaults to latest kubectl binary version
    config: ${{ secrets.KUBE_CONFIG_DATA }}
    command: set image --record deployment/dolphin-post-service dolphin-post-service=registry.cn-hangzhou.aliyuncs.com/reddwarf-pro/dolphin-post:${{ github.sha }} -n reddwarf-pro

替换container-namedolphin-post-service.

相关内容