项目作者: ameizi

项目描述 :
Spring Boot整合Kubernetes
高级语言: Java
项目地址: git://github.com/ameizi/k8s-example.git
创建时间: 2020-05-07T08:53:40Z
项目社区:https://github.com/ameizi/k8s-example

开源协议:

下载


k8s-example

使用spring-boot-maven-plugin构建

升级spring boot 版本为2.3.x,执行spring-boot:build-image命令即可。

  1. $ mvn spring-boot:build-image
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] -----------------------< net.ameizi:k8s-example >-----------------------
  5. [INFO] Building k8s-example 1.0.0
  6. [INFO] --------------------------------[ jar ]---------------------------------
  7. [INFO]
  8. [INFO] >>> spring-boot-maven-plugin:2.3.0.BUILD-SNAPSHOT:build-image (default-cli) > package @ k8s-example >>>
  9. [INFO]
  10. [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ k8s-example ---
  11. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  12. [INFO] Copying 1 resource
  13. [INFO] Copying 0 resource
  14. [INFO]
  15. [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ k8s-example ---
  16. [INFO] Changes detected - recompiling the module!
  17. [INFO] Compiling 1 source file to /Users/amz/develop/workspace/k8s-example/target/classes
  18. [INFO]
  19. [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ k8s-example ---
  20. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  21. [INFO] skip non existing resourceDirectory /Users/amz/develop/workspace/k8s-example/src/test/resources
  22. [INFO]
  23. [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ k8s-example ---
  24. [INFO] Changes detected - recompiling the module!
  25. [INFO] Compiling 1 source file to /Users/amz/develop/workspace/k8s-example/target/test-classes
  26. [INFO]
  27. [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ k8s-example ---
  28. Downloading from spring-milestones: https://repo.spring.io/milestone/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.pom
  29. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.pom
  30. Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.pom
  31. Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.pom (0 B at 0 B/s)
  32. Downloading from spring-milestones: https://repo.spring.io/milestone/org/apache/maven/surefire/surefire-providers/2.22.2/surefire-providers-2.22.2.pom
  33. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/apache/maven/surefire/surefire-providers/2.22.2/surefire-providers-2.22.2.pom
  34. Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-providers/2.22.2/surefire-providers-2.22.2.pom
  35. Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-providers/2.22.2/surefire-providers-2.22.2.pom (0 B at 0 B/s)
  36. Downloading from spring-milestones: https://repo.spring.io/milestone/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.pom
  37. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.pom
  38. Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.pom
  39. Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.pom (0 B at 0 B/s)
  40. Downloading from spring-milestones: https://repo.spring.io/milestone/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.pom
  41. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.pom
  42. Downloading from central: https://repo.maven.apache.org/maven2/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.pom
  43. Downloaded from central: https://repo.maven.apache.org/maven2/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.pom (0 B at 0 B/s)
  44. Downloading from spring-milestones: https://repo.spring.io/milestone/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.pom
  45. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.pom
  46. Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.pom
  47. Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.pom (0 B at 0 B/s)
  48. Downloading from spring-milestones: https://repo.spring.io/milestone/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.pom
  49. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.pom
  50. Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.pom
  51. Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.pom (0 B at 0 B/s)
  52. Downloading from spring-milestones: https://repo.spring.io/milestone/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.pom
  53. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.pom
  54. Downloading from central: https://repo.maven.apache.org/maven2/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.pom
  55. Downloaded from central: https://repo.maven.apache.org/maven2/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.pom (0 B at 0 B/s)
  56. Downloading from spring-milestones: https://repo.spring.io/milestone/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar
  57. Downloading from spring-milestones: https://repo.spring.io/milestone/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.jar
  58. Downloading from spring-milestones: https://repo.spring.io/milestone/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.jar
  59. Downloading from spring-milestones: https://repo.spring.io/milestone/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.jar
  60. Downloading from spring-milestones: https://repo.spring.io/milestone/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.jar
  61. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar
  62. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.jar
  63. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.jar
  64. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.jar
  65. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.jar
  66. Downloading from central: https://repo.maven.apache.org/maven2/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar
  67. Downloaded from central: https://repo.maven.apache.org/maven2/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar (0 B at 0 B/s)
  68. Downloading from spring-milestones: https://repo.spring.io/milestone/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar
  69. Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.jar
  70. Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.jar
  71. Downloading from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.jar
  72. Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.jar
  73. Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.jar (0 B at 0 B/s)
  74. Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar
  75. Downloading from central: https://repo.maven.apache.org/maven2/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar
  76. Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.jar (0 B at 0 B/s)
  77. Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.jar (0 B at 0 B/s)
  78. Downloaded from central: https://repo.maven.apache.org/maven2/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar (0 B at 0 B/s)
  79. Downloaded from central: https://repo.maven.apache.org/maven2/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.jar (0 B at 0 B/s)
  80. [INFO]
  81. [INFO] -------------------------------------------------------
  82. [INFO] T E S T S
  83. [INFO] -------------------------------------------------------
  84. [INFO] Running net.ameizi.k8s.example.K8sExampleApplicationTests
  85. 14:26:46.188 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
  86. 14:26:46.206 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
  87. 14:26:46.250 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [net.ameizi.k8s.example.K8sExampleApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
  88. 14:26:46.267 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [net.ameizi.k8s.example.K8sExampleApplicationTests], using SpringBootContextLoader
  89. 14:26:46.277 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [net.ameizi.k8s.example.K8sExampleApplicationTests]: class path resource [net/ameizi/k8s/example/K8sExampleApplicationTests-context.xml] does not exist
  90. 14:26:46.278 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [net.ameizi.k8s.example.K8sExampleApplicationTests]: class path resource [net/ameizi/k8s/example/K8sExampleApplicationTestsContext.groovy] does not exist
  91. 14:26:46.278 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [net.ameizi.k8s.example.K8sExampleApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
  92. 14:26:46.279 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [net.ameizi.k8s.example.K8sExampleApplicationTests]: K8sExampleApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
  93. 14:26:46.354 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [net.ameizi.k8s.example.K8sExampleApplicationTests]
  94. 14:26:46.457 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/Users/amz/develop/workspace/k8s-example/target/classes/net/ameizi/k8s/example/K8sExampleApplication.class]
  95. 14:26:46.458 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration net.ameizi.k8s.example.K8sExampleApplication for test class net.ameizi.k8s.example.K8sExampleApplicationTests
  96. 14:26:46.580 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [net.ameizi.k8s.example.K8sExampleApplicationTests]: using defaults.
  97. 14:26:46.582 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
  98. 14:26:46.603 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
  99. 14:26:46.604 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
  100. 14:26:46.605 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@1da2cb77, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@48f278eb, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@2f217633, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@a530d0a, org.springframework.test.context.support.DirtiesContextTestExecutionListener@1a18644, org.springframework.test.context.event.EventPublishingTestExecutionListener@5acf93bb, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@7e7be63f, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@6cd28fa7, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@614ca7df, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@4738a206, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@66d3eec0]
  101. 14:26:46.609 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@741a8937 testClass = K8sExampleApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@306e95ec testClass = K8sExampleApplicationTests, locations = '{}', classes = '{class net.ameizi.k8s.example.K8sExampleApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@2ddc8ecb, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@33afa13b, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@5dd6264, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@7c0c77c7, org.springframework.boot.test.context.SpringBootTestArgs@1], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
  102. 14:26:46.654 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}
  103. . ____ _ __ _ _
  104. /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
  105. ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  106. \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  107. ' |____| .__|_| |_|_| |_\__, | / / / /
  108. =========|_|==============|___/=/_/_/_/
  109. :: Spring Boot :: (v2.3.0.BUILD-SNAPSHOT)
  110. 2020-05-07 14:26:47.064 INFO 44321 --- [ main] n.a.k.e.K8sExampleApplicationTests : Starting K8sExampleApplicationTests on swfeng.local with PID 44321 (started by amz in /Users/amz/develop/workspace/k8s-example)
  111. 2020-05-07 14:26:47.066 INFO 44321 --- [ main] n.a.k.e.K8sExampleApplicationTests : No active profile set, falling back to default profiles: default
  112. 2020-05-07 14:26:48.913 INFO 44321 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
  113. 2020-05-07 14:26:49.506 INFO 44321 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 13 endpoint(s) beneath base path '/actuator'
  114. 2020-05-07 14:26:49.595 INFO 44321 --- [ main] n.a.k.e.K8sExampleApplicationTests : Started K8sExampleApplicationTests in 2.92 seconds (JVM running for 4.057)
  115. [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.872 s - in net.ameizi.k8s.example.K8sExampleApplicationTests
  116. 2020-05-07 14:26:49.969 INFO 44321 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
  117. [INFO]
  118. [INFO] Results:
  119. [INFO]
  120. [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
  121. [INFO]
  122. [INFO]
  123. [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ k8s-example ---
  124. [INFO] Building jar: /Users/amz/develop/workspace/k8s-example/target/k8s-example-1.0.0.jar
  125. [INFO]
  126. [INFO] --- spring-boot-maven-plugin:2.3.0.BUILD-SNAPSHOT:repackage (repackage) @ k8s-example ---
  127. [INFO] Replacing main artifact with repackaged archive
  128. [INFO]
  129. [INFO] --- jib-maven-plugin:2.2.0:build (default) @ k8s-example ---
  130. [INFO]
  131. [INFO] Containerizing application to registry.hub.docker.com/aimeizi/k8s-example...
  132. [WARNING] Base image 'openjdk:8-jdk-alpine' does not use a specific image digest - build may not be reproducible
  133. [INFO] Using credentials from Docker config (/Users/amz/.docker/config.json) for registry.hub.docker.com/aimeizi/k8s-example
  134. [INFO] The base image requires auth. Trying again for openjdk:8-jdk-alpine...
  135. [WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: registry-1.docker.ioNG]
  136. Got output:
  137. credentials not found in native keychain
  138. [INFO] Using credentials from Docker config (/Users/amz/.docker/config.json) for openjdk:8-jdk-alpine
  139. [INFO] Using base image with digest: sha256:44b3cea369c947527e266275cee85c71a81f20fc5076f6ebb5a13f19015dce71
  140. [INFO]
  141. [INFO] Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, net.ameizi.k8s.example.K8sExampleApplication]
  142. [INFO]
  143. [INFO] Built and pushed image as registry.hub.docker.com/aimeizi/k8s-example
  144. [INFO] Executing tasks:
  145. [INFO] [=========================== ] 88.9% complete
  146. [INFO] > launching layer pushers
  147. [INFO]
  148. [INFO]
  149. [INFO] <<< spring-boot-maven-plugin:2.3.0.BUILD-SNAPSHOT:build-image (default-cli) < package @ k8s-example <<<
  150. [INFO]
  151. [INFO]
  152. [INFO] --- spring-boot-maven-plugin:2.3.0.BUILD-SNAPSHOT:build-image (default-cli) @ k8s-example ---
  153. [INFO] Building image 'docker.io/library/k8s-example:1.0.0'
  154. [INFO]
  155. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 0%
  156. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 2%
  157. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 2%
  158. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 2%
  159. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 3%
  160. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 3%
  161. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 4%
  162. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 4%
  163. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 6%
  164. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 7%
  165. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 7%
  166. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 8%
  167. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 8%
  168. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 10%
  169. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 11%
  170. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 11%
  171. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 12%
  172. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 12%
  173. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 12%
  174. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 13%
  175. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 13%
  176. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 13%
  177. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 14%
  178. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 14%
  179. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 14%
  180. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 14%
  181. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 14%
  182. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 14%
  183. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 14%
  184. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 15%
  185. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 16%
  186. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 20%
  187. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 20%
  188. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 21%
  189. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 21%
  190. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 22%
  191. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 22%
  192. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 23%
  193. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 23%
  194. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 23%
  195. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 24%
  196. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 24%
  197. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 24%
  198. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 25%
  199. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 25%
  200. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 25%
  201. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 26%
  202. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 26%
  203. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 27%
  204. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 27%
  205. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 27%
  206. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 28%
  207. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 28%
  208. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 29%
  209. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 30%
  210. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 30%
  211. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 31%
  212. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 31%
  213. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 31%
  214. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 32%
  215. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 32%
  216. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 32%
  217. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 32%
  218. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 32%
  219. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 33%
  220. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 33%
  221. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 33%
  222. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 33%
  223. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 33%
  224. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 34%
  225. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 34%
  226. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 34%
  227. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 34%
  228. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 34%
  229. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 35%
  230. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 35%
  231. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 35%
  232. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 36%
  233. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 36%
  234. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 37%
  235. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 37%
  236. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 37%
  237. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 38%
  238. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 39%
  239. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 48%
  240. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 52%
  241. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 54%
  242. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 59%
  243. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 63%
  244. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 65%
  245. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 67%
  246. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 69%
  247. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 69%
  248. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 69%
  249. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 70%
  250. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 72%
  251. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 72%
  252. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 73%
  253. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 73%
  254. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 73%
  255. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 74%
  256. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 74%
  257. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 74%
  258. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 75%
  259. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 77%
  260. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 79%
  261. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 79%
  262. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 80%
  263. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 80%
  264. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 81%
  265. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 81%
  266. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 81%
  267. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 81%
  268. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 83%
  269. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 87%
  270. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 89%
  271. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 89%
  272. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 90%
  273. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 90%
  274. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 90%
  275. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 90%
  276. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 91%
  277. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 91%
  278. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 91%
  279. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 91%
  280. [INFO] > Pulling builder image 'gcr.io/paketo-buildpacks/builder:base-platform-api-0.3' 100%
  281. [INFO] > Pulled builder image 'gcr.io/paketo-buildpacks/builder@sha256:1bb775a178ed4c54246ab71f323d2a5af0e4b70c83b0dc84f974694b0221d636'
  282. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 3%
  283. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 21%
  284. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 32%
  285. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 35%
  286. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 37%
  287. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 37%
  288. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 38%
  289. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 38%
  290. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 38%
  291. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 39%
  292. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 39%
  293. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 39%
  294. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 40%
  295. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 40%
  296. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 40%
  297. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 40%
  298. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 40%
  299. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 41%
  300. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 41%
  301. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 41%
  302. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 42%
  303. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 42%
  304. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 46%
  305. [INFO] > Pulling run image 'gcr.io/paketo-buildpacks/run:base-cnb' 100%
  306. [INFO] > Pulled run image 'gcr.io/paketo-buildpacks/run@sha256:d70bf0fe11d84277997c4a7da94b2867a90d6c0f55add4e19b7c565d5087206f'
  307. [INFO] > Executing lifecycle version v0.7.4
  308. [INFO] > Using build cache volume 'pack-cache-55330c9f9824.build'
  309. [INFO]
  310. [INFO] > Running detector
  311. [INFO] [detector] 5 of 15 buildpacks participating
  312. [INFO] [detector] paketo-buildpacks/bellsoft-liberica 2.5.0
  313. [INFO] [detector] paketo-buildpacks/executable-jar 1.2.2
  314. [INFO] [detector] paketo-buildpacks/apache-tomcat 1.1.2
  315. [INFO] [detector] paketo-buildpacks/dist-zip 1.2.2
  316. [INFO] [detector] paketo-buildpacks/spring-boot 1.5.2
  317. [INFO]
  318. [INFO] > Running analyzer
  319. [INFO] [analyzer] Previous image with name "docker.io/library/k8s-example:1.0.0" not found
  320. [INFO]
  321. [INFO] > Running restorer
  322. [INFO]
  323. [INFO] > Running builder
  324. [INFO] [builder]
  325. [INFO] [builder] Paketo BellSoft Liberica Buildpack 2.5.0
  326. [INFO] [builder] Set $BP_JAVA_VERSION to configure the Java version. Default 11.*.
  327. [INFO] [builder] Set $BPL_HEAD_ROOM to configure the headroom in memory calculation. Default 0.
  328. [INFO] [builder] Set $BPL_LOADED_CLASS_COUNT to configure the number of loaded classes in memory calculation. Default 35% of classes.
  329. [INFO] [builder] Set $BPL_THREAD_COUNT to configure the number of threads in memory calculation. Default 250.
  330. [INFO] [builder] BellSoft Liberica JRE 8.0.252: Contributing to layer
  331. [INFO] [builder] Downloading from https://github.com/bell-sw/Liberica/releases/download/8u252+9/bellsoft-jre8u252+9-linux-amd64.tar.gz
  332. [INFO] [builder] Verifying checksum
  333. [INFO] [builder] Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jre
  334. [INFO] [builder] Writing env.launch/JAVA_HOME.override
  335. [INFO] [builder] Writing env.launch/MALLOC_ARENA_MAX.override
  336. [INFO] [builder] Writing profile.d/active-processor-count.sh
  337. [INFO] [builder] Memory Calculator 4.0.0: Contributing to layer
  338. [INFO] [builder] Downloading from https://github.com/cloudfoundry/java-buildpack-memory-calculator/releases/download/v4.0.0/memory-calculator-4.0.0.tgz
  339. [INFO] [builder] Verifying checksum
  340. [INFO] [builder] Expanding to /layers/paketo-buildpacks_bellsoft-liberica/memory-calculator
  341. [INFO] [builder] Writing profile.d/memory-calculator.sh
  342. [INFO] [builder] Class Counter: Contributing to layer
  343. [INFO] [builder] Copying to /layers/paketo-buildpacks_bellsoft-liberica/class-counter
  344. [INFO] [builder] JVMKill Agent 1.16.0: Contributing to layer
  345. [INFO] [builder] Downloading from https://github.com/cloudfoundry/jvmkill/releases/download/v1.16.0.RELEASE/jvmkill-1.16.0-RELEASE.so
  346. [INFO] [builder] Verifying checksum
  347. [INFO] [builder] Copying to /layers/paketo-buildpacks_bellsoft-liberica/jvmkill
  348. [INFO] [builder] Writing env.launch/JAVA_OPTS.append
  349. [INFO] [builder] Link-Local DNS: Contributing to layer
  350. [INFO] [builder] Copying to /layers/paketo-buildpacks_bellsoft-liberica/link-local-dns
  351. [INFO] [builder] Writing profile.d/link-local-dns.sh
  352. [INFO] [builder] Java Security Properties: Contributing to layer
  353. [INFO] [builder] Writing env.launch/JAVA_OPTS.append
  354. [INFO] [builder] Writing env.launch/JAVA_SECURITY_PROPERTIES.override
  355. [INFO] [builder] Security Providers Configurer: Contributing to layer
  356. [INFO] [builder] Copying to /layers/paketo-buildpacks_bellsoft-liberica/security-providers-configurer
  357. [INFO] [builder] Writing profile.d/security-providers-classpath.sh
  358. [INFO] [builder] Writing profile.d/security-providers-configurer.sh
  359. [INFO] [builder] OpenSSL Security Provider 1.0.2: Contributing to layer
  360. [INFO] [builder] Downloading from https://jitpack.io/com/github/paketo-buildpacks/openssl-security-provider/1.0.2/openssl-security-provider-1.0.2.jar
  361. [INFO] [builder] Verifying checksum
  362. [INFO] [builder] Copying to /layers/paketo-buildpacks_bellsoft-liberica/openssl-security-provider
  363. [INFO] [builder] Writing env.launch/SECURITY_PROVIDERS.append
  364. [INFO] [builder] Writing env.launch/SECURITY_PROVIDERS_CLASSPATH
  365. [INFO] [builder] Writing profile.d/openssl-security-provider.sh
  366. [INFO] [builder]
  367. [INFO] [builder] Paketo Executable JAR Buildpack 1.2.2
  368. [INFO] [builder] Writing env/CLASSPATH
  369. [INFO] [builder] Process types:
  370. [INFO] [builder] executable-jar: java -cp "${CLASSPATH}" ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher
  371. [INFO] [builder] task: java -cp "${CLASSPATH}" ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher
  372. [INFO] [builder] web: java -cp "${CLASSPATH}" ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher
  373. [INFO] [builder]
  374. [INFO] [builder] Paketo Spring Boot Buildpack 1.5.2
  375. [INFO] [builder] Image labels:
  376. [INFO] [builder] org.opencontainers.image.title
  377. [INFO] [builder] org.opencontainers.image.version
  378. [INFO] [builder] org.springframework.boot.spring-configuration-metadata.json
  379. [INFO] [builder] org.springframework.boot.version
  380. [INFO]
  381. [INFO] > Running exporter
  382. [INFO] [exporter] Adding layer 'launcher'
  383. [INFO] [exporter] Adding layer 'paketo-buildpacks/bellsoft-liberica:class-counter'
  384. [INFO] [exporter] Adding layer 'paketo-buildpacks/bellsoft-liberica:java-security-properties'
  385. [INFO] [exporter] Adding layer 'paketo-buildpacks/bellsoft-liberica:jre'
  386. [INFO] [exporter] Adding layer 'paketo-buildpacks/bellsoft-liberica:jvmkill'
  387. [INFO] [exporter] Adding layer 'paketo-buildpacks/bellsoft-liberica:link-local-dns'
  388. [INFO] [exporter] Adding layer 'paketo-buildpacks/bellsoft-liberica:memory-calculator'
  389. [INFO] [exporter] Adding layer 'paketo-buildpacks/bellsoft-liberica:openssl-security-provider'
  390. [INFO] [exporter] Adding layer 'paketo-buildpacks/bellsoft-liberica:security-providers-configurer'
  391. [INFO] [exporter] Adding layer 'paketo-buildpacks/executable-jar:class-path'
  392. [INFO] [exporter] Adding 1/1 app layer(s)
  393. [INFO] [exporter] Adding layer 'config'
  394. [INFO] [exporter] *** Images (39ca89c37d5b):
  395. [INFO] [exporter] docker.io/library/k8s-example:1.0.0
  396. [INFO] [exporter] Adding cache layer 'paketo-buildpacks/executable-jar:class-path'
  397. [INFO]
  398. [INFO] Successfully built image 'docker.io/library/k8s-example:1.0.0'
  399. [INFO]
  400. [INFO] ------------------------------------------------------------------------
  401. [INFO] BUILD SUCCESS
  402. [INFO] ------------------------------------------------------------------------
  403. [INFO] Total time: 08:13 min
  404. [INFO] Finished at: 2020-05-07T14:34:48+08:00
  405. [INFO] ------------------------------------------------------------------------

根据日志输出发现构建好的镜像默认为docker.io/library/k8s-example:1.0.0。当然这个可以配置修改

  1. <plugin>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-maven-plugin</artifactId>
  4. <configuration>
  5. <image>
  6. <name>k8s-example:latest</name>
  7. </image>
  8. </configuration>
  9. </plugin>

使用jib-maven-plugin插件构建 docker 镜像

  1. <plugin>
  2. <groupId>com.google.cloud.tools</groupId>
  3. <artifactId>jib-maven-plugin</artifactId>
  4. <version>2.2.0</version>
  5. <executions>
  6. <execution>
  7. <phase>package</phase>
  8. <goals>
  9. <goal>build</goal>
  10. </goals>
  11. </execution>
  12. </executions>
  13. <configuration>
  14. <from>
  15. <image>openjdk:8-jdk-alpine</image>
  16. </from>
  17. <to>
  18. <!-- 坑!!!这里切记一定要设置 docker registry的完整地址,否则会被坑死,构建的时候会报授权错误,原因在于执行 mvn package 命令后会打包构建镜像并进行推送,因此要设置镜像仓库的地址,并且记得在命令行进行镜像仓库登录(docker login) -->
  19. <!-- 此处构建不依赖docker daemon进程。说人话就是不需要启动docker服务 -->
  20. <image>registry.hub.docker.com/aimeizi/k8s-example:latest</image>
  21. </to>
  22. <container>
  23. <mainClass>net.ameizi.k8s.example.K8sExampleApplication</mainClass>
  24. <ports>
  25. <port>8080</port>
  26. </ports>
  27. </container>
  28. </configuration>
  29. </plugin>

执行构建

asciicast

Kubernetes

导出 Deployment

  1. $ mkdir k8s
  2. $ kubectl create deployment k8s-example --image registry.hub.docker.com/aimeizi/k8s-example:latest -o yaml --dry-run > k8s/deployment.yaml

生成的deployment.yaml如下所示:

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. creationTimestamp: null
  5. labels:
  6. app: k8s-example
  7. name: k8s-example
  8. spec:
  9. replicas: 1
  10. selector:
  11. matchLabels:
  12. app: k8s-example
  13. strategy: {}
  14. template:
  15. metadata:
  16. creationTimestamp: null
  17. labels:
  18. app: k8s-example
  19. spec:
  20. containers:
  21. - image: registry.hub.docker.com/aimeizi/k8s-example:latest
  22. name: k8s-example
  23. resources: {}
  24. status: {}

导出 Service

  • ClusterIP方式
  1. $ kubectl create service clusterip k8s-example --tcp 80:8080 -o yaml --dry-run > k8s/service.yaml

其中80:8080,80为宿主机端口,8080为容器内应用端口

生成的service.yaml如下所示:

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. creationTimestamp: null
  5. labels:
  6. app: k8s-example
  7. name: k8s-example
  8. spec:
  9. ports:
  10. - name: 80-8080
  11. port: 80
  12. protocol: TCP
  13. targetPort: 8080
  14. selector:
  15. app: k8s-example
  16. type: ClusterIP # ClusterIP 需要 kubectl port-forward
  17. status:
  18. loadBalancer: {}

应用和部署生成的Deployment、Service文件

首先开启 watch 监听

  1. $ watch -n 1 kubectl get all
  2. Every 1.0s: kubectl get all swfeng.local: Thu May 7 10:26:58 2020
  3. NAME READY STATUS RESTARTS AGE
  4. pod/k8s-example-664b9f68d4-jwxmb 1/1 Running 0 52s
  5. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  6. service/k8s-example ClusterIP 10.96.67.94 <none> 80/TCP 52s
  7. service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 14d
  8. NAME READY UP-TO-DATE AVAILABLE AGE
  9. deployment.apps/k8s-example 1/1 1 1 52s

应用生成的yaml 文件

  1. $ kubectl apply -f ./k8s
  2. deployment.apps/k8s-example created
  3. service/k8s-example created

访问和测试应用

使用kubectl port-forward端口映射

  1. $ kubectl port-forward service/k8s-example 8080:80
  2. Forwarding from 127.0.0.1:8080 -> 8080
  3. Forwarding from [::1]:8080 -> 8080

使用kubectl port-forwardservice/k8s-example服务的 80 端口映射到宿主机的8080端口

测试访问

  1. curl http://127.0.0.1:8080/hello
  2. hello,kubernetes!
  • LoadBalancer方式

注意:完成该实验时先清理资源。具体使用如下的命令

  1. $ kubectl delete -f ./k8s
  2. deployment.apps "k8s-example" deleted
  3. service "k8s-example" deleted

备份并修改service.yaml文件,修改service.yaml文件中的ClusterIpLoadBalancer,其修改后的文件内容为

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. creationTimestamp: null
  5. labels:
  6. app: k8s-example
  7. name: k8s-example
  8. spec:
  9. ports:
  10. - name: 80-8080
  11. port: 80
  12. protocol: TCP
  13. targetPort: 8080
  14. selector:
  15. app: k8s-example
  16. type: LoadBalancer # LoadBalancer 不需要kubectl port-forward 直接用映射出来的 IP 和端口访问
  17. status:
  18. loadBalancer: {}

应用修改后的文件

  1. $ kubectl apply -f ./k8s

观察服务映射信息

  1. $ watch -n 1 kubectl get all
  2. Every 1.0s: kubectl get all swfeng.local: Thu May 7 10:48:50 2020
  3. NAME READY STATUS RESTARTS AGE
  4. pod/k8s-example-664b9f68d4-wnf4s 1/1 Running 0 71s
  5. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  6. service/k8s-example LoadBalancer 10.100.43.70 localhost 80:31223/TCP 71s
  7. service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 14d

或执行如下的命令

  1. $ kubectl get service k8s-example -w
  2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  3. k8s-example LoadBalancer 10.100.43.70 localhost 80:31223/TCP 5m47s

根据日志输出发现service/k8s-example,已经做好了 IP、端口映射绑定。

测试并访问应用

  1. $ curl http://127.0.0.1/hello
  2. hello,kubernetes!

Skaffold

检查版本信息

  1. $ skaffold version
  2. v1.9.0

生成skaffold.yaml文件

  1. $ skaffold init --XXenableJibInit
  2. apiVersion: skaffold/v2beta3
  3. kind: Config
  4. metadata:
  5. name: k-s-example
  6. build:
  7. artifacts:
  8. - image: registry.hub.docker.com/aimeizi/k8s-example
  9. jib:
  10. project: net.ameizi:k8s-example
  11. deploy:
  12. kubectl:
  13. manifests:
  14. - k8s/deployment.yaml
  15. - k8s/service.yaml
  16. Do you want to write this configuration to skaffold.yaml? [y/n]: y
  17. Configuration skaffold.yaml was written
  18. You can now run [skaffold build] to build the artifacts
  19. or [skaffold run] to build and deploy
  20. or [skaffold dev] to enter development mode, with auto-redeploy

执行完上述操作后会在项目根目录生成一个skaffold.yaml文件,其内容为:

  1. apiVersion: skaffold/v2beta3
  2. kind: Config
  3. metadata:
  4. name: k-s-example
  5. build:
  6. artifacts:
  7. - image: registry.hub.docker.com/aimeizi/k8s-example
  8. jib:
  9. project: net.ameizi:k8s-example
  10. deploy:
  11. kubectl:
  12. manifests:
  13. - k8s/deployment.yaml
  14. - k8s/service.yaml

使用Skaffold部署应用

  1. $ skaffold dev --port-forward
  2. Listing files to watch...
  3. - registry.hub.docker.com/aimeizi/k8s-example
  4. Generating tags...
  5. - registry.hub.docker.com/aimeizi/k8s-example -> registry.hub.docker.com/aimeizi/k8s-example:latest
  6. Some taggers failed. Rerun with -vdebug for errors.
  7. Checking cache...
  8. - registry.hub.docker.com/aimeizi/k8s-example: Not found. Building
  9. Found [docker-desktop] context, using local docker daemon.
  10. Building [registry.hub.docker.com/aimeizi/k8s-example]...
  11. [INFO] Scanning for projects...
  12. [INFO]
  13. [INFO] -----------------------< net.ameizi:k8s-example >-----------------------
  14. [INFO] Building k8s-example 1.0.0
  15. [INFO] --------------------------------[ jar ]---------------------------------
  16. [INFO]
  17. [INFO] --- jib-maven-plugin:2.2.0:_skaffold-fail-if-jib-out-of-date (default-cli) @ k8s-example ---
  18. [INFO]
  19. [INFO] -----------------------< net.ameizi:k8s-example >-----------------------
  20. [INFO] Building k8s-example 1.0.0
  21. [INFO] --------------------------------[ jar ]---------------------------------
  22. [INFO]
  23. [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ k8s-example ---
  24. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  25. [INFO] Copying 1 resource
  26. [INFO] Copying 0 resource
  27. [INFO]
  28. [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ k8s-example ---
  29. [INFO] Nothing to compile - all classes are up to date
  30. [INFO]
  31. [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ k8s-example ---
  32. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  33. [INFO] skip non existing resourceDirectory /Users/amz/develop/workspace/k8s-example/src/test/resources
  34. [INFO]
  35. [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ k8s-example ---
  36. [INFO] Changes detected - recompiling the module!
  37. [INFO] Compiling 1 source file to /Users/amz/develop/workspace/k8s-example/target/test-classes
  38. [INFO]
  39. [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ k8s-example ---
  40. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.pom
  41. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.pom (7.0 kB at 4.7 kB/s)
  42. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-providers/2.22.2/surefire-providers-2.22.2.pom
  43. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-providers/2.22.2/surefire-providers-2.22.2.pom (2.5 kB at 5.5 kB/s)
  44. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.pom
  45. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.pom (2.2 kB at 4.9 kB/s)
  46. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.pom
  47. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.pom (1.2 kB at 2.6 kB/s)
  48. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.pom
  49. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.pom (2.4 kB at 5.4 kB/s)
  50. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.pom
  51. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.pom (2.0 kB at 4.5 kB/s)
  52. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.pom
  53. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.pom (1.7 kB at 3.7 kB/s)
  54. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.jar
  55. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.jar
  56. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.jar
  57. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.jar
  58. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar
  59. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar (2.2 kB at 1.2 kB/s)
  60. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-engine/1.3.1/junit-platform-engine-1.3.1.jar (135 kB at 75 kB/s)
  61. Downloading from aliyun: https://maven.aliyun.com/repository/public/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar
  62. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-commons/1.3.1/junit-platform-commons-1.3.1.jar (78 kB at 38 kB/s)
  63. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.jar (66 kB at 31 kB/s)
  64. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.jar (95 kB at 45 kB/s)
  65. Downloaded from aliyun: https://maven.aliyun.com/repository/public/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar (7.1 kB at 15 kB/s)
  66. [INFO]
  67. [INFO] -------------------------------------------------------
  68. [INFO] T E S T S
  69. [INFO] -------------------------------------------------------
  70. [INFO] Running net.ameizi.k8s.example.K8sExampleApplicationTests
  71. 11:09:31.561 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
  72. 11:09:31.581 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
  73. 11:09:31.624 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [net.ameizi.k8s.example.K8sExampleApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
  74. 11:09:31.653 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [net.ameizi.k8s.example.K8sExampleApplicationTests], using SpringBootContextLoader
  75. 11:09:31.659 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [net.ameizi.k8s.example.K8sExampleApplicationTests]: class path resource [net/ameizi/k8s/example/K8sExampleApplicationTests-context.xml] does not exist
  76. 11:09:31.660 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [net.ameizi.k8s.example.K8sExampleApplicationTests]: class path resource [net/ameizi/k8s/example/K8sExampleApplicationTestsContext.groovy] does not exist
  77. 11:09:31.660 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [net.ameizi.k8s.example.K8sExampleApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
  78. 11:09:31.662 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [net.ameizi.k8s.example.K8sExampleApplicationTests]: K8sExampleApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
  79. 11:09:31.734 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [net.ameizi.k8s.example.K8sExampleApplicationTests]
  80. 11:09:31.858 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/Users/amz/develop/workspace/k8s-example/target/classes/net/ameizi/k8s/example/K8sExampleApplication.class]
  81. 11:09:31.859 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration net.ameizi.k8s.example.K8sExampleApplication for test class net.ameizi.k8s.example.K8sExampleApplicationTests
  82. 11:09:32.026 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [net.ameizi.k8s.example.K8sExampleApplicationTests]: using defaults.
  83. 11:09:32.027 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
  84. 11:09:32.042 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
  85. 11:09:32.042 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
  86. 11:09:32.043 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@5ba3f27a, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@58d75e99, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@74751b3, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@741a8937, org.springframework.test.context.support.DirtiesContextTestExecutionListener@306e95ec, org.springframework.test.context.event.EventPublishingTestExecutionListener@52af26ee, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@6fd83fc1, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@4f2b503c, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@bae7dc0, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@209da20d, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@e15b7e8]
  87. 11:09:32.046 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@434a63ab testClass = K8sExampleApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@6e0f5f7f testClass = K8sExampleApplicationTests, locations = '{}', classes = '{class net.ameizi.k8s.example.K8sExampleApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@48fa0f47, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@6d2a209c, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@4ddced80, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@76908cc0], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
  88. 11:09:32.101 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=-1}
  89. . ____ _ __ _ _
  90. /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
  91. ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  92. \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  93. ' |____| .__|_| |_|_| |_\__, | / / / /
  94. =========|_|==============|___/=/_/_/_/
  95. :: Spring Boot :: (v2.2.6.RELEASE)
  96. 2020-05-07 11:09:32.439 INFO 40881 --- [ main] n.a.k.e.K8sExampleApplicationTests : Starting K8sExampleApplicationTests on swfeng.local with PID 40881 (started by amz in /Users/amz/develop/workspace/k8s-example)
  97. 2020-05-07 11:09:32.440 INFO 40881 --- [ main] n.a.k.e.K8sExampleApplicationTests : No active profile set, falling back to default profiles: default
  98. 2020-05-07 11:09:34.552 INFO 40881 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
  99. 2020-05-07 11:09:35.159 INFO 40881 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 13 endpoint(s) beneath base path '/actuator'
  100. 2020-05-07 11:09:35.242 INFO 40881 --- [ main] n.a.k.e.K8sExampleApplicationTests : Started K8sExampleApplicationTests in 3.126 seconds (JVM running for 4.349)
  101. [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.144 s - in net.ameizi.k8s.example.K8sExampleApplicationTests
  102. 2020-05-07 11:09:35.600 INFO 40881 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
  103. [INFO]
  104. [INFO] Results:
  105. [INFO]
  106. [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
  107. [INFO]
  108. [INFO]
  109. [INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ k8s-example ---
  110. [INFO] Building jar: /Users/amz/develop/workspace/k8s-example/target/k8s-example-1.0.0.jar
  111. [INFO]
  112. [INFO] --- spring-boot-maven-plugin:2.2.6.RELEASE:repackage (repackage) @ k8s-example ---
  113. [INFO] Replacing main artifact with repackaged archive
  114. [INFO]
  115. [INFO] --- jib-maven-plugin:2.2.0:build (default) @ k8s-example ---
  116. [INFO]
  117. [INFO] Containerizing application to registry.hub.docker.com/aimeizi/k8s-example...
  118. [WARNING] Base image 'openjdk:8-jdk-alpine' does not use a specific image digest - build may not be reproducible
  119. [INFO] Getting manifest for base image openjdk:8-jdk-alpine...
  120. [INFO] Building dependencies layer...
  121. [INFO] Building resources layer...
  122. [INFO] Building classes layer...
  123. [INFO] Using credentials from Docker config (/Users/amz/.docker/config.json) for registry.hub.docker.com/aimeizi/k8s-example
  124. [INFO] The base image requires auth. Trying again for openjdk:8-jdk-alpine...
  125. [WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: registry-1.docker.io
  126. Got output:
  127. credentials not found in native keychain
  128. [INFO] Using credentials from Docker config (/Users/amz/.docker/config.json) for openjdk:8-jdk-alpine
  129. [INFO] Using base image with digest: sha256:44b3cea369c947527e266275cee85c71a81f20fc5076f6ebb5a13f19015dce71
  130. [INFO]
  131. [INFO] Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, net.ameizi.k8s.example.K8sExampleApplication]
  132. [INFO]
  133. [INFO] Built and pushed image as registry.hub.docker.com/aimeizi/k8s-example
  134. [INFO]
  135. [INFO]
  136. [INFO] --- jib-maven-plugin:2.2.0:dockerBuild (default-cli) @ k8s-example ---
  137. [INFO]
  138. [INFO] Containerizing application to Docker daemon as registry.hub.docker.com/aimeizi/k8s-example...
  139. [WARNING] Base image 'openjdk:8-jdk-alpine' does not use a specific image digest - build may not be reproducible
  140. [INFO] Getting manifest for base image openjdk:8-jdk-alpine...
  141. [INFO] Building dependencies layer...
  142. [INFO] Building resources layer...
  143. [INFO] Building classes layer...
  144. [INFO] The base image requires auth. Trying again for openjdk:8-jdk-alpine...
  145. [WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: registry-1.docker.io
  146. Got output:
  147. credentials not found in native keychain
  148. [INFO] Using credentials from Docker config (/Users/amz/.docker/config.json) for openjdk:8-jdk-alpine
  149. [INFO] Using base image with digest: sha256:44b3cea369c947527e266275cee85c71a81f20fc5076f6ebb5a13f19015dce71
  150. [INFO]
  151. [INFO] Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, net.ameizi.k8s.example.K8sExampleApplication]
  152. [INFO] Loading to Docker daemon...
  153. [INFO]
  154. [INFO] Built image to Docker daemon as registry.hub.docker.com/aimeizi/k8s-example
  155. [INFO]
  156. [INFO] ------------------------------------------------------------------------
  157. [INFO] BUILD SUCCESS
  158. [INFO] ------------------------------------------------------------------------
  159. [INFO] Total time: 03:12 min
  160. [INFO] Finished at: 2020-05-07T11:12:33+08:00
  161. [INFO] ------------------------------------------------------------------------
  162. Tags used in deployment:
  163. - registry.hub.docker.com/aimeizi/k8s-example -> registry.hub.docker.com/aimeizi/k8s-example:1ab1c78361f6855399f7865c3abb1b8bc6693cfc6b90edcd37fa81a98379668b
  164. Starting deploy...
  165. - deployment.apps/k8s-example created
  166. - service/k8s-example created
  167. Waiting for deployments to stabilize...
  168. - deployment/k8s-example: waiting for rollout to finish: 0 of 1 updated replicas are available...
  169. - deployment/k8s-example is ready.
  170. Deployments stabilized in 1.262264304s
  171. Port forwarding service/k8s-example in namespace default, remote port 80 -> address 127.0.0.1 port 4503
  172. Watching for changes...
  173. [k8s-example-8469866549-s8v6s k8s-example]
  174. [k8s-example-8469866549-s8v6s k8s-example] . ____ _ __ _ _
  175. [k8s-example-8469866549-s8v6s k8s-example] /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
  176. [k8s-example-8469866549-s8v6s k8s-example] ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  177. [k8s-example-8469866549-s8v6s k8s-example] \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  178. [k8s-example-8469866549-s8v6s k8s-example] ' |____| .__|_| |_|_| |_\__, | / / / /
  179. [k8s-example-8469866549-s8v6s k8s-example] =========|_|==============|___/=/_/_/_/
  180. [k8s-example-8469866549-s8v6s k8s-example] :: Spring Boot :: (v2.2.6.RELEASE)
  181. [k8s-example-8469866549-s8v6s k8s-example]
  182. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:38.122 INFO 1 --- [ restartedMain] n.a.k8s.example.K8sExampleApplication : Starting K8sExampleApplication on k8s-example-8469866549-s8v6s with PID 1 (/app/classes started by root in /)
  183. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:38.128 INFO 1 --- [ restartedMain] n.a.k8s.example.K8sExampleApplication : No active profile set, falling back to default profiles: default
  184. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:38.208 INFO 1 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
  185. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:38.208 INFO 1 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
  186. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:39.900 INFO 1 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
  187. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:39.922 INFO 1 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
  188. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:39.922 INFO 1 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
  189. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:40.022 INFO 1 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
  190. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:40.022 INFO 1 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1814 ms
  191. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:40.922 INFO 1 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
  192. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:41.226 INFO 1 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
  193. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:41.236 INFO 1 --- [ restartedMain] o.s.b.a.e.web.EndpointLinksResolver : Exposing 13 endpoint(s) beneath base path '/actuator'
  194. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:41.336 INFO 1 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
  195. [k8s-example-8469866549-s8v6s k8s-example] 2020-05-07 03:12:41.346 INFO 1 --- [ restartedMain] n.a.k8s.example.K8sExampleApplication : Started K8sExampleApplication in 3.714 seconds (JVM running for 4.57)

根据日志输出发现Port forwarding service/k8s-example in namespace default, remote port 80 -> address 127.0.0.1 port 4503

  1. $ curl http://127.0.0.1:4503/hello
  2. hello,kubernetes!

修改应用中的代码,并再次观察其输出

  1. $ curl http://127.0.0.1:4503/hello
  2. hello,Skaffold!

发现,程序修改后会自动重新构建并部署应用。

skaffold进程结束后会自动清理

  1. ^CCleaning up...
  2. WARN[0802] signal: interrupt
  3. - deployment.apps "k8s-example" deleted
  4. - service "k8s-example" deleted

执行 debug

  1. $ skaffold debug --port-forward
  2. Listing files to watch...
  3. Generating tags...
  4. - registry.hub.docker.com/aimeizi/k8s-example -> registry.hub.docker.com/aimeizi/k8s-example:latest
  5. Some taggers failed. Rerun with -vdebug for errors.
  6. Checking cache...
  7. - registry.hub.docker.com/aimeizi/k8s-example: Found Locally
  8. Tags used in deployment:
  9. - registry.hub.docker.com/aimeizi/k8s-example -> registry.hub.docker.com/aimeizi/k8s-example:8c60b1d982f01598222d196f322372427252593e6de28599f49cca8a45ea3229
  10. Starting deploy...
  11. - deployment.apps/k8s-example created
  12. - service/k8s-example created
  13. Waiting for deployments to stabilize...
  14. - deployment/k8s-example: waiting for rollout to finish: 0 of 1 updated replicas are available...
  15. - deployment/k8s-example is ready.
  16. Deployments stabilized in 1.845665959s
  17. Port forwarding service/k8s-example in namespace default, remote port 80 -> address 127.0.0.1 port 4503
  18. Watching for changes...
  19. Port forwarding pod/k8s-example-5fbc9ff88b-pdv8m in namespace default, remote port 5005 -> address 127.0.0.1 port 5005
  20. [k8s-example-5fbc9ff88b-pdv8m k8s-example] Picked up JAVA_TOOL_OPTIONS: -agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=n,quiet=y
  21. [k8s-example-5fbc9ff88b-pdv8m k8s-example]
  22. [k8s-example-5fbc9ff88b-pdv8m k8s-example] . ____ _ __ _ _
  23. [k8s-example-5fbc9ff88b-pdv8m k8s-example] /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
  24. [k8s-example-5fbc9ff88b-pdv8m k8s-example] ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  25. [k8s-example-5fbc9ff88b-pdv8m k8s-example] \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  26. [k8s-example-5fbc9ff88b-pdv8m k8s-example] ' |____| .__|_| |_|_| |_\__, | / / / /
  27. [k8s-example-5fbc9ff88b-pdv8m k8s-example] =========|_|==============|___/=/_/_/_/
  28. [k8s-example-5fbc9ff88b-pdv8m k8s-example] :: Spring Boot :: (v2.2.6.RELEASE)
  29. [k8s-example-5fbc9ff88b-pdv8m k8s-example]
  30. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:27.077 INFO 1 --- [ restartedMain] n.a.k8s.example.K8sExampleApplication : Starting K8sExampleApplication on k8s-example-5fbc9ff88b-pdv8m with PID 1 (/app/classes started by root in /)
  31. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:27.090 INFO 1 --- [ restartedMain] n.a.k8s.example.K8sExampleApplication : No active profile set, falling back to default profiles: default
  32. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:27.202 INFO 1 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
  33. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:27.205 INFO 1 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
  34. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:28.990 INFO 1 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
  35. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:29.010 INFO 1 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
  36. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:29.010 INFO 1 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
  37. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:29.115 INFO 1 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
  38. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:29.115 INFO 1 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1905 ms
  39. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:30.167 INFO 1 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
  40. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:30.650 INFO 1 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
  41. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:30.664 INFO 1 --- [ restartedMain] o.s.b.a.e.web.EndpointLinksResolver : Exposing 13 endpoint(s) beneath base path '/actuator'
  42. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:30.806 INFO 1 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
  43. [k8s-example-5fbc9ff88b-pdv8m k8s-example] 2020-05-07 03:24:30.818 INFO 1 --- [ restartedMain] n.a.k8s.example.K8sExampleApplication : Started K8sExampleApplication in 4.549 seconds (JVM running for 5.451)

根据日志输出,在 ide 中进行设置即可

  1. -agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=n,quiet=y


浏览器地址栏输入http://127.0.0.1:4503/hello即可进入断点模式

Kustomize

执行如下命令创建目录

  1. $ mkdir -p kustomize/base
  2. $ mv k8s/* kustomize/base
  3. $ rm -Rf k8s

kustomize/base目录下创建kustomization.yaml文件,其内容为

  1. apiVersion: kustomize.config.k8s.io/v1beta1
  2. kind: Kustomization
  3. resources:
  4. - service.yaml
  5. - deployment.yaml

kustomize/qa目录下创建update-replicas.yaml文件,其内容为

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: k8s-example
  5. spec:
  6. replicas: 2

kustomize/qa目录下创建kustomization.yaml文件,其内容为

  1. apiVersion: kustomize.config.k8s.io/v1beta1
  2. kind: Kustomization
  3. resources:
  4. - ../base
  5. patchesStrategicMerge:
  6. - update-replicas.yaml

运行 Kustomize

执行构建

  1. $ kustomize build ./kustomize/base
  2. apiVersion: v1
  3. kind: Service
  4. metadata:
  5. creationTimestamp: null
  6. labels:
  7. app: k8s-example
  8. name: k8s-example
  9. spec:
  10. ports:
  11. - name: 80-8080
  12. port: 80
  13. protocol: TCP
  14. targetPort: 8080
  15. selector:
  16. app: k8s-example
  17. type: LoadBalancer
  18. status:
  19. loadBalancer: {}
  20. ---
  21. apiVersion: apps/v1
  22. kind: Deployment
  23. metadata:
  24. creationTimestamp: null
  25. labels:
  26. app: k8s-example
  27. name: k8s-example
  28. spec:
  29. replicas: 1
  30. selector:
  31. matchLabels:
  32. app: k8s-example
  33. strategy: {}
  34. template:
  35. metadata:
  36. creationTimestamp: null
  37. labels:
  38. app: k8s-example
  39. spec:
  40. containers:
  41. - image: registry.hub.docker.com/aimeizi/k8s-example:latest
  42. name: k8s-example
  43. resources: {}
  44. status: {}
  1. $ kustomize build ./kustomize/qa
  2. apiVersion: v1
  3. kind: Service
  4. metadata:
  5. creationTimestamp: null
  6. labels:
  7. app: k8s-example
  8. name: k8s-example
  9. spec:
  10. ports:
  11. - name: 80-8080
  12. port: 80
  13. protocol: TCP
  14. targetPort: 8080
  15. selector:
  16. app: k8s-example
  17. type: LoadBalancer
  18. status:
  19. loadBalancer: {}
  20. ---
  21. apiVersion: apps/v1
  22. kind: Deployment
  23. metadata:
  24. creationTimestamp: null
  25. labels:
  26. app: k8s-example
  27. name: k8s-example
  28. spec:
  29. replicas: 2
  30. selector:
  31. matchLabels:
  32. app: k8s-example
  33. strategy: {}
  34. template:
  35. metadata:
  36. creationTimestamp: null
  37. labels:
  38. app: k8s-example
  39. spec:
  40. containers:
  41. - image: registry.hub.docker.com/aimeizi/k8s-example:latest
  42. name: k8s-example
  43. resources: {}
  44. status: {}

部署应用服务

  1. $ kustomize build kustomize/qa | kubectl apply -f -
  2. service/k8s-example created
  3. deployment.apps/k8s-example created

查看状态

  1. $ watch -n 1 kubectl get all
  2. Every 1.0s: kubectl get all swfeng.local: Thu May 7 15:48:05 2020
  3. NAME READY STATUS RESTARTS AGE
  4. pod/k8s-example-664b9f68d4-qzfqs 1/1 Running 0 116s
  5. pod/k8s-example-664b9f68d4-s7xv7 1/1 Running 0 116s
  6. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  7. service/k8s-example LoadBalancer 10.100.196.38 localhost 80:32689/TCP 116s
  8. service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 15d

运行测试

  1. $ curl http://127.0.0.1/hello
  2. hello,Skaffold!

此时发现k8s-example在两个Pod间具有LoadBalancer

清理资源

  1. $ kustomize build kustomize/qa | kubectl delete -f -

Kustomize 整合 Skaffold

默认情况下Skaffold使用kubectl部署应用,可以修改使用kustomize来部署应用。其具体操作如下,修改skaffold.yaml配置文件内容如下所示:

  1. apiVersion: skaffold/v2beta3
  2. kind: Config
  3. metadata:
  4. name: k-s-example
  5. build:
  6. artifacts:
  7. - image: registry.hub.docker.com/aimeizi/k8s-example
  8. jib:
  9. project: net.ameizi:k8s-example
  10. deploy:
  11. # kubectl:
  12. # manifests:
  13. # - k8s/deployment.yaml
  14. # - k8s/service.yaml
  15. kustomize:
  16. paths: ["kustomize/base"]
  17. profiles:
  18. - name: qa
  19. deploy:
  20. kustomize:
  21. paths: ["kustomize/qa"]

即修改deploy的kubectl属性为kustomize

测试Skaffold整合Kustomize后的效果

  1. $ skaffold dev

注:以上命令默认执行kustomize/base目录下的配置

  1. $ skaffold dev -p qa

注:以上命令执行kustomize/qa目录下的配置

kt-connect本地联调

检查版本信息

  1. $ ktctl --version
  2. KT Connect version kt-0.0.12

启动ktctl

  1. $ sudo ktctl -d connect --method socks5
  2. Password:
  3. 4:13PM INF Connect Start At 58263
  4. 4:13PM INF Client address 172.24.202.121
  5. 4:13PM INF deploy shadow deployment kt-connect-daemon-qocry in namespace default
  6. 4:13PM INF pod label: kt=kt-connect-daemon-qocry
  7. 4:13PM INF pod: kt-connect-daemon-qocry-5f976c8848-nzn67 is running,but not ready
  8. 4:13PM INF pod: kt-connect-daemon-qocry-5f976c8848-nzn67 is running,but not ready
  9. 4:13PM INF pod: kt-connect-daemon-qocry-5f976c8848-nzn67 is running,but not ready
  10. 4:13PM INF Shadow pod: kt-connect-daemon-qocry-5f976c8848-nzn67 is ready.
  11. 4:13PM INF Fail to get pod cidr from node.Spec.PODCIDR, try to get with pod sample
  12. 4:13PM DBG Child, os.Args = [ktctl -d connect --method socks5]
  13. 4:13PM DBG Child, cmd.Args = [kubectl --kubeconfig=/Users/amz/.kube/config -n default port-forward kt-connect-daemon-qocry-5f976c8848-nzn67 2222:22]
  14. Forwarding from 127.0.0.1:2222 -> 22
  15. Forwarding from [::1]:2222 -> 22
  16. 4:13PM INF port-forward start at pid: 58266
  17. 4:13PM INF ==============================================================
  18. 4:13PM INF Start SOCKS5 Proxy: export http_proxy=socks5://127.0.0.1:2223
  19. 4:13PM INF ==============================================================
  20. 4:13PM DBG Child, os.Args = [ktctl -d connect --method socks5]
  21. 4:13PM DBG Child, cmd.Args = [ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -i /Users/amz/.kt_id_rsa -D 2223 root@127.0.0.1 -p2222 sh loop.sh]
  22. Handling connection for 2222
  23. Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts.
  24. 4:13PM INF vpn(ssh) start at pid: 58268
  25. 4:13PM INF KT proxy start successful

根据日志输出在终端设置http_proxy环境变量,然后使用CLUSTER-IP:PORT访问应用

查看服务端口映射信息

  1. $ watch -n 1 kubectl get all
  2. Every 1.0s: kubectl get all swfeng.local: Thu May 7 16:17:54 2020
  3. NAME READY STATUS RESTARTS AGE
  4. pod/k8s-example-55697bcd6b-kwzhf 1/1 Running 0 5m18s
  5. pod/kt-connect-daemon-izhxa-6f95f75678-k578z 1/1 Running 0 7m38s
  6. pod/kt-connect-daemon-qocry-5f976c8848-nzn67 1/1 Running 0 4m34s
  7. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  8. service/k8s-example LoadBalancer 10.100.27.20 localhost 80:32106/TCP 5m18s
  9. service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 15d

命令行验证

  1. $ export http_proxy=socks5://127.0.0.1:2223
  2. $ curl http://10.100.27.20:80/hello
  3. hello,Skaffold!

IDEA中与Kubernetes集群中的程序联调

ktctl在socks5模式下,会自动在当前路径下生成.jvmrc文件,该文件中会包含SOCKS5代理的相关JVM参数。其内容如下所示:

  1. -DsocksProxyHost=127.0.0.1
  2. -DsocksProxyPort=2223

在 ide 中安装JVM Inject插件,在IDEA中启动Java程序时,该插件会自动加载当前项目根路径下的.jvmrc并追加到Java的启动参数中。具体如下所示

  1. /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:52776,suspend=y,server=n -Dvisualvm.id=90478590646964 -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=2223

之后可以在 ide 中直接访问k8s中的服务。

远程调试

  1. FROM openjdk:8-jdk-alpine
  2. VOLUME /tmp
  3. ADD target/app.jar target/app.jar
  4. ENTRYPOINT ["java","-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n","-Djava.security.egd=file:/dev/./urandom","-Xms2g","-Xmx8g","-jar","target/app.jar"]

在 Service 中暴露端口

如本例可修改为

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. creationTimestamp: null
  5. labels:
  6. app: k8s-example
  7. name: k8s-example
  8. spec:
  9. ports:
  10. - name: 80-8080
  11. port: 80
  12. protocol: TCP
  13. targetPort: 8080
  14. - name: 5005-5005
  15. port: 5005
  16. protocol: TCP
  17. targetPort: 5005
  18. selector:
  19. app: k8s-example
  20. type: LoadBalancer # LoadBalancer 不需要kubectl port-forward 直接用映射出来的 IP 和端口访问
  21. status:
  22. loadBalancer: {}

参考文档

https://hackmd.io/@ryanjbaxter/spring-on-k8s-workshop

https://spring.io/blog/2020/01/27/creating-docker-images-with-spring-boot-2-3-0-m1

https://github.com/alibaba/kt-connect

http://ylzheng.com/2019/12/14/how-to-integration-with-kubernetes-from-idea/

https://itnext.io/remote-debugging-spring-boot-on-kubernetes-a5f96a40e5c0