Kubernetes
錯誤:找不到名為“container-name”的容器
當我在 GitHub Actions 中使用此命令更新 kubernetes 集群中的容器時:
- name: deploy to cluster uses: steebchen/kubectl@v2.0.0 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/kubectl@v2.0.0 /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 kubectl@v1.22.0 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
我應該怎麼做才能解決這個問題?
我終於明白container-name不是kubernetes control(kubectl)的key,它是kubernetes中的容器名,我這樣做並修復它:
- name: deploy to cluster uses: steebchen/kubectl@v2.0.0 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-name
todolphin-post-service
。