ARTIFACTORY: Use custom JDK for Artifactory in Helm installation under Kubernetes cluster

Jayanth Suresh
2023-01-22 11:07

In this article, we are covering a use case of using custom JDK for Artifactory which is running on a Kubernetes cluster using Helm installation. 

By default, Artifactory comes with build JDK but however in a few organizations there will be constraints of using a certain version of JDK which is approved by the security team. So, in that case, this article will be helpful.  

Artifactory 7.x supports JDK 11+, but from Artifactory version 7.46.x and above JDK 17+ is supported (Mandatory) and even the custom JDK should be JDK 17+ for  Artifactory version 7.46.x and above.

Below are the steps to be followed to use custom JDK for Artifactory in Helm installation under Kubernetes cluster:
The below example steps were tested on Artifactory version 7.46.x with custom java (Open JDK 17.0.5).

1.  Take a backup of the current values YAML file which was used for Artifactory deployment as we need to modify that file.
 2.  Add the below commands in the preStartCommand section of the values YAML file to configure custom java (Open JDK 17.0.5). Note that the below command will create a directory for custom java, download the custom java archive file, unarchive it to the custom java directory and remove the archive file. 
artifactory:
 preStartCommand: "mkdir -p /opt/jfrog/artifactory/var/custom-java/; cd /opt/jfrog/artifactory/var/custom-java/ && curl https://download.oracle.com/java/17/archive/jdk-17.0.5_linux-x64_bin.tar.gz -O && tar -xvf jdk-17.0.5_linux-x64_bin.tar.gz && rm -f jdk-17.0.5_linux-x64_bin.tar.gz"

 

3.  Add the custom java home path in the system.yaml file, If you have a secret for system YAML file then you can add java_home in it. In the below example, we are adding in the values YAML file.
artifactory:
 preStartCommand: "mkdir -p /opt/jfrog/artifactory/var/custom-java/; cd /opt/jfrog/artifactory/var/custom-java/ && curl https://download.oracle.com/java/17/archive/jdk-17.0.5_linux-x64_bin.tar.gz -O && tar -xvf jdk-17.0.5_linux-x64_bin.tar.gz && rm -f jdk-17.0.5_linux-x64_bin.tar.gz"
 systemYaml: |
   shared:
     javaHome: "/opt/jfrog/artifactory/var/custom-java/jdk-17.0.5"

Once the custom java is configured and integrated with Artifactory, then we can check whether the custom java is being used by Artifactory process with ps -ef | grep -i Artifactory command 

User-added image