Kubernetes Maven Sample
This example will show how to deploy a Java application to a Kubernetes cluster using Maven. It requires to run a Couchbase server that can be easily started on AWS or using Docker.
Main Targets
-
package
: Builds the WAR file -
install
: Builds the WAR and Docker image using it -
exec:java
: Runs the application with a Couchbase server running onlocalhost
-
fabric8:apply
: Deploys the application to Kubernetes, requireinstall
target to be invoked first-
By default, the Kubernetes cluster is
localhost
. Set KUBERNETES_MASTER environment variable to point to Kubernetes master.
-
Additional Targets
-
fabric8:build
: Builds the Docker image and generated Kubernetes resources -
fabric8:resource
: Generates the Kubernetes configuration file intarget/classes/META-INF/fabric8
directory -
fabric8:cluster-start
: Bootstrap a Kubernetes cluster using minikube (download, install and run)
More content on deploying your Java applications with Kubernetes at https://github.com/arun-gupta/kubernetes-java-sample/.