일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- kotlin coroutine
- kotlin spring
- Java
- CKA
- MySQL
- IntelliJ
- Linux
- 정보처리기사실기 기출문제
- APM
- mysql 튜닝
- Elasticsearch
- Kubernetes
- 기록으로 실력을 쌓자
- 공부
- Spring
- 정보처리기사 실기
- Pinpoint
- 코틀린 코루틴의 정석
- kotlin
- PETERICA
- kotlin querydsl
- 티스토리챌린지
- minikube
- aws
- AI
- 정보처리기사 실기 기출문제
- 오블완
- CloudWatch
- AWS EKS
- CKA 기출문제
- Today
- Total
피터의 개발이야기
[kubernets] Kubernetes 로컬 개발환경 skaffold, Intellij 본문
[kubernets] Kubernetes 로컬 개발환경 skaffold, Intellij
기록하는 백앤드개발자 2022. 9. 24. 21:05
[kubernetes] 개발환경 목차
ㅁ 개요
ㅇ [kubernets] skaffold란, Kubernetes 로컬 개발환경에서 skaffold를 알아보았습니다.
ㅇ skaffold와 Intellij를 연동하여 쿠버네티스 로컬 개발환경 세팅하는 과정을 정리하였습니다.
ㅇ 궁극적으로 skaffold를 통해 쿠버네티스 환경에서 Debug모드로 프로세스의 흐름을 분석하는 것이다.
ㅇ skaffold를 구성을 공부하는 과정에서 트러블 슈팅은 여기에 정리되어 있다.
ㅁ Spring 샘플 프로젝트 생성
ㅇ Spring 샘플 프로젝트를 생성하여 해당 프로젝트를 Intellij로 실행하였다.
ㅇ 참고로 위 이미지는 트러블 슈팅으로 인해 예전에 만든 프로젝트 이름임.
ㅁ skaffold.yaml 생성
ㅇ skaffold.yaml를 생성하였다.
ㅇ jib 설정 및 k8s 파일 경로 추가하였다.
ㅁ jib 설정
ㅇ Jib는 Java 애플리케이션용 Docker 이미지를 빌드하기 위한 Gradle 플러그인입니다.
ㅇ build.gradle 파일 > plugins > jib 3.3.0을 추가하였다.
ㅁ k8s deployment, service 추가
ㅇ spring-boot-example이라는 deplyment 생성
ㅇ port는 8080임
ㅇ 접속을 위한 spring-boot-example 서비스 생성.
ㅁ Skaffold build
$ skaffold build
Generating tags...
- skaffold-spring-boot -> skaffold-spring-boot:6e32d9e-dirty
Checking cache...
- skaffold-spring-boot: Not found. Building
Starting build...
Found [minikube] context, using local docker daemon.
Building [skaffold-spring-boot]...
> Task :_skaffoldFailIfJibOutOfDate
> Task :compileJava
> Task :processResources UP-TO-DATE
> Task :classes
> Task :jibDockerBuild
Containerizing application to Docker daemon as skaffold-spring-boot:6e32d9e-dirty...
Base image 'eclipse-temurin:11-jre' does not use a specific image digest - build may not be reproducible
Getting manifest for base image eclipse-temurin:11-jre...
Building dependencies layer...
Building resources layer...
Building classes layer...
Building jvm arg files layer...
The base image requires auth. Trying again for eclipse-temurin:11-jre...
The credential helper (docker-credential-desktop) has nothing for server URL: registry-1.docker.io
Got output:
credentials not found in native keychain
The credential helper (docker-credential-desktop) has nothing for server URL: registry.hub.docker.com
Got output:
credentials not found in native keychain
Using credentials from Docker config (/Users/peterseo/.docker/config.json) for eclipse-temurin:11-jre
Using base image with digest: sha256:3ca22aa74f428cd034085bcf6823733f1730dd7ddd813ae0fa986da8a336eeb0
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.peterica.skaffoldspringboot.SkaffoldSpringBootApplication]
Loading to Docker daemon...
Built image to Docker daemon as skaffold-spring-boot:6e32d9e-dirty
BUILD SUCCESSFUL in 6s
4 actionable tasks: 3 executed, 1 up-to-date
Build [skaffold-spring-boot] succeeded
ㅁ Skaffold dev
$ skaffold dev
Listing files to watch...
- skaffold-spring-boot
Generating tags...
- skaffold-spring-boot -> skaffold-spring-boot:6e32d9e-dirty
Checking cache...
- skaffold-spring-boot: Not found. Building
Starting build...
Found [minikube] context, using local docker daemon.
Building [skaffold-spring-boot]...
Target platforms: [linux/amd64]
> Task :_skaffoldFailIfJibOutOfDate
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :jibDockerBuild
Containerizing application to Docker daemon as skaffold-spring-boot:6e32d9e-dirty...
Base image 'eclipse-temurin:11-jre' does not use a specific image digest - build may not be reproducible
Getting manifest for base image eclipse-temurin:11-jre...
Building dependencies layer...
Building resources layer...
Building classes layer...
Building jvm arg files layer...
The base image requires auth. Trying again for eclipse-temurin:11-jre...
The credential helper (docker-credential-desktop) has nothing for server URL: registry-1.docker.io
Got output:
credentials not found in native keychain
The credential helper (docker-credential-desktop) has nothing for server URL: registry.hub.docker.com
Got output:
credentials not found in native keychain
Using credentials from Docker config (/Users/peterseo/.docker/config.json) for eclipse-temurin:11-jre
Using base image with digest: sha256:3ca22aa74f428cd034085bcf6823733f1730dd7ddd813ae0fa986da8a336eeb0
Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.peterica.skaffoldspringboot.SkaffoldSpringBootApplication]
Loading to Docker daemon...
Built image to Docker daemon as skaffold-spring-boot:6e32d9e-dirty
BUILD SUCCESSFUL in 6s
4 actionable tasks: 2 executed, 2 up-to-date
Build [skaffold-spring-boot] succeeded
Tags used in deployment:
- skaffold-spring-boot -> skaffold-spring-boot:4de8c3487507f2a7bf25b6a6750ae17c250c111d7bfd17fd9d3330f8076aabad
Starting deploy...
- deployment.apps/spring-boot-example created
- service/spring-boot-example created
Waiting for deployments to stabilize...
- deployment/spring-boot-example is ready.
Deployments stabilized in 3.166 seconds
Press Ctrl+C to exit
Watching for changes...
[spring-boot-example]
[spring-boot-example] . ____ _ __ _ _
[spring-boot-example] /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
[spring-boot-example] ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
[spring-boot-example] \\/ ___)| |_)| | | | | || (_| | ) ) ) )
[spring-boot-example] ' |____| .__|_| |_|_| |_\__, | / / / /
[spring-boot-example] =========|_|==============|___/=/_/_/_/
[spring-boot-example] :: Spring Boot :: (v2.6.12)
[spring-boot-example]
[spring-boot-example] 2022-09-25 03:15:59.592 INFO 1 --- [ main] c.p.s.SkaffoldSpringBootApplication : Starting SkaffoldSpringBootApplication using Java 11.0.16.1 on spring-boot-example-67d894d76-65ftz with PID 1 (/app/classes started by root in /)
[spring-boot-example] 2022-09-25 03:15:59.596 INFO 1 --- [ main] c.p.s.SkaffoldSpringBootApplication : No active profile set, falling back to 1 default profile: "default"
[spring-boot-example] 2022-09-25 03:16:01.021 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
[spring-boot-example] 2022-09-25 03:16:01.042 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
[spring-boot-example] 2022-09-25 03:16:01.043 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
[spring-boot-example] 2022-09-25 03:16:01.190 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
[spring-boot-example] 2022-09-25 03:16:01.190 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1494 ms
[spring-boot-example] 2022-09-25 03:16:02.103 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
[spring-boot-example] 2022-09-25 03:16:02.125 INFO 1 --- [ main] c.p.s.SkaffoldSpringBootApplication : Started SkaffoldSpringBootApplication in 3.322 seconds (JVM running for 3.936)
[spring-boot-example] 2022-09-25 03:16:55.429 INFO 1 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
[spring-boot-example] 2022-09-25 03:16:55.430 INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
[spring-boot-example] 2022-09-25 03:16:55.434 INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 3 ms
ㅇ dev로 하는 경우 바로 Spring 로그를 확인할 수 있다.
ㅇ kubectl로 pod의 정상 로딩을 확인하였다.
ㅁ 접속 확인
ㅇ minikube 환경이라 service list 확인이 필요하다.
ㅇ 웹을 통해 정상 로딩 확인하였다.
ㅁ 함께 보면 좋은 사이트
ㅇ jib gradle quick start
ㅇ skaffold-spring-boot-example
'Kubernetes > kube 개발환경' 카테고리의 다른 글
[kubernetes] kubectl convert 설치 및 사용법 (0) | 2022.10.02 |
---|---|
[kubernetes] skaffold 로컬 환경 세팅 트러블슈팅 (0) | 2022.09.25 |
[kubernets] skaffold란, Kubernetes 로컬 개발환경 (0) | 2022.09.21 |
[kubernetes] Datree 사용법, 자동완성기능 (2) | 2022.09.21 |
[kubernetes] Datree란, Yaml validation, kubernetes schama validation (0) | 2022.08.02 |