25 Π»Π΅Ρ Π½Π°Π·Π°Π΄ Java ΠΏΠΎΡΠ»Π° Π² ΡΠΈΡΠΎΠΊΠΈΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΡΠΊΠΈΠ΅ ΠΌΠ°ΡΡΡ, ΡΡΠΎΠ±Ρ Π² ΠΈΡΠΎΠ³Π΅ ΡΡΠ°ΡΡ ΠΎΠ΄Π½ΠΈΠΌ ΠΈΠ· ΡΠ΅Ρ
ΡΡΠ΅ΡΠΆΠ½Π΅ΠΉ, Π²ΠΎΠΊΡΡΠ³ ΠΊΠΎΡΠΎΡΡΡ
ΡΡΡΠΎΡΡΡΡ ΡΡΠ΅ΠΊΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ. ΠΠ΄Π½Π°ΠΊΠΎ ΡΠ΅Π³ΠΎΠ΄Π½Ρ ΠΌΠ½ΠΎΠ³ΠΈΠ΅ Π»ΡΠ΄ΠΈ ΠΈ ΠΎΡΠ³Π°Π½ΠΈΠ·Π°ΡΠΈΠΈ, Π΄ΠΎΠ»Π³ΠΈΠ΅ Π³ΠΎΠ΄Ρ Ρ
ΡΠ°Π½ΠΈΠ²ΡΠΈΠ΅ Π²Π΅ΡΠ½ΠΎΡΡΡ Java, Π·Π°Π½ΡΡΡ ΡΠ΅ΠΌ, ΡΡΠΎ ΠΏΠ΅ΡΠ΅Ρ
ΠΎΠ΄ΡΡ ΠΈΠ»ΠΈ Π΄ΡΠΌΠ°ΡΡ ΠΏΠ΅ΡΠ΅Ρ
ΠΎΠ΄ΠΈΡΡ Π½Π° ΠΏΠ»Π°ΡΡΠΎΡΠΌΡ
Π£Π²Ρ, Kubernetes ΠΎΡΠ»ΠΈΡΠ°Π΅ΡΡΡ ΠΊΡΡΡΠΎΠΉ ΠΊΡΠΈΠ²ΠΎΠΉ ΠΎΠ±ΡΡΠ΅Π½ΠΈΡ ΠΈ Π²Π²ΠΎΠ΄ΠΈΡ Π΅ΡΠ΅ ΠΎΠ΄ΠΈΠ½ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΡΠΉ ΡΡΠΎΠ²Π΅Π½Ρ Π² ΠΏΡΠΈΠ²ΡΡΠ½ΡΠΉ Π΄Π»Ρ Java-ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡΠΎΠ² ΠΏΡΠΎΡΠ΅ΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ. Π‘Π΅Π³ΠΎΠ΄Π½Ρ ΠΌΡ ΡΠ°ΡΡΠΊΠ°ΠΆΠ΅ΠΌ, ΠΊΠ°ΠΊ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ
Π’ΡΠ°Π΄ΠΈΡΠΈΠΎΠ½Π½ΡΠΉ ΠΏΡΠΎΡΠ΅ΡΡ Java-ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ
Π’ΡΠ°Π΄ΠΈΡΠΈΠΎΠ½Π½ΡΠΉ ΠΏΡΠΎΡΠ΅ΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ
Π ΠΈΡ. 1. Π’ΡΠ°Π΄ΠΈΡΠΈΠΎΠ½Π½ΡΠΉ ΠΏΡΠΎΡΠ΅ΡΡ Java-ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ.
ΠΡΠΎΡΠ΅ΡΡ Java-ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Π΄Π»Ρ ΠΎΠ±Π»Π°ΠΊΠ°
ΠΡΠΈ ΠΏΠ΅ΡΠ΅Ρ
ΠΎΠ΄Π΅ ΠΊ ΠΎΠ±Π»Π°ΡΠ½ΡΠΌ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡΠΌ Π² ΠΎΠΏΠΈΡΠ°Π½Π½ΡΡ Π²ΡΡΠ΅ ΡΡ
Π΅ΠΌΡ Π΄ΠΎΠ±Π°Π²Π»ΡΡΡΡΡ Kubernetes ΠΈ
ΠΠ΅ΡΠ°ΠΌΠΎΡΡΠΎΠ·Π° ΡΡΠ°Π΄ΠΈΡΠΈΠΎΠ½Π½ΠΎΠ³ΠΎ ΠΏΡΠΎΡΠ΅ΡΡΠ° Java-ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ ΠΏΡΠΈ ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄Π΅ ΠΊ ΠΎΠ±Π»Π°ΠΊΡ ΠΏΠΎΠΊΠ°Π·Π°Π½Π° Π½Π° Π ΠΈΡ. 2.
Π ΠΈΡ. 2. ΠΡΠΎΡΠ΅ΡΡ Java-ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Π΄Π»Ρ ΠΎΠ±Π»Π°ΠΊΠ°.
Eclipse JKube
ΠΠ΅ΡΠ΅Ρ
ΠΎΠ΄ Π½Π° Kubernetes Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅Ρ Π΅ΡΠ΅ ΠΎΠ΄ΠΈΠ½ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΡΠΉ ΡΡΠΎΠ²Π΅Π½Ρ Π² ΠΏΡΠΎΡΠ΅ΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ, ΠΈ ΠΌΠ½ΠΎΠ³ΠΈΡ
ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠΎΠ² ΡΡΠΎ Π½Π΅ΡΠ²ΠΈΡΡΠ΅Ρ, ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ ΠΎΠ½ΠΈ Ρ
ΠΎΡΡΡ Π·Π°Π½ΠΈΠΌΠ°ΡΡΡΡ ΡΠ²ΠΎΠ΅ΠΉ ΠΎΡΠ½ΠΎΠ²Π½ΠΎΠΉ ΡΠ°Π±ΠΎΡΠΎΠΉ β Π»ΠΎΠ³ΠΈΠΊΠΎΠΉ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ, β Π° Π½Π΅ ΡΠ΅ΠΌ, ΠΊΠ°ΠΊ ΠΈΡ
ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°ΡΡ. Π Π·Π΄Π΅ΡΡ Π² ΠΈΠ³ΡΡ Π²ΡΡΡΠΏΠ°Π΅Ρ
Π ΠΎΡΡΠ°Π²ΡΠ΅ΠΉΡΡ ΡΠ°ΡΡΠΈ ΡΡΠΎΠΉ ΡΡΠ°ΡΡΠΈ ΠΌΡ ΠΏΠΎΠΊΠ°ΠΆΠ΅ΠΌ, ΠΊΠ°ΠΊ ΡΠΏΡΠΎΡΡΠΈΡΡ ΠΏΡΠΎΡΠ΅ΡΡ Java-ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Π² ΡΡΠ΅Π΄Π΅ Kubernetes, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ Eclipse JKube Ρ ΠΏΠ»Π°Π³ΠΈΠ½ΠΎΠΌ Kubernetes Maven Plugin.
ΠΡΠΎΡΠ΅ΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Π΄Π»Ρ ΠΎΠ±Π»Π°ΠΊΠ° Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ Eclipse JKube
Π Π°ΡΡΠΌΠΎΡΡΠΈΠΌ ΡΠ»Π΅Π³ΠΊΠ° ΠΌΠΎΠ΄ΠΈΡΠΈΡΠΈΡΠΎΠ²Π°Π½Π½ΡΡ ΡΡ Π΅ΠΌΡ Java-ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Π΄Π»Ρ ΠΎΠ±Π»Π°ΠΊΠ° Ρ Π ΠΈΡ.2, Π²Π²Π΅Π΄Ρ Π² Π½Π΅Π΅ Eclipse JKube ΠΈ Kubernetes Maven Plugin, ΠΊΠ°ΠΊ ΠΏΠΎΠΊΠ°Π·Π°Π½ΠΎ Π½Π° Π ΠΈΡ. 3.
Π ΠΈΡ. 3. ΠΡΠΎΡΠ΅ΡΡ Java-ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Π΄Π»Ρ ΠΎΠ±Π»Π°ΠΊΠ° Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ Eclipse JKube.
ΠΠ°ΠΊ ΠΌΡ Π²ΠΈΠ΄ΠΈΠΌ, Π·Π΄Π΅ΡΡ Π²ΡΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ ΠΏΠΎ Π²Π·Π°ΠΈΠΌΠΎΠ΄Π΅ΠΉΡΡΠ²ΠΈΡ Ρ Kubernetes ΠΈ ΠΊΠΎΠ½ΡΠ΅ΠΉΠ½Π΅ΡΠ°ΠΌΠΈ (Π½Π° ΡΡ Π΅ΠΌΠ΅ Π²ΡΠ΄Π΅Π»Π΅Π½Ρ ΠΊΡΠ°ΡΠ½ΡΠΌ) Π·Π°ΠΌΠ΅Π½ΡΡΡΡΡ goal-Π·Π°Π΄Π°ΡΠ°ΠΌΠΈ Eclipse JKube ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΠ΅ΡΠ΅ΡΠΈΡΠ»Π΅Π½Ρ Π² Π’Π°Π±Π». 1.
Π’Π°Π±Π». 1. ΠΠ°Π΄Π°ΡΠΈ Eclipse JKube ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ.
ΠΠ°Π΄Π°ΡΠ°
ΠΡΠ°ΠΏ
ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅
PRE_INTEGRATION_TEST
Π‘Π±ΠΎΡΠΊΠ° docker-ΠΎΠ±ΡΠ°Π·ΠΎΠ²
INSTALL
ΠΡΠΏΡΠ°Π²ΠΊΠ° docker-ΠΎΠ±ΡΠ°Π·ΠΎΠ² Π² ΡΠ΅Π΅ΡΡΡ
PROCESS_RESOURCES
ΠΠ΅Π½Π΅ΡΠ°ΡΠΈΡ ΠΌΠ°Π½ΠΈΡΠ΅ΡΡΠΎΠ² K8s
COMPILE
ΠΡΠΈΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ ΡΠ³Π΅Π½Π΅ΡΠΈΡΠΎΠ²Π°Π½Π½ΡΡ
ΠΌΠ°Π½ΠΈΡΠ΅ΡΡΠΎΠ² ΠΊ K8s
UNDEPLOY
Π£Π΄Π°Π»Π΅Π½ΠΈΠ΅ ΡΠ΅ΡΡΡΡΠΎΠ² K8s, ΠΊΠΎΡΠΎΡΡΠ΅ Π±ΡΠ»ΠΈ ΡΠ°Π·Π²Π΅ΡΠ½ΡΡΡ ΠΏΠΎΡΡΠ΅Π΄ΡΡΠ²ΠΎΠΌ k8s:apply ΠΈ k8s:deploy
ΠΡΠΈΠΌΠ΅ΡΠ°Π½ΠΈΠ΅: ΠΡΠ»ΠΈ Π²Ρ Π½Π΅ Ρ
ΠΎΡΠΈΡΠ΅, ΡΡΠΎΠ±Ρ Π·Π°Π΄Π°ΡΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π»ΠΈ ΡΡΠΈ ΠΆΠ΅ΡΡΠΊΠΈΠ΅ Π΄Π΅ΡΠΎΠ»ΡΡ (opinionated defaults), ΡΠΎ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π²ΡΡΡΠ½ΡΡ Π½Π°ΡΡΡΠΎΠΈΡΡ Eclipse JKube ΠΏΠΎΠ΄ ΡΠ΅Π±Ρ, Π±Π»Π°Π³ΠΎ ΠΎΠ½ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠ΅ΡΠ΅Π·
Π’Π΅ΠΏΠ΅ΡΡ ΡΠ°ΡΡΠΌΠΎΡΡΠΈΠΌ ΠΏΡΠΈΠΌΠ΅ΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ Eclipse JKube ΠΈ Kubernetes Maven Plugin ΠΏΡΠΈ ΡΠ°Π±ΠΎΡΠ΅ Ρ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡΠΌΠΈ.
Π Π°Π·Π²Π΅ΡΡΡΠ²Π°Π΅ΠΌ Java-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π² Kubernetes Ρ ΠΏΠΎΠΌΠΎΡΡΡ Eclipse JKube
Π ΡΡΠΎΠΌ ΠΏΡΠΈΠΌΠ΅ΡΠ΅ ΠΌΡ ΡΠ°Π·Π²Π΅ΡΠ½Π΅ΠΌ ΠΏΡΠΎΡΡΠΎΠ΅ Java-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π² ΠΊΠ»Π°ΡΡΠ΅ΡΠ΅
Π ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΠΏΡΠΈΠΌΠ΅ΡΠ° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΌΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ
~/work/repos/eclipse-jkube-demo-project : $ curl localhost:8080/random | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 45 0 45 0 0 818 0 --:--:-- --:--:-- --:--:-- 818
{
"id": "e80a4d10-c79b-4b9a-aaac-7c286cb37f3c"
}
Π¨Π°Π³ 1. ΠΠ°Π³ΡΡΠΆΠ°Π΅ΠΌ Kubernetes Maven Plugin
Kubernetes Maven Plugin Π½Π°Ρ
ΠΎΠ΄ΠΈΡΡΡ Π² ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΈ
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${jkube.version}</version>
</plugin>
ΠΡΠ»ΠΈ Π²ΠΌΠ΅ΡΡΠΎ ΡΠΈΡΡΠΎΠ³ΠΎ Kubernetes ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ OpenShift, ΡΠΎ pom.xml ΠΌΠΎΠ΄ΠΈΡΠΈΡΠΈΡΡΠ΅ΡΡΡ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ:
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>openshift-maven-plugin</artifactId>
<version>${jkube.version}</version>
</plugin>
Π¨Π°Π³ 2. Π‘ΠΎΠ±ΠΈΡΠ°Π΅ΠΌ docker-ΠΎΠ±ΡΠ°Π·
JAR-ΡΠ°ΠΉΠ» ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ ΡΠΎΠ±ΡΠ°ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ mvn package, Π° Π·Π°ΡΠ΅ΠΌ ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ goal-Π·Π°Π΄Π°ΡΡ mvn k8s:build, ΡΡΠΎΠ±Ρ ΡΠΎΠ±ΡΠ°ΡΡ docker-ΠΎΠ±ΡΠ°Π· ΡΡΠΎΠ³ΠΎ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ. ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅, ΡΡΠΎ ΠΌΡ ΠΏΠ΅ΡΠ΅ΠΎΠΏΡΠ΅Π΄Π΅Π»ΠΈΠ»ΠΈ ΠΈΠΌΡ ΠΎΠ±ΡΠ°Π·Π° ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Π²ΠΎΡ ΡΡΠΎΠ³ΠΎ ΡΠ²ΠΎΠΉΡΡΠ²Π°:
<jkube.generator.name>docker.io/rohankanojia/random-generator:${project.version}</jkube.generator.name>
ΠΡΠ΅ΠΆΠ΄Π΅ ΡΠ΅ΠΌ ΡΠΎΠ±ΠΈΡΠ°ΡΡ ΠΎΠ±ΡΠ°Π·, Π½Π°Π΄ΠΎ ΡΠ±Π΅Π΄ΠΈΡΡΡΡ, ΡΡΠΎΠ±Ρ docker-Π΄Π΅ΠΌΠΎΠ½ Π±ΡΠ» ΠΊΠΎΡΡΠ΅ΠΊΡΠ½ΠΎ ΡΠΊΡΠΏΠΎΠ½ΠΈΡΠΎΠ²Π°Π½. ΠΡΠΎ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ:
$ eval $(minikube docker-env)
ΠΠ°ΡΠ΅ΠΌ Π²Π²ΠΎΠ΄ΠΈΠΌ ΠΊΠΎΠΌΠ°Π½Π΄Ρ mvn k8s:build, ΠΈ Π²ΠΎΡ ΡΡΠΎ ΠΌΡ ΡΠ²ΠΈΠ΄ΠΈΠΌ Π½Π° ΡΠΊΡΠ°Π½Π΅ ΠΏΡΠΈ ΡΠ±ΠΎΡΠΊΠ΅ docker-ΠΎΠ±ΡΠ°Π·Π° Ρ ΠΏΠΎΠΌΠΎΡΡΡ build-Π·Π°Π΄Π°ΡΠΈ Eclipse JKube:
~/work/repos/eclipse-jkube-demo-project : $ mvn k8s:build
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< meetup:random-generator >-----------------------
[INFO] Building random-generator 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- kubernetes-maven-plugin:1.0.0-rc-1:build (default-cli) @ random-generator ---
[INFO] k8s: Running in Kubernetes mode
[INFO] k8s: Building Docker image in Kubernetes mode
[INFO] k8s: Running generator spring-boot
[INFO] k8s: spring-boot: Using Docker image quay.io/jkube/jkube-java-binary-s2i:0.0.7 as base / builder
[INFO] k8s: [docker.io/rohankanojia/random-generator:0.0.1] "spring-boot": Created docker-build.tar in 251 milliseconds
[INFO] k8s: [docker.io/rohankanojia/random-generator:0.0.1] "spring-boot": Built image sha256:a20e5
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.053 s
[INFO] Finished at: 2020-08-10T11:28:23+05:30
[INFO] ------------------------------------------------------------------------
~/work/repos/eclipse-jkube-demo-project : $
Π¨Π°Π³ 3. ΠΡΠΏΡΠ°Π²Π»ΡΠ΅ΠΌ ΠΎΠ±ΡΠ°Π· Π² ΡΠ΅Π΅ΡΡΡ docker
ΠΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ, ΠΊΠ°ΠΊ ΠΌΡ ΡΠΎΠ±ΡΠ°Π»ΠΈ docker-ΠΎΠ±ΡΠ°Π· ΠΏΡΠΈ Π½Π°ΡΡΡΠΎΠ΅Π½Π½ΠΎΠΌ push-ΡΠ΅Π΅ΡΡΡΠ΅ (Π² Π½Π°ΡΠ΅ΠΌ ΡΠ»ΡΡΠ°Π΅ ΡΡΠΎ docker.io), ΠΌΠΎΠΆΠ½ΠΎ ΠΎΡΠΏΡΠ°Π²Π»ΡΡΡ ΡΡΠΎΡ ΠΎΠ±ΡΠ°Π· Π² ΡΠ΅Π΅ΡΡΡ. ΠΠΎΡ ΡΡΠΎ Π²ΡΠ²Π΅Π΄Π΅ΡΡΡ Π½Π° ΡΠΊΡΠ°Π½ ΠΏΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ, ΠΊΠ°ΠΊ ΠΌΡ ΠΏΠΎΠΏΡΠΎΡΠΈΠΌ Eclipse JKube Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ push-Π·Π°Π΄Π°ΡΡ mvn k8s:push:
~/work/repos/eclipse-jkube-demo-project : $ mvn k8s:push
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< meetup:random-generator >-----------------------
[INFO] Building random-generator 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- kubernetes-maven-plugin:1.0.0-rc-1:push (default-cli) @ random-generator ---
[INFO] k8s: Running in Kubernetes mode
[INFO] k8s: Building Docker image in Kubernetes mode
[INFO] k8s: Running generator spring-boot
[INFO] k8s: spring-boot: Using Docker image quay.io/jkube/jkube-java-binary-s2i:0.0.7 as base / builder
[INFO] k8s: The push refers to repository [docker.io/rohankanojia/random-generator]
5dcd9556710f: Layer already exists
b7139ad07aa8: Layer already exists
b6f081e4b2b6: Layer already exists
d8e1f35641ac: Layer already exists
[INFO] k8s: 0.0.1: digest: sha256:9f9eda2a13b8cab1d2c9e474248500145fc09e2922fe3735692f9bda4c76002d size: 1162
[INFO] k8s: Pushed docker.io/rohankanojia/random-generator:0.0.1 in 7 seconds
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.222 s
[INFO] Finished at: 2020-08-10T11:35:37+05:30
[INFO] ------------------------------------------------------------------------
~/work/repos/eclipse-jkube-demo-project : $
ΠΠΎΡΠ»Π΅ ΠΎΡΠΏΡΠ°Π²ΠΊΠΈ ΠΎΠ±ΡΠ°Π·Π° Π½Π°Π΄ΠΎ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ, ΡΡΠΎ ΠΎΠ½ ΠΏΠΎΠΏΠ°Π» Π² ΡΠ΅Π΅ΡΡΡ. Π Π½Π°ΡΠ΅ΠΌ ΡΠ»ΡΡΠ°Π΅ ΠΌΡ ΠΏΡΠΎΡΡΠΎ Π²ΠΈΠ΄ΠΈΠΌ Π΅Π³ΠΎ Π² Docker Hub, ΠΊΠ°ΠΊ ΠΏΠΎΠΊΠ°Π·Π°Π½ΠΎ Π½Π° Π ΠΈΡ. 4.
Π ΠΈΡ. 4. ΠΡΠΏΡΠ°Π²Π»Π΅Π½Π½ΡΠΉ Π² ΡΠ΅Π΅ΡΡΡ ΠΎΠ±ΡΠ°Π· ΠΏΠΎΡΠ²ΠΈΠ»ΡΡ Π² Docker Hub.
Π¨Π°Π³ 4. ΠΠ΅Π½Π΅ΡΠΈΡΡΠ΅ΠΌ ΠΌΠ°Π½ΠΈΡΠ΅ΡΡΡ Kubernetes-ΡΠ΅ΡΡΡΡΠΎΠ² Π΄Π»Ρ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ
ΠΡΠ°ΠΊ, ΠΎΠ±ΡΠ°Π· ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΌΡ ΡΠΎΠ±ΡΠ°Π»ΠΈ, ΡΠ΅ΠΏΠ΅ΡΡ Π½Π°Π΄ΠΎ Π½Π°ΠΏΠΈΡΠ°ΡΡ Kubernetes-ΠΌΠ°Π½ΠΈΡΠ΅ΡΡΡ. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π² Eclipse JKube Π΅ΡΡΡ Π·Π°Π΄Π°ΡΠ°, ΠΊΠΎΡΠΎΡΠ°Ρ Π³Π΅Π½Π΅ΡΠΈΡΡΠ΅Ρ ΠΆΠ΅ΡΡΠΊΠΈΠ΅ ΠΌΠ°Π½ΠΈΡΠ΅ΡΡΡ ΡΠ΅ΡΡΡΡΠΎΠ², ΠΎΡΡΠ°Π»ΠΊΠΈΠ²Π°ΡΡΡ ΠΎΡ Π½ΠΈΠΆΠ΅Π»Π΅ΠΆΠ°ΡΠ΅Π³ΠΎ Java-ΡΡΠ΅ΠΉΠΌΠ²ΠΎΡΠΊΠ° (
Π Π½Π°ΡΠ΅ΠΌ ΠΏΡΠΈΠΌΠ΅ΡΠ΅ ΠΌΡ ΠΎΡΡΠ°Π²Π»ΡΠ΅ΠΌ Π²ΡΠ΅ ΠΊΠ°ΠΊ Π΅ΡΡΡ, ΠΈ ΠΏΠΎΡΡΠΎΠΌΡ Eclipse JKube Π³Π΅Π½Π΅ΡΠΈΡΡΠ΅Ρ ΠΌΠ°Π½ΠΈΡΠ΅ΡΡ Π΄Π»Ρ Π΄Π΅ΡΠΎΠ»ΡΠ½ΠΎΠ³ΠΎ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΡ ΠΈ Π΄Π»Ρ ΡΠ΅ΡΠ²ΠΈΡΠ° Ρ ΡΠΈΠΏΠΎΠΌ ClusterIP. Π ΡΠΆΠ΅ ΠΏΠΎΡΠΎΠΌ ΠΌΡ ΠΌΠΎΠ΄ΠΈΡΠΈΡΠΈΡΡΠ΅ΠΌ ΠΌΠ°Π½ΠΈΡΠ΅ΡΡ ΡΠ΅ΡΠ²ΠΈΡΠ°, ΡΡΠΎΠ±Ρ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΡ ΡΠΈΠΏΠ° ΡΠ΅ΡΠ²ΠΈΡΠ° Π½Π° NodePort. ΠΠ΅ΡΠ΅ΠΎΠΏΡΠ΅Π΄Π΅Π»ΠΈΡΡ Π΄Π΅ΡΠΎΠ»ΡΠ½ΠΎΠ΅ ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ ΠΌΠΎΠΆΠ½ΠΎ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΡΠ»Π΅Π΄ΡΡΡΠ΅Π³ΠΎ ΡΠ²ΠΎΠΉΡΡΠ²Π°:
<jkube.enricher.jkube-service.type>NodePort</jkube.enricher.jkube-service.type>
ΠΠΎΡ ΠΊΠ°ΠΊ Π²ΡΠ³Π»ΡΠ΄ΠΈΡ ΡΠΊΡΠ°Π½Π½ΡΠΉ Π²ΡΠ²ΠΎΠ΄ ΠΏΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ, ΠΊΠ°ΠΊ ΠΌΡ ΠΏΠΎΠΏΡΠΎΡΠΈΠΌ Eclipse JKube Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ resource-Π·Π°Π΄Π°ΡΡ mvn k8s:resource.
~/work/repos/eclipse-jkube-demo-project : $ mvn k8s:resource
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< meetup:random-generator >-----------------------
[INFO] Building random-generator 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- kubernetes-maven-plugin:1.0.0-rc-1:resource (default-cli) @ random-generator ---
[INFO] k8s: Running generator spring-boot
[INFO] k8s: spring-boot: Using Docker image quay.io/jkube/jkube-java-binary-s2i:0.0.7 as base / builder
[INFO] k8s: jkube-controller: Adding a default Deployment
[INFO] k8s: jkube-service: Adding a default service 'random-generator' with ports [8080]
[INFO] k8s: jkube-healthcheck-spring-boot: Adding readiness probe on port 8080, path='/actuator/health', scheme='HTTP', with initial delay 10 seconds
[INFO] k8s: jkube-healthcheck-spring-boot: Adding liveness probe on port 8080, path='/actuator/health', scheme='HTTP', with initial delay 180 seconds
[INFO] k8s: jkube-revision-history: Adding revision history limit to 2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.344 s
[INFO] Finished at: 2020-08-10T11:38:11+05:30
[INFO] ------------------------------------------------------------------------
~/work/repos/eclipse-jkube-demo-project : $ ls target/classes/META-INF/jkube/kubernetes
random-generator-deployment.yml random-generator-service.yml
~/work/repos/eclipse-jkube-demo-project : $ cat target/classes/META-INF/jkube/kubernetes/random-generator-deployment.yml | head -n10
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
jkube.io/git-url: [email protected]:rohanKanojia/eclipse-jkube-demo-project.git
jkube.io/git-commit: 1ef9ef2ef7a6fcbf8eb64c293f26f9c42d026512
jkube.io/git-branch: master
jkube.io/scm-url: https://github.com/spring-projects/spring-boot/spring-boot-starter-parent/random-generator
jkube.io/scm-tag: HEAD
~/work/repos/eclipse-jkube-demo-project : $
Π¨Π°Π³ 5. Π Π°Π·Π²Π΅ΡΡΡΠ²Π°Π΅ΠΌ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π² ΠΊΠ»Π°ΡΡΠ΅ΡΠ΅ Kubernetes
ΠΡΠ°ΠΊ, Ρ Π½Π°Ρ Π²ΡΠ΅ Π³ΠΎΡΠΎΠ²ΠΎ, ΡΡΠΎΠ±Ρ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ: ΠΌΡ ΡΠ³Π΅Π½Π΅ΡΠΈΡΠΎΠ²Π°Π»ΠΈ Π΅Π³ΠΎ ΠΎΠ±ΡΠ°Π· ΠΈ Π·Π°ΡΠ΅ΠΌ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ ΡΠ³Π΅Π½Π΅ΡΠΈΡΠΎΠ²Π°Π»ΠΈ ΠΌΠ°Π½ΠΈΡΠ΅ΡΡΡ ΡΠ΅ΡΡΡΡΠΎΠ². Π’Π΅ΠΏΠ΅ΡΡ ΠΎΡΡΠ°Π»ΠΎΡΡ ΡΠΎΠ»ΡΠΊΠΎ ΠΏΡΠΈΠΌΠ΅Π½ΠΈΡΡ Π²ΡΡ ΡΡΠΎ ΠΊ ΠΊΠ»Π°ΡΡΠ΅ΡΡ Kubernetes. ΠΠ»Ρ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ, ΠΊΠΎΠ½Π΅ΡΠ½ΠΎ, Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ kubectl apply -f, Π½ΠΎ ΠΏΠ»Π°Π³ΠΈΠ½ ΠΈ ΡΡΠΎ ΠΌΠΎΠΆΠ΅Ρ ΡΠ΄Π΅Π»Π°ΡΡ Π·Π° Π½Π°Ρ. ΠΠΎΡ ΡΡΠΎ Π±ΡΠ΄Π΅Ρ Π½Π° ΡΠΊΡΠ°Π½Π΅ ΠΏΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ, ΠΊΠ°ΠΊ ΠΌΡ ΠΏΠΎΠΏΡΠΎΡΠΈΠΌ Eclipse JKube Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ apply-Π·Π°Π΄Π°ΡΡ mvn k8s:apply:
~/work/repos/eclipse-jkube-demo-project : $ mvn k8s:apply
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< meetup:random-generator >-----------------------
[INFO] Building random-generator 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- kubernetes-maven-plugin:1.0.0-rc-1:apply (default-cli) @ random-generator ---
[INFO] k8s: Using Kubernetes at https://192.168.39.145:8443/ in namespace default with manifest /home/rohaan/work/repos/eclipse-jkube-demo-project/target/classes/META-INF/jkube/kubernetes.yml
[INFO] k8s: Using namespace: default
[INFO] k8s: Creating a Service from kubernetes.yml namespace default name random-generator
[INFO] k8s: Created Service: target/jkube/applyJson/default/service-random-generator.json
[INFO] k8s: Creating a Deployment from kubernetes.yml namespace default name random-generator
[INFO] k8s: Created Deployment: target/jkube/applyJson/default/deployment-random-generator.json
[INFO] k8s: HINT: Use the command `kubectl get pods -w` to watch your pods start up
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.306 s
[INFO] Finished at: 2020-08-10T11:40:57+05:30
[INFO] ------------------------------------------------------------------------
~/work/repos/eclipse-jkube-demo-project : $ kubectl get pods -w
NAME READY STATUS RESTARTS AGE
random-generator-58b7847d7f-9m9df 0/1 Running 0 7s
random-generator-58b7847d7f-9m9df 1/1 Running 0 17s
^C~/work/repos/eclipse-jkube-demo-project : $ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
io-openliberty-sample-getting-started NodePort 10.110.4.104 <none> 9080:30570/TCP 44h
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 18d
random-generator NodePort 10.97.172.147 <none> 8080:32186/TCP 22s
~/work/repos/eclipse-jkube-demo-project : $ curl `minikube ip`:32186/random | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 45 0 45 0 0 1800 0 --:--:-- --:--:-- --:--:-- 1875
{
"id": "42e5571f-a20f-44b3-8184-370356581d10"
}
Π¨Π°Π³ 6. ΠΠ΅Π»Π°Π΅ΠΌ undeploy ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΈΠ· ΠΊΠ»Π°ΡΡΠ΅ΡΠ° Kubernetes
ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π·Π°Π΄Π°ΡΠ° undeploy, ΠΊΠΎΡΠΎΡΠ°Ρ ΠΏΡΠΎΡΡΠΎ ΡΠ΄Π°Π»ΡΠ΅Ρ Π²ΡΠ΅ ΡΠ΅ΡΡΡΡΡ, ΠΊΠΎΡΠΎΡΡΠ΅ Π±ΡΠ»ΠΈ ΠΏΡΠΈΠΌΠ΅Π½Π΅Π½Ρ Π½Π° ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅ΠΌ ΡΠ°Π³Π΅, ΡΠΎ Π΅ΡΡΡ ΠΏΡΠΈ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠΈ Π·Π°Π΄Π°ΡΠΈ apply. ΠΠΎΡ ΡΡΠΎ ΠΌΡ ΡΠ²ΠΈΠ΄ΠΈΠΌ Π½Π° ΡΠΊΡΠ°Π½Π΅ ΠΏΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ, ΠΊΠ°ΠΊ ΠΏΠΎΠΏΡΠΎΡΠΈΠΌ Eclipse JKube Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ undeploy-Π·Π°Π΄Π°ΡΡ mvn k8s:undeploy:
~/work/repos/eclipse-jkube-demo-project : $ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/random-generator-58b7847d7f-9m9df 1/1 Running 0 5m21s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 18d
service/random-generator NodePort 10.97.172.147 <none> 8080:32186/TCP 5m21s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/random-generator 1/1 1 1 5m21s
NAME DESIRED CURRENT READY AGE
replicaset.apps/random-generator-58b7847d7f 1 1 1 5m21s
~/work/repos/eclipse-jkube-demo-project : $ mvn k8s:undeploy
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< meetup:random-generator >-----------------------
[INFO] Building random-generator 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- kubernetes-maven-plugin:1.0.0-rc-1:undeploy (default-cli) @ random-generator ---
[INFO] k8s: Using Kubernetes at https://192.168.39.145:8443/ in namespace default with manifest /home/rohaan/work/repos/eclipse-jkube-demo-project/target/classes/META-INF/jkube/kubernetes.yml
[INFO] k8s: Using namespace: default
[INFO] k8s: Deleting resource Deployment default/random-generator
[INFO] k8s: Deleting resource Service default/random-generator
[INFO] k8s: HINT: Use the command `kubectl get pods -w` to watch your pods start up
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.412 s
[INFO] Finished at: 2020-08-10T11:46:22+05:30
[INFO] ------------------------------------------------------------------------
~/work/repos/eclipse-jkube-demo-project : $ kubectl get pods -w
^C~/work/repos/eclipse-jkube-demo-project : $ kubectl get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 18d
~/work/repos/eclipse-jkube-demo-project : $
Π§ΡΠΎ Π΅ΡΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ Ρ Eclipse JKube
ΠΡΠ°ΠΊ, ΠΌΡ ΡΠ°ΡΡΠΌΠΎΡΡΠ΅Π»ΠΈ ΠΎΡΠ½ΠΎΠ²Π½ΡΠ΅ goal-Π·Π°Π΄Π°ΡΠΈ Eclipse JKube ΠΈ Kubernetes Maven Plugin, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΎΠ±Π»Π΅Π³ΡΠ°ΡΡ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΡ Java-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Π΄Π»Ρ ΠΏΠ»Π°ΡΡΠΎΡΠΌΡ Kubernetes. ΠΡΠ»ΠΈ Π²Π°ΠΌ Π½Π΅ Ρ ΠΎΡΠ΅ΡΡΡ ΠΏΠΎΡΡΠΎΡΠ½Π½ΠΎ Π²Π²ΠΎΠ΄ΠΈΡΡ ΡΡΠΈ Π·Π°Π΄Π°ΡΠΈ Ρ ΠΊΠ»Π°Π²ΠΈΠ°ΡΡΡΡ, ΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠΏΠΈΡΠ°ΡΡ Π² ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΠΈ ΠΏΠ»Π°Π³ΠΈΠ½Π°, Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ, Π²ΠΎΡ ΡΠ°ΠΊ:
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>resource</goal>
<goal>apply</goal>
</goals>
</execution>
</executions>
</plugin>
ΠΠ°Π΄ΠΎ ΡΠΊΠ°Π·Π°ΡΡ, ΡΡΠΎ Π² ΡΡΠΎΠΉ ΡΡΠ°ΡΡΠ΅ ΠΌΡ ΡΠ°ΡΡΠΌΠΎΡΡΠ΅Π»ΠΈ Π΄Π°Π»Π΅ΠΊΠΎ Π½Π΅ Π²ΡΠ΅ goal-Π·Π°Π΄Π°ΡΠΈ, ΠΊΠΎΡΠΎΡΡΠ΅ Π΅ΡΡΡ Π² Eclipse JKube ΠΈ Kubernetes Maven Plugin, ΠΏΠΎΡΡΠΎΠΌΡ ΠΏΡΠΈΠ²ΠΎΠ΄ΠΈΠΌ Π² Π’Π°Π±Π».2 ΡΠΏΠΈΡΠΎΠΊ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΡ Π·Π°Π΄Π°Ρ, ΠΊΠΎΡΠΎΡΡΠ΅ ΡΠ°ΠΊΠΆΠ΅ ΠΌΠΎΠ³ΡΡ Π²Π°ΠΌ ΠΏΡΠΈΠ³ΠΎΠ΄ΠΈΡΡΡΡ.
Π’Π°Π±Π». 2. ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ goal-Π·Π°Π΄Π°ΡΠΈ Eclipse JKube.
ΠΠ°Π΄Π°ΡΠ°
ΠΡΠ°ΠΏ
ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅
VALIDATE
ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ Π»ΠΎΠ³ΠΎΠ² ΠΎΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, ΡΠ°Π±ΠΎΡΠ°ΡΡΠ΅Π³ΠΎ Π½Π° Kubernetes.
PACKAGE
ΠΡΠΊΡΡΡΠΈΠ΅ ΠΎΡΠ»Π°Π΄ΠΎΡΠ½ΠΎΠ³ΠΎ ΠΏΠΎΡΡΠ°, ΡΡΠΎΠ±Ρ Π²ΡΠΏΠΎΠ»Π½ΡΡΡ ΠΎΡΠ»Π°Π΄ΠΊΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, ΡΠ°Π±ΠΎΡΠ°ΡΡΠ΅Π³ΠΎ Π½Π° Kubernetes, Π½Π΅ΠΏΠΎΡΡΠ΅Π΄ΡΡΠ²Π΅Π½Π½ΠΎ ΠΈΠ· IDE.
INSTALL
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΡΠΎΡΠΊΠ° Π΄Π»Ρ Install-Π·Π°Π΄Π°ΡΠΈ ΠΈ ΠΏΡΠΈΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ ΡΠ³Π΅Π½Π΅ΡΠΈΡΠΎΠ²Π°Π½Π½ΡΡ
ΠΌΠ°Π½ΠΈΡΠ΅ΡΡΠΎΠ² ΠΊ ΠΊΠ»Π°ΡΡΠ΅ΡΡ Kubernetes ΡΠΎΡΠ½ΠΎ ΡΠ°ΠΊ ΠΆΠ΅, ΠΊΠ°ΠΊ Π² ΡΠ»ΡΡΠ°Π΅ apply-Π·Π°Π΄Π°ΡΠΈ.
PACKAGE
ΠΠ²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠ΅ Π³ΠΎΡΡΡΠ΅Π΅ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π·Π° ΡΡΠ΅Ρ ΠΎΡΡΠ»Π΅ΠΆΠΈΠ²Π°Π½ΠΈΡ Π΅Π³ΠΎ ΠΏΡΠΎΡΡΡΠ°Π½ΡΡΠ²Π° ΠΈΠΌΠ΅Π½.
Π Π°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΠ΅ Java-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Π½Π° Red Hat OpenShift Ρ ΠΏΠΎΠΌΠΎΡΡΡ OpenShift Maven Plugin
ΠΠ»Ρ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΈΠ· Π½Π°ΡΠ΅Π³ΠΎ ΠΏΡΠΈΠΌΠ΅ΡΠ° Π½Π° ΠΏΠ»Π°ΡΡΠΎΡΠΌΠ΅ Red Hat OpenShift ΠΏΡΠΈΠΌΠ΅Π½ΠΈΠΌ ΠΏΠ»Π°Π³ΠΈΠ½
~/work/repos/eclipse-jkube-demo-project : $ mvn oc:build oc:resource oc:apply
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< meetup:random-generator >-----------------------
[INFO] Building random-generator 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- openshift-maven-plugin:1.0.0-rc-1:build (default-cli) @ random-generator ---
[INFO] oc: Using OpenShift build with strategy S2I
[INFO] oc: Running in OpenShift mode
[INFO] oc: Running generator spring-boot
[INFO] oc: spring-boot: Using Docker image quay.io/jkube/jkube-java-binary-s2i:0.0.7 as base / builder
[INFO] oc: [random-generator:0.0.1] "spring-boot": Created docker source tar /home/rohaan/work/repos/eclipse-jkube-demo-project/target/docker/random-generator/0.0.1/tmp/docker-build.tar
[INFO] oc: Adding to Secret pullsecret-jkube
[INFO] oc: Using Secret pullsecret-jkube
[INFO] oc: Creating BuildServiceConfig random-generator-s2i for Source build
[INFO] oc: Creating ImageStream random-generator
[INFO] oc: Starting Build random-generator-s2i
[INFO] oc: Waiting for build random-generator-s2i-1 to complete...
[INFO] oc: Caching blobs under "/var/cache/blobs".
[INFO] oc: Getting image source signatures
[INFO] oc: Copying blob sha256:cf0f3ebe9f536c782ab3835049cfbd9a663761ded9370791ef6ea3965c823aad
[INFO] oc: Copying blob sha256:57de4da701b511cba33bbdc424757f7f3b408bea741ca714ace265da9b59191a
[INFO] oc: Copying blob sha256:f320f94d91a064281f5127d5f49954b481062c7d56cce3b09910e471cf849050
[INFO] oc: Copying config sha256:52d6788fcfdd39595264d34a3959464a5dabc1d4ef0ae188802b20fc2d6a857b
[INFO] oc: Writing manifest to image destination
[INFO] oc: Storing signatures
[INFO] oc: Generating dockerfile with builder image quay.io/jkube/jkube-java-binary-s2i:0.0.7
[INFO] oc: STEP 1: FROM quay.io/jkube/jkube-java-binary-s2i:0.0.7
[INFO] oc: STEP 2: LABEL "io.openshift.build.source-location"="/tmp/build/inputs" "io.openshift.build.image"="quay.io/jkube/jkube-java-binary-s2i:0.0.7"
[INFO] oc: STEP 3: ENV JAVA_APP_DIR="/deployments" OPENSHIFT_BUILD_NAME="random-generator-s2i-1" OPENSHIFT_BUILD_NAMESPACE="default"
[INFO] oc: STEP 4: USER root
[INFO] oc: STEP 5: COPY upload/src /tmp/src
[INFO] oc: STEP 6: RUN chown -R 1000:0 /tmp/src
[INFO] oc: STEP 7: USER 1000
[INFO] oc: STEP 8: RUN /usr/local/s2i/assemble
[INFO] oc: INFO S2I source build with plain binaries detected
[INFO] oc: INFO S2I binary build from fabric8-maven-plugin detected
[INFO] oc: INFO Copying binaries from /tmp/src/deployments to /deployments ...
[INFO] oc: random-generator-0.0.1.jar
[INFO] oc: INFO Copying deployments from deployments to /deployments...
[INFO] oc: '/tmp/src/deployments/random-generator-0.0.1.jar' -> '/deployments/random-generator-0.0.1.jar'
[INFO] oc: STEP 9: CMD /usr/local/s2i/run
[INFO] oc: STEP 10: COMMIT temp.builder.openshift.io/default/random-generator-s2i-1:48795e41
[INFO] oc: time="2020-08-10T06:37:49Z" level=info msg="Image operating system mismatch: image uses "", expecting "linux""
[INFO] oc: time="2020-08-10T06:37:49Z" level=info msg="Image architecture mismatch: image uses "", expecting "amd64""
[INFO] oc: Getting image source signatures
[INFO] oc: Copying blob sha256:d8e1f35641acb80b562f70cf49911341dfbe8c86f4d522b18efbf3732aa74223
[INFO] oc: Copying blob sha256:b6f081e4b2b6de8be4b1dec132043d14c121e968384dd624fb69c2c07b482edb
[INFO] oc: Copying blob sha256:b7139ad07aa8ce4ed5a132f7c5cc9f1de0f5099b5e155027a23d57f7fbe78b16
[INFO] oc: Copying blob sha256:98972fc90a1108315cc5b05b2c691a0849a149727a7b81e76bc847ac2c6d9714
[INFO] oc: Copying config sha256:27aaadaf28e24856a66db962b88118b8222b61d79163dceeeed869f7289bc230
[INFO] oc: Writing manifest to image destination
[INFO] oc: Storing signatures
[INFO] oc: --> 27aaadaf28e
[INFO] oc: 27aaadaf28e24856a66db962b88118b8222b61d79163dceeeed869f7289bc230
[INFO] oc: Getting image source signatures
[INFO] oc:
[INFO] oc: Pushing image image-registry.openshift-image-registry.svc:5000/default/random-generator:0.0.1 ...
[INFO] oc: Copying blob sha256:f320f94d91a064281f5127d5f49954b481062c7d56cce3b09910e471cf849050
[INFO] oc: Copying blob sha256:cf0f3ebe9f536c782ab3835049cfbd9a663761ded9370791ef6ea3965c823aad
[INFO] oc: Copying blob sha256:57de4da701b511cba33bbdc424757f7f3b408bea741ca714ace265da9b59191a
[INFO] oc: Copying blob sha256:98972fc90a1108315cc5b05b2c691a0849a149727a7b81e76bc847ac2c6d9714
[INFO] oc: Copying config sha256:27aaadaf28e24856a66db962b88118b8222b61d79163dceeeed869f7289bc230
[INFO] oc: Writing manifest to image destination
[INFO] oc: Storing signatures
[INFO] oc: Successfully pushed image-registry.openshift-image-registry.svc:5000/default/random-generator@sha256:aa9e1a380c04ef9174ba56459c13d44420ebe653ebf32884d60fe4306b17306d
[INFO] oc: Push successful
[INFO] oc: Build random-generator-s2i-1 in status Complete
[INFO] oc: Found tag on ImageStream random-generator tag: sha256:aa9e1a380c04ef9174ba56459c13d44420ebe653ebf32884d60fe4306b17306d
[INFO] oc: ImageStream random-generator written to /home/rohaan/work/repos/eclipse-jkube-demo-project/target/random-generator-is.yml
[INFO]
[INFO] --- openshift-maven-plugin:1.0.0-rc-1:resource (default-cli) @ random-generator ---
[INFO] oc: Using docker image name of namespace: default
[INFO] oc: Running generator spring-boot
[INFO] oc: spring-boot: Using Docker image quay.io/jkube/jkube-java-binary-s2i:0.0.7 as base / builder
[INFO] oc: jkube-controller: Adding a default DeploymentConfig
[INFO] oc: jkube-service: Adding a default service 'random-generator' with ports [8080]
[INFO] oc: jkube-healthcheck-spring-boot: Adding readiness probe on port 8080, path='/actuator/health', scheme='HTTP', with initial delay 10 seconds
[INFO] oc: jkube-healthcheck-spring-boot: Adding liveness probe on port 8080, path='/actuator/health', scheme='HTTP', with initial delay 180 seconds
[INFO] oc: jkube-revision-history: Adding revision history limit to 2
[INFO]
[INFO] --- openshift-maven-plugin:1.0.0-rc-1:apply (default-cli) @ random-generator ---
[INFO] oc: Using OpenShift at https://api.crc.testing:6443/ in namespace default with manifest /home/rohaan/work/repos/eclipse-jkube-demo-project/target/classes/META-INF/jkube/openshift.yml
[INFO] oc: OpenShift platform detected
[INFO] oc: Using project: default
[INFO] oc: Creating a Service from openshift.yml namespace default name random-generator
[INFO] oc: Created Service: target/jkube/applyJson/default/service-random-generator.json
[INFO] oc: Creating a DeploymentConfig from openshift.yml namespace default name random-generator
[INFO] oc: Created DeploymentConfig: target/jkube/applyJson/default/deploymentconfig-random-generator.json
[INFO] oc: Creating Route default:random-generator host: null
[INFO] oc: HINT: Use the command `oc get pods -w` to watch your pods start up
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:07 min
[INFO] Finished at: 2020-08-10T12:08:00+05:30
[INFO] ------------------------------------------------------------------------
~/work/repos/eclipse-jkube-demo-project : $ oc get pods -w
NAME READY STATUS RESTARTS AGE
random-generator-1-deploy 1/1 Running 0 14s
random-generator-1-vnrm9 0/1 Running 0 11s
random-generator-s2i-1-build 0/1 Completed 0 1m
random-generator-1-vnrm9 1/1 Running 0 24s
random-generator-1-deploy 0/1 Completed 0 28s
~/work/repos/eclipse-jkube-demo-project : $ oc get routes
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
random-generator random-generator-default.apps-crc.testing random-generator 8080 None
~/work/repos/eclipse-jkube-demo-project : $ curl random-generator-default.apps-crc.testing/random
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 45 0 45 0 0 1666 0 --:--:-- --:--:-- --:--:-- 1730
{
"id": "d80052d9-2f92-43cb-b9eb-d7cffb879798"
}
~/work/repos/eclipse-jkube-demo-project : $
ΠΠΈΠ΄Π΅ΠΎ-ΡΡΠΎΠΊ
Π§ΡΠΎΠ±Ρ ΡΠ·Π½Π°ΡΡ Π±ΠΎΠ»ΡΡΠ΅ ΠΎ ΡΠΎΠΌ, ΠΊΠ°ΠΊ ΡΠΏΡΠΎΡΡΠΈΡΡ Kubernetes-ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Eclipse JKube, ΠΏΠΎΡΠΌΠΎΡΡΠΈΡΠ΅ Π²ΠΈΠ΄Π΅ΠΎ-ΡΡΠΎΠΊ ΠΏΠΎ Π±ΡΡΡΡΠΎΠΌΡ ΡΠ°Π·Π²Π΅ΡΡΡΠ²Π°Π½ΠΈΡ ΠΏΡΠΎΡΡΠΎΠ³ΠΎ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Spring Boot Π½Π° Minikube:
ΠΠ°ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅
Π ΡΡΠΎΠΉ ΡΡΠ°ΡΡΠ΅ ΠΌΡ ΠΏΠΎΠΊΠ°Π·Π°Π»ΠΈ, ΠΊΠ°ΠΊ Eclipse JKube ΠΎΠ±Π»Π΅Π³ΡΠ°Π΅Ρ ΠΆΠΈΠ·Π½Ρ Java-ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΡ ΠΏΡΠΈ ΡΠ°Π±ΠΎΡΠ΅ Ρ Kubernetes. ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΡ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΏΠΎ Eclipse JKube ΠΌΠΎΠΆΠ½ΠΎ Π½Π°ΠΉΡΠΈ Π½Π°
ΠΡΡΠΎΡΠ½ΠΈΠΊ: habr.com