devops:docker:kubernetes:tutorial-springboot
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
devops:docker:kubernetes:tutorial-springboot [2024/03/04 21:48] – skipidar | devops:docker:kubernetes:tutorial-springboot [2024/03/05 21:51] (current) – skipidar | ||
---|---|---|---|
Line 6: | Line 6: | ||
<sxh> | <sxh> | ||
- | $ ./gradlew bootJar | + | $ ./gradlew bootJar |
Starting a Gradle Daemon, 1 busy and 1 stopped Daemons could not be reused, use --status for details | Starting a Gradle Daemon, 1 busy and 1 stopped Daemons could not be reused, use --status for details | ||
Line 35: | Line 35: | ||
2024-03-04T22: | 2024-03-04T22: | ||
</ | </ | ||
+ | |||
+ | |||
+ | Building the image: | ||
+ | |||
+ | <sxh> | ||
+ | $ ./gradlew bootBuildImage | ||
+ | |||
+ | [creator] | ||
+ | [creator] | ||
+ | [creator] | ||
+ | [creator] | ||
+ | [creator] | ||
+ | [creator] | ||
+ | [creator] | ||
+ | [creator] | ||
+ | [creator] | ||
+ | [creator] | ||
+ | |||
+ | Successfully built image ' | ||
+ | |||
+ | |||
+ | BUILD SUCCESSFUL in 1m 6s | ||
+ | 5 actionable tasks: 1 executed, 4 up-to-date | ||
+ | skip@desktop:/ | ||
+ | REPOSITORY | ||
+ | paketobuildpacks/ | ||
+ | gcr.io/ | ||
+ | gcr.io/ | ||
+ | demo 0.0.1-SNAPSHOT | ||
+ | paketobuildpacks/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | Running | ||
+ | |||
+ | <sxh> | ||
+ | docker run -p 8080:8080 demo: | ||
+ | Setting Active Processor Count to 20 | ||
+ | Calculating JVM memory based on 30175084K available memory | ||
+ | For more information on this calculation, | ||
+ | Calculated JVM Memory Configuration: | ||
+ | Enabling Java Native Memory Tracking | ||
+ | Adding 137 container CA certificates to JVM truststore | ||
+ | Spring Cloud Bindings Enabled | ||
+ | Picked up JAVA_TOOL_OPTIONS: | ||
+ | |||
+ | . | ||
+ | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ | ||
+ | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ | ||
+ | | ||
+ | ' | ||
+ | | ||
+ | :: Spring Boot :: (v3.2.3) | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | Generate deployment config | ||
+ | |||
+ | <sxh shell> | ||
+ | kubectl create deployment demo --image=springguides/ | ||
+ | echo --- >> deployment.yaml | ||
+ | kubectl create service clusterip demo --tcp=8080: | ||
+ | </ | ||
+ | |||
+ | Manifests are YAML files containing multiple resources separated by the " | ||
+ | |||
+ | |||
+ | * **Service in Kubernetes**: | ||
+ | * **ClusterIP Service Type**: When you use clusterip, you're creating a service that has a virtual IP address assigned within the cluster. **This IP address is only accessible from within the cluster** and cannot be directly accessed from the outside world. | ||
+ | * **Benefits**: | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | <sxh shell> | ||
+ | |||
+ | skip@desktop:/ | ||
+ | NAME READY | ||
+ | pod/ | ||
+ | |||
+ | NAME | ||
+ | service/ | ||
+ | service/ | ||
+ | |||
+ | NAME | ||
+ | deployment.apps/ | ||
+ | |||
+ | NAME DESIRED | ||
+ | replicaset.apps/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | Now you need to be able to connect to the application, | ||
+ | |||
+ | |||
+ | |||
+ | <sxh shell> | ||
+ | kubectl port-forward svc/demo 8080:8080 | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | **Kubernetes usually uses REMOTE images from repo.** | ||
+ | To fix: | ||
+ | |||
+ | |||
+ | **Step1: | ||
+ | |||
+ | Artificially add the image to the minikube cache. | ||
+ | |||
+ | |||
+ | Achtung: work around bug https:// | ||
+ | |||
+ | <sxh> | ||
+ | skip@desktop:/ | ||
+ | skip@desktop:/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | **Step2: | ||
+ | |||
+ | Use '' | ||
+ | |||
+ | After taht '' | ||
+ | |||
+ | <sxh shell> | ||
+ | skip@desktop:/ | ||
+ | skip@desktop:/ | ||
+ | REPOSITORY | ||
+ | docker | ||
+ | k8s.gcr.io/ | ||
+ | k8s.gcr.io/ | ||
+ | k8s.gcr.io/ | ||
+ | k8s.gcr.io/ | ||
+ | k8s.gcr.io/ | ||
+ | k8s.gcr.io/ | ||
+ | k8s.gcr.io/ | ||
+ | kubernetesui/ | ||
+ | kubernetesui/ | ||
+ | gcr.io/ | ||
+ | springguides/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Now finally you can run a container with image ' | ||
+ | |||
+ | <sxh> | ||
+ | skip@desktop:/ | ||
+ | deployment.apps/ | ||
+ | service/ | ||
+ | skip@desktop:/ | ||
+ | NAME READY | ||
+ | pod/ | ||
+ | |||
+ | NAME | ||
+ | service/ | ||
+ | service/ | ||
+ | |||
+ | NAME | ||
+ | deployment.apps/ | ||
+ | |||
+ | NAME DESIRED | ||
+ | replicaset.apps/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | Forwarding port | ||
+ | |||
+ | <sxh> | ||
+ | kubectl port-forward svc/demo 8080:8080 | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | kubectl: This is the command-line tool used to interact with a Kubernetes cluster. | ||
+ | |||
+ | port-forward: | ||
+ | |||
+ | svc/demo: This specifies the target resource for port forwarding. It indicates a Service named demo in the current namespace. | ||
+ | |||
+ | 8080:8080: This defines the port mapping. The first 8080 represents the local port on your machine that will be used to access the forwarded service. The second 8080 indicates the port on the target service within the cluster. | ||
+ | |||
+ | |||
+ | |||
+ | You can now reach the service on 8080 | ||
+ | <sxh> | ||
+ | curl localhost: | ||
+ | </ | ||
+ |
devops/docker/kubernetes/tutorial-springboot.1709588903.txt.gz · Last modified: by skipidar