Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

How to easily generate Helm charts using Dekorate

October 12, 2022
Jose Carvajal Hilario Charles Moulliard
Related topics:
HelmJavaKubernetes
Related products:
Red Hat OpenShift Container Platform

    Helm is the most popular package manager that finds, shares, and deploys software built for Kubernetes. It would be best if you packaged Java applications as Helm charts containing all of the necessary metadata and resource definitions to configure them for distribution through Helm. This article introduces the Dekorate Helm extension as an easier way to generate and maintain Helm chart resources.

    What are Helm charts?

    A Helm chart is a collection of files inside a directory. The following files are mandatory:

    • Chart.yaml: Chart metadata, such as name, version, and developers.
    • values.yaml: Default configuration values for the chart in YAML.
    • templates: A directory containing the list of resources that, combined with values.yaml, generate the application when the chart is installed. The resources are also specified in YAML.

    How to configure the Dekorate Helm extension

    Dekorate (starting with version 2.11) can generate the Helm chart resources for you. You should include the Dekorate Helm dependency in your POM file using the latest version of Dekorate from Maven Central as follows:

    <dependency>
      <groupId>io.dekorate</groupId>
      <artifactId>helm-annotations</artifactId>
      <version>{dekorate.version}</version>
    </dependency>
    

    Then, configure Helm via properties as follows:

    # This name property is mandatory to generate the Helm chart
    dekorate.helm.name=myChart
    # If the version is not provided, the application version will be used instead
    dekorate.helm.version=1.0.0-SNAPSHOT
    # The description property is optional
    dekorate.helm.description=Description of my Chart
    

    Alternatively, add the @HelmChart annotation to one of your Java source files:

    @HelmChart(name = "myChart", version = "1.0.0-SNAPSHOT", description = "Description of my Chart")
    @SpringBootApplication
    public class Main {
    
      public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
      }
    }
    

    Now you can generate the Helm resources using the Maven build command:

    $ mvn clean package
    

    The generated Helm chart will be in the target/classes/META-INF/dekorate/helm/<chart name>/ directory.

    Dekorate extensions determine which templates appear in the chart. For example, if your project uses the Kubernetes Dekorate extension, the Helm resources include the following files in the target/classes/META-INF/dekorate/helm/<chart name>/templates directory:

    • deployment.yaml
    • ingress.yaml
    • service.yaml

    How to use Helm

    Let's see how to use the previously generated Helm chart.

    First, make sure you have installed the Helm command-line interface (CLI) and logged into a Kubernetes cluster.

    Then run the following Maven command to generate the Helm artifacts:

    $ mvn clean package
    

    Finally, install the generated Helm chart into the cluster:

    $ helm install helm-example ./target/classes/META-INF/dekorate/helm/<chart name>
    

    The helm command waits until the chart is fully installed and the application is up and running.

    2 ways to update your deployment

    Method #1: Update deployment via the upgrade option of the Helm command line. After making changes to your project, regenerate the resources using this Maven command:

    $ mvn clean package
    

    Then upgrade your deployment:

    $ helm upgrade helm-example ./target/classes/META-INF/dekorate/helm/<chart name>
    

    Method #2: Update a deployment through the --set option of the helm upgrade command:

    $ helm upgrade helm-example ./target/classes/META-INF/dekorate/helm/<chart name> --set app.replicas=1
    

    The app.replicas option is a parameterized property mapped by the values.yaml file. We will explore this function more in the next section.

    To delete a deployment, enter:

    $ helm uninstall helm-example
    

    Mapping values using path expressions

    Helm allows mapping to set properties of your resources during or after chart installation. For instance, suppose your deployment template in the templates/deployment.yaml file looks like this:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: myModule
    spec:
      replicas: {{ .Values.app.replicas }}
    

    Use the helm command to set the number of replicas to use for installing the chart, as shown in the previous section:

    $ helm install helm-example ./target/classes/META-INF/dekorate/helm/<chart name> --set app.replicas=1
    

    Alternatively, set the number of the replicas in the values.yaml file, located in the chart's directory at target/classes/META-INF/dekorate/helm/<chart name>/values.yaml:

    app:
      replicas: 1
    

    The good news is that Dekorate also generates the Helm values.yaml file and automatically maps preconfigured properties, such as Kubernetes replicas or ingress host properties. The complete list of preconfigured properties is in the official Dekorate Helm site documentation.

    Let's try an example of configuring the replicas using the Dekorate Kubernetes dekorate.kubernetes.replicas property. This example will demonstrate how Dekorate Helm automatically maps it into the generated Helm chart.

    Set 3 replicas for your deployment:

    # Set replicas to 3
    dekorate.kubernetes.replicas=3
    

    The generated Helm values file at target/classes/META-INF/dekorate/helm/<chart name>/values.yaml contain the replicas value:

    ---
    app:
      replicas: 3
    

    Additionally, the deployment template file at target/classes/META-INF/dekorate/helm/<chart name>/templates/deployment.yaml will have a reference to this value.

    What if you want to map other properties that are not preconfigured? For example, mapping the value myModule that appears in the metadata.name property with the following deployment template file:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: myModule -- let's map this value!
    spec:
      replicas: {{ .Values.app.replicas }}
    

    You can configure Dekorate to map any properties in your resources using YAMLPath expressions. To continue with the preceding example, you need only add the following configuration to your properties:

    dekorate.helm.values[0].property=resource
    dekorate.helm.values[0].paths=metadata.name
    

    In the first line, property is the property name to be set. In the second line, paths is a list of YAMLPath expressions that identify the properties you want to use (metadata.name in the example).

    Using the properties just defined, the resulting Helm values file at target/classes/META-INF/dekorate/helm/<chart name>/values.yaml will include:

    app:
      resource: myModule
    

    The following is the deployment template resource at target/classes/META-INF/dekorate/helm/<chart name>/templates/deployment.yaml:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: {{ .Values.app.resource }}
    spec:
      replicas: {{ .Values.app.replicas }}
    

    YAMLPath expressions also support more complex scenarios. You can use the expressions to replace properties for a specific resource type or properties described as a key-value map. You can find all the supported features in the official site documentation.

    How to use Helm profiles

    All properties are, by default, mapped to the same Helm values.yaml file. However, Dekorate also supports the generation of other Helm values files.

    For example, let’s say you have two environments: one for testing and another for production. Each environment has a different ingress host that exposes your Kubernetes application. You can configure your application as follows:

    # Mapped to `values.yaml` by the preconfigured Ingress decorator
    dekorate.kubernetes.ingress.host=my-host
    
    # Overwrite the value of `dekorate.kubernetes.ingress.host` to `values-<profile-name>.yaml`:
    dekorate.helm.values[0].property=host
    dekorate.helm.values[0].paths=(kind == Ingress).spec.rules.host
    dekorate.helm.values[0].value=my-test-host
    ## `test` is the profile name.
    dekorate.helm.values[0].profile=test
    

    Dekorate Helm preconfigures the Ingress host property. Therefore, you will find the my-host value in the target/classes/META-INF/dekorate/helm/<chart name>/values.yaml file:

    app:
      host: my-host
    

    But because you are also using a profile named test in one of your properties, Dekorate generates a target/classes/META-INF/dekorate/helm/<chart name>/values-test.yaml file with this content:

    app:
      host: my-test-host
    

    When installing your chart in the test environment, you can use this values file in the following command:

    $ helm install -f ./target/classes/META-INF/dekorate/helm/<chart name>/values-test.yaml helm-example ./target/classes/META-INF/dekorate/helm/<chart name>
    

    Dekorate reduces the complexity of Helm chart generation

    Generating Helm charts can be a complex process. In this article, we demonstrated three Helm processes that illustrate how Dekorate simplifies Helm chart generation:

    1. How to easily generate Helm charts using Dekorate.

    2. How to map properties to be set when installing or updating your charts.

    3. How to use Helm profiles.

    Learn more about Helm charts in the official Helm documentation.

    Last updated: October 31, 2023

    Related Posts

    • Deploy a Java application using Helm, Part 1

    • Deploy a Java application using Helm, Part 2

    • How to use Dekorate to create Kubernetes manifests

    Recent Posts

    • What GPU kernels mean for your distributed inference

    • Debugging image mode with Red Hat OpenShift 4.20: A practical guide

    • EvalHub: Because "looks good to me" isn't a benchmark

    • SQL Server HA on RHEL: Meet Pacemaker HA Agent v2 (tech preview)

    • Deploy with confidence: Continuous integration and continuous delivery for agentic AI

    What’s up next?

    Find out how you can move your legacy Java application into a container and deploy it to Kubernetes in minutes using the Developer Sandbox for Red Hat OpenShift.

    Try Java in the sandbox
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.