Example SpringBoot app tutorial to deploy to Kubernetes cluster using kind.
Tutorial to build & run java app locally ---> containerize the image and push to JFrog Artifactory --> create identity key on JFrog --> Install and start kind
cluster ---> create a namespace --> create artifactory secret in kubernetes --> create a deployment ---> check pods
- java 18.0
- maven
- docker
- kind
- jfrog artifactory account
- kubectl
-
clone Repo
-
cd into the directory
-
build SpringBoot maven app using following command
./mvnw clean package
-
run the app locally to test if its working
./mvnw SpringBoot:run
-
create a Docker image of the app locally using the
Dockerfile
docker build -t spring-boot-app:latest .
-
check if image was created
docker images
-
run the image locally and test if it works
docker run --publish 8080:8080 spring-boot-app
-
tag the image
docker build -t swagger-java-app:latest .
-
push the image to your private artifactory
docker push <YOUR_HOST>.jfrog.io/default-docker-local/spring-boot-app:latest
-
run the kind cluster locally
kind create cluster
-
create a namespace
kubectl apply -f resources/namespace.yaml
-
create a secret of artifactory
kubectl create secret docker-registry regcred --docker-server=<YOUR_HOST>.jfrog.io --docker-username=<USER_NAME> --docker-password=<IDENTITY_TOKEN> --docker-email=<EMAIL_ADDRESS>
-
patch default service account
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "regcred"}]}'
-
create deployment
kubectl apply -f resources/deployment.yaml
-
check status
kubectl get deployments kubectl get pods