관리 메뉴

피터의 개발이야기

[kubernetes] skaffold 로컬 환경 세팅 트러블슈팅 본문

Kubernetes/kube 개발환경

[kubernetes] skaffold 로컬 환경 세팅 트러블슈팅

기록하는 백앤드개발자 2022. 9. 25. 12:21
반응형

[kubernetes] 개발환경 목차

ㅁ 개요

 ㅇ skaffold와 Intellij를 연동하여 쿠버네티스 로컬 개발환경 세팅하면서 발생한 문제를 해결하는 과정 정리

 ㅇ 이전 글:  [kubernets] Kubernetes 로컬 개발환경 skaffold, Intellij

 

ㅁ 목록

 ㅇ Gradle 오류발생

 ㅇ skaffold build 중 Git init 오류

 ㅇ  skaffold run 시 image pull 에러

 

ㅁ 트러블슈팅1, Gradle 오류발생

 ㅇ Gradle 7.5가 로컬에서 실행되면서 문제가 발생하였다.

 ㅇ 현재 개발환경과 최근 Gradle의 버젼이 맞이 않아서 발생.

 

 ㅇ Gradle 6.8.3으로 수정하여 문제 해결함.

 

 

 

 트러블슈팅2, skaffold build 중 Git init 오류

$ skaffold build
Generating tags...
 - skaffold -> skaffold:latest
Some taggers failed. Rerun with -vdebug for errors.
Checking cache...
 - skaffold: Error checking cache.
getting hash for artifact "skaffold": getting dependencies for "skaffold": could not fetch dependencies for workspace .: initial Jib dependency refresh failed: failed to get Jib dependencies: running [/Users/peterseo/study/aws/skaffold/gradlew _skaffoldFailIfJibOutOfDate -Djib.requiredVersion=1.4.0 :_jibSkaffoldFilesV2 -q --console=plain]
 - stdout: ""
 - stderr: "\nFAILURE: Build failed with an exception.\n\n* What went wrong:\nTask '_skaffoldFailIfJibOutOfDate' not found in root project 'skaffold'.\n\n* Try:\nRun gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.\n\n* Get more help at https://help.gradle.org\n\nBUILD FAILED in 605ms\n"
 - cause: exit status 1

 ㅇ 에러가 발생하였다. 내용상 정확한 원인을 분석 할 수 없어서 -vdebug 를 사용해보았다.

 

 

$ skaffold build -vdebug
DEBU[0000] skaffold API not starting as it's not requested  subtask=-1 task=DevLoop
INFO[0000] Skaffold &{Version:v1.39.2 ConfigVersion:skaffold/v2beta29 GitVersion: GitCommit:7ed1d722b53b55ac1c909f00d00a05b47d0964dd BuildDate:2022-08-16T21:03:40Z GoVersion:go1.17.13 Compiler:gc Platform:darwin/amd64 User:}  subtask=-1 task=DevLoop
INFO[0000] Loaded Skaffold defaults from "/Users/peterseo/.skaffold/config"  subtask=-1 task=DevLoop
DEBU[0000] config version out of date: upgrading to latest "skaffold/v2beta29"  subtask=-1 task=DevLoop
DEBU[0000] parsed 1 configs from configuration file /Users/peterseo/study/aws/skaffold/skaffold.yaml  subtask=-1 task=DevLoop
INFO[0000] map entry found when executing locate for &{skaffold . <nil> {<nil> <nil> <nil> 0xc0009ec5a0 <nil> <nil> <nil>} [] {[] []} []} of type *latest.Artifact and pointer: 824648901184  subtask=-1 task=DevLoop
INFO[0000] Using kubectl context: minikube               subtask=-1 task=DevLoop
DEBU[0000] getting client config for kubeContext: `minikube`  subtask=-1 task=DevLoop
DEBU[0000] Running command: [minikube version --output=json]  subtask=-1 task=DevLoop
DEBU[0000] Command output: [{"commit":"362d5fdc0a3dbee389b3d3f1034e8023e72bd3a7","minikubeVersion":"v1.25.2"}
]  subtask=-1 task=DevLoop
DEBU[0000] Running command: [/usr/local/bin/minikube docker-env --shell none -p minikube --user=skaffold]  subtask=-1 task=DevLoop
DEBU[0000] Command output: [DOCKER_CERT_PATH=/Users/peterseo/.minikube/certs
MINIKUBE_ACTIVE_DOCKERD=minikube
DOCKER_TLS_VERIFY=1
DOCKER_HOST=tcp://192.168.64.3:2376
]  subtask=-1 task=DevLoop
DEBU[0000] setting Docker user agent to skaffold-v1.39.2  subtask=-1 task=DevLoop
INFO[0000] Using minikube docker daemon at tcp://192.168.64.3:2376  subtask=-1 task=DevLoop
DEBU[0000] CLI platforms provided: ""                    subtask=-1 task=DevLoop
DEBU[0000] platforms detected from active kubernetes cluster nodes: ""  subtask=-1 task=DevLoop
DEBU[0000] platforms selected for artifact "skaffold": ""  subtask=-1 task=DevLoop
DEBU[0000] Using builder: local                          subtask=-1 task=DevLoop
DEBU[0000] push value not present in NewBuilder, defaulting to false because cluster.PushImages is false  subtask=-1 task=DevLoop
INFO[0000] build concurrency first set to 1 parsed from *local.Builder[0]  subtask=-1 task=DevLoop
INFO[0000] final build concurrency value is 1            subtask=-1 task=DevLoop
Generating tags...
 - skaffold -> DEBU[0000] Running command: [git describe --tags --always]  subtask=-1 task=Build
DEBU[0000] generating tag: unable to find git commit: running [git describe --tags --always]
 - stdout: ""
 - stderr: "fatal: (현재 폴더 또는 상위 폴더 중 일부가) 깃 저장소가 아닙니다: .git\n"
 - cause: exit status 128  subtask=skaffold task=Build
DEBU[0000] Using a fall-back tagger                      subtask=skaffold task=Build
skaffold:latest
Some taggers failed. Rerun with -vdebug for errors.
INFO[0000] Tags generated in 8.703549ms                  subtask=-1 task=Build
Checking cache...
DEBU[0000] Running command: [java -version]              subtask=-1 task=Build
DEBU[0000] Using wrapper for gradlew: gradle             subtask=-1 task=Build
DEBU[0000] Running command: [/Users/peterseo/study/aws/skaffold/gradlew _skaffoldFailIfJibOutOfDate -Djib.requiredVersion=1.4.0 :_jibSkaffoldFilesV2 -q --console=plain]  subtask=-1 task=Build
 - skaffold: Error checking cache.
DEBU[0001] Running command: [tput colors]                subtask=-1 task=DevLoop
DEBU[0001] Command output: [256
]                        subtask=-1 task=DevLoop
getting hash for artifact "skaffold": getting dependencies for "skaffold": could not fetch dependencies for workspace .: initial Jib dependency refresh failed: failed to get Jib dependencies: running [/Users/peterseo/study/aws/skaffold/gradlew _skaffoldFailIfJibOutOfDate -Djib.requiredVersion=1.4.0 :_jibSkaffoldFilesV2 -q --console=plain]
 - stdout: ""
 - stderr: "\nFAILURE: Build failed with an exception.\n\n* What went wrong:\nTask '_skaffoldFailIfJibOutOfDate' not found in root project 'skaffold'.\n\n* Try:\nRun gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.\n\n* Get more help at https://help.gradle.org\n\nBUILD FAILED in 602ms\n"
 - cause: exit status 1
DEBU[0001] exporting metrics                             subtask=-1 task=DevLoop

 ㅇ '(현재 폴더 또는 상위 폴더 중 일부가) 깃 저장소가 아닙니다'라는 문구를 확인하여 git init을 실행하였다.

 

 

 ㅇ git을 초기화 하고 모든 소스를 커밋한 상태로 만들어서 해결함.

 

 

ㅁ skaffold run 시 image pull 에러

 ㅇ skaffold build까지 성공하고 pod를 실행하는 과정에서 docker image를 가져올 수 없다는 에러가 발생함.

 

 ㅇ docker hub에 로그인을 하지 않은 상태여서 로그인 후 정상 작동 확인함.

 

 

ㅁ 함께 보면 좋은 사이트

 

GitHub - GoogleContainerTools/jib: 🏗 Build container images for your Java applications.

🏗 Build container images for your Java applications. - GitHub - GoogleContainerTools/jib: 🏗 Build container images for your Java applications.

github.com

 ㅇ jib gradle quick start

 

 

 

Image Repository Handling

Often, a Kubernetes manifest (or skaffold.yaml) makes references to images that push to registries that we might not have access to. Modifying these individual image names manually is tedious, so Skaffold supports automatically prefixing these image names

skaffold.dev

 ㅇ skaffold 이미지 저장소 처리방법

 

 

반응형
Comments