User Tools

Site Tools


devops:docker:kubernetes:tutorial-springboot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devops:docker:kubernetes:tutorial-springboot [2024/03/05 21:17] skipidardevops:docker:kubernetes:tutorial-springboot [2024/03/05 21:51] (current) skipidar
Line 140: Line 140:
  
  
-Kubernetes usually uses REMOTE images from repo.+**Kubernetes usually uses REMOTE images from repo.** 
 +To fix: 
 + 
 + 
 +**Step1:** 
  
 Artificially add the image to the minikube cache. Artificially add the image to the minikube cache.
  
-Using "minikube image load docker:latest"+ 
-Achtungwithout repository name.+Achtung: work around bug https://github.com/kubernetes/minikube/issues/18021 
 + 
 +<sxh> 
 +skip@desktop:/mnt/d/1PROJEKTE/Kubernete-tutorials-springboot$ docker image save -o image.tar springguides/demo:latest 
 +skip@desktop:/mnt/d/1PROJEKTE/Kubernete-tutorials-springboot$ minikube image load image.tar 
 +</sxh> 
 + 
 + 
 +**Step2:**  
 + 
 +Use ''eval $(minikube docker-env)'' to switch to container cache within minikube. 
 + 
 +After taht ''docker images'' will show you minikube containers.
  
 <sxh shell> <sxh shell>
-skip@desktop:~$ docker images +skip@desktop:/mnt/d/1PROJEKTE/Kubernete-tutorials-springboot$ eval $(minikube docker-env) 
-REPOSITORY                            TAG              IMAGE ID       CREATED        SIZE +skip@desktop:/mnt/d/1PROJEKTE/Kubernete-tutorials-springboot$ docker images 
-paketobuildpacks/run-jammy-base       latest           ddb21b4d22de   days ago     111MB +REPOSITORY                                TAG       IMAGE ID       CREATED        SIZE 
-gcr.io/k8s-minikube/kicbase           v0.0.42          dbc648475405   4 months ago   1.2GB +docker                                    latest    e5fbe8997fd9   11 days ago    348MB 
-gcr.io/k8s-minikube/kicbase           v0.0.30          1312ccd2422d   2 years ago    1.14GB +k8s.gcr.io/kube-apiserver                 v1.23.3   f40be0088a83   2 years ago    135MB 
-demo                                  0.0.1-SNAPSHOT   b57e814aa8fb   44 years ago   307MB +k8s.gcr.io/kube-controller-manager        v1.23.  b07520cd7ab7   2 years ago    125MB 
-springguides/demo                     latest           b57e814aa8fb   44 years ago   307MB +k8s.gcr.io/kube-scheduler                 v1.23.3   99a3486be4f2   2 years ago    53.5MB 
-paketobuildpacks/builder-jammy-base   latest           d00577c76e33   44 years ago   1.46GB +k8s.gcr.io/kube-proxy                     v1.23.3   9b7cc9982109   2 years ago    112MB 
-skip@desktop:~$ minikube image load docker:latest +k8s.gcr.io/etcd                           3.5.1-  25f8c7f3da61   years ago    293MB 
-skip@desktop:~$ +k8s.gcr.io/coredns/coredns                v1.8.6    a4ca41631cc7   2 years ago    46.8MB 
 +k8s.gcr.io/pause                          3.6       6270bb605e12   years ago    683kB 
 +kubernetesui/dashboard                    v2.3.1    e1482a24335a   2 years ago    220MB 
 +kubernetesui/metrics-scraper              v1.0.7    7801cfc6d5c0   2 years ago    34.4MB 
 +gcr.io/k8s-minikube/storage-provisioner   v5        6e38f40d628d   years ago    31.5MB 
 +springguides/demo                         latest    b57e814aa8fb   44 years ago   307MB
 </sxh> </sxh>
  
  
 +
 +
 +
 +Now finally you can run a container with image 'image: springguides/demo'
 +
 +<sxh>
 +skip@desktop:/mnt/d/1PROJEKTE/Kubernete-tutorials-springboot$ kubectl apply -f deployment.yaml
 +deployment.apps/demo created
 +service/demo created
 +skip@desktop:/mnt/d/1PROJEKTE/Kubernete-tutorials-springboot$ kubectl get all
 +NAME                        READY   STATUS    RESTARTS   AGE
 +pod/demo-6f64658b59-swj5z   1/    Running            3s
 +
 +NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
 +service/demo         ClusterIP   10.97.44.9   <none>        8080/TCP   3s
 +service/kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP    26h
 +
 +NAME                   READY   UP-TO-DATE   AVAILABLE   AGE
 +deployment.apps/demo   1/               1           3s
 +
 +NAME                              DESIRED   CURRENT   READY   AGE
 +replicaset.apps/demo-6f64658b59                         3s
 +
 +</sxh>
 +
 +
 +Forwarding port 
 +
 +<sxh>
 +kubectl port-forward svc/demo 8080:8080
 +</sxh>
 +
 +
 +
 +kubectl: This is the command-line tool used to interact with a Kubernetes cluster.
 +
 +port-forward: This is a subcommand of kubectl specifically designed for forwarding ports from Pods or Services within the cluster to your local machine.
 +
 +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:8080/actuator/health
 +</sxh>
  
devops/docker/kubernetes/tutorial-springboot.1709673430.txt.gz · Last modified: by skipidar