Skip to content
Kubernetes Maven Plugin
Java Groovy
Branch: master
Clone or download
Pull request Compare This branch is 3 commits behind deanjameseverett:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Kubernetes Maven Plugin

Version 1.0.5

This is a maven plugin that can be installed locally and on the central artifactory repo.

The aim of this plugin is to allow developers and automation developers to build and deploy docker images to kubernetes



If not using 'startMinikube' goal directly, make sure minikube is running and you have exported the minikube environment

minikube start	
eval $(minikube docker-env)

Installation to Local repo

mvn clean install

Otherwise it will be pulled from artefactory when you add it to your maven pom.xml


For each maven project add the plugin (you might want to do this in a profile) Example below will delete and build the docker image. And then redeploy to kubernetes


Command line Execution

mvn k8:buildImage
mvn k8:deleteImage
mvn k8:deploy
mvn k8:undeploy
mvn k8:apply
mvn k8:startMinikube
mvn k8:stopMinikube

How to structure you project

Docker files.

You can add your Docker file, and any other text based files you want to use in a directory:


The default directory is src/main/docker/, however you can define your own:


Kubernetes files

You can add your Kubernetes files in a directory:


The default directory is src/main/k8/, however you can define your own:


You can specify any Kubernetes descriptor when using 'apply' goal:


Alternatively, you can specify any of the supported types of Kubernetes descriptors when using 'deploy' and 'undeploy' goals. The specific types which are currently supported are:


You can also add config map files under a folder config in the Kubernetes directory


Variables in your configuraion files

All files in the Docker and Kubernetes folders has access to maven variables. Example src/main/docker/Dockerfile

FROM airhacks/wildfly
MAINTAINER Phillip Kruger,
ENV DEPLOYMENT_DIR ${WILDFLY_HOME}/standalone/deployments/
RUN rm ${WILDFLY_HOME}/bin/standalone.conf
ADD standalone.conf ${WILDFLY_HOME}/bin/
ADD ${DEPLOYMENT_DIR} and @project.packaging@ is defined in pom.xml

Plugin configuration

In most cases you can just use the default values, however if you need to you can set them as plugin configurations:

  • target (default to ${})
  • encoding (default to ${})
  • artefactName (default to ${})
  • artefactType (default to ${project.packaging})
  • imageName (default to ${project.artifactId})
  • imageVersion (default to ${project.version})
  • dockerConfDir (default to ${project.basedir}/src/main/docker)
  • dockerFileName (default to Dockerfile)
  • kubernetesConfDir (default to ${project.basedir}/src/main/k8)
  • persistenceFileName (default to persistence.yml)
  • claimFileName (default to claim.yml)
  • deploymentFileName (default to deployment.yml)
  • serviceFileName (default to service.yml)
  • dockerRegistry (default to ${})
  • insecureRegistry (used with 'startMinikube' goal, ignored if not specified)
  • memory (used with 'startMinikube' goal, ignored if not specified)
  • cpus (used with 'startMinikube' goal, ignored if not specified)

You can also explicitly define the files that should be included: (The default is all files in the folder)


(above will only copy the specified files,standalone.conf and somefile.txt)

You can also add to the existing do not filter list (file type that we do not do pom variable replacement, usually non text based files) (The current default is deb, rpm, tar, gz, tar.gz, zip, war, ear, jar, rar)


(above will add all doc and conf files to the ignore list, so no filter on those)

You can’t perform that action at this time.