ibm-open-liberty-spring
by Helm
Open Liberty, an open source runtime for Java microservices & cloud-native apps.
About this chart
Spring with Open Liberty Helm Chart
Introduction
Spring provides a popular programming model for developing cloud-native Java applications, and when powered by Open Liberty the stack becomes consistent with other enterprise Java workloads - performance, security and a single management plane. This Helm chart will help you deploy your shinny new Spring Boot application into Kubernetes with enterprise settings such as Ingress, Auto-scaling and Pod Security Policy!
Resources Required
System resources
- CPU Requested : 500m (500 millicpu)
- Memory Requested : 512Mi (~ 537 MB)
Storage
A persistent volume is required, if you plan on using the transaction service within Liberty. The server.xml Liberty configuration file must be configured to place the transaction log on this volume so that it persists, if the server fails and restarts.
Chart Details
- Installs one
DeploymentorStatefulSetrunning Open Liberty image - Installs a
Serviceand optionally anIngressto route traffic to Open Liberty server - Optionally persistence can be configured to retain server logs and transaction logs
Prerequisites
Open Liberty Docker image requirements
Open Liberty Docker images based on Universal Base Images (UBI), with tags springBoot1-ubi-min and springBoot2-ubi-min, are publicly available from Docker hub. Our Docker images for Ubuntu are also publicly available from our Docker Hub page, using the tags springBoot1 and springBoot2 depending on the version of Spring Boot your app depends on. Ensure your Kubernetes environment has set the image enforcement policy appropriately to allow access to those repositories. See Enforcing container image security for more information.
Within the Using springBoot images section, you’ll also learn how to achieve an optimized application image where the layer containing Spring libraries has been pushed between Open Liberty’s layer and your application’s layer – allowing for a much faster continuous development and build flow.
We have also pre-packaged the popular Spring Pet Clinic application as a sample that is ready to be used! You can check out how we built it or run it right away via docker run -d --name springApp -p 8080:9080 openliberty/samples:springPetClinic. Ensure your Kubernetes environment has set the image enforcement policy appropriately to allow access to the sample application.
The Helm chart requires the Docker image to have certain directories linked. The open-liberty image from Docker Hub will already have the expected links. If you are not using that image, either directly or as parent image, then you must add the following to your Dockerfile:
ENV PATH /opt/ol/wlp/bin:/opt/ol/docker/:$PATH
ENV LOG_DIR /logs
ENV WLP_OUTPUT_DIR /opt/ol/wlp/output
RUN mkdir -p /logs \
&& mkdir -p $WLP_OUTPUT_DIR/defaultServer \
&& ln -s $WLP_OUTPUT_DIR/defaultServer /output \
&& ln -s /opt/ol/wlp/usr/servers/defaultServer /config \
&& ln -s /logs $WLP_OUTPUT_DIR/defaultServer/logs
Configuration values related to HTTP, SSL, session caching and monitoring require the Liberty server to be configured appropriately at Docker image layer. See OpenLiberty/ci.docker for more information.
PodSecurityPolicy Requirements
This chart requires a PodSecurityPolicy to be bound to the target namespace prior to installation. Choose either a predefined PodSecurityPolicy or have your cluster administrator create a custom PodSecurityPolicy for you:
- Predefined PodSecurityPolicy name:
ibm-restricted-psp - Custom PodSecurityPolicy definition:
apiVersion: extensions/v1beta1
kind: PodSecurityPolicy
metadata:
name: ibm-open-liberty-spring-psp
spec:
allowPrivilegeEscalation: false
forbiddenSysctls:
- '*'
fsGroup:
ranges:
- max: 65535
min: 1
rule: MustRunAs
requiredDropCapabilities:
- ALL
runAsUser:
rule: MustRunAsNonRoot
seLinux:
rule: RunAsAny
supplementalGroups:
ranges:
- max: 65535
min: 1
rule: MustRunAs
volumes:
- configMap
- emptyDir
- projected
- secret
- downwardAPI
- persistentVolumeClaim
- Custom ClusterRole for the custom PodSecurityPolicy:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ibm-open-liberty-spring-clusterrole
rules:
- apiGroups:
- extensions
resourceNames:
- ibm-open-liberty-spring-psp
resources:
- podsecuritypolicies
verbs:
- use
Configuration scripts can be used to create the required resources
Download the following scripts located at /ibm_cloud_pak/pak_extensions/pre-install directory.
-
The pre-install instructions are located at
clusterAdministration/createSecurityClusterPrereqs.shfor cluster admins to create the PodSecurityPolicy and ClusterRole for all releases of this chart. -
The namespace scoped instructions are located at
namespaceAdministration/createSecurityNamespacePrereqs.shfor team admin/operator to create the RoleBinding for the namespace. This script takes one argument; the name of a pre-existing namespace where the chart will be installed.- Example usage:
./createSecurityNamespacePrereqs.sh myNamespace
- Example usage:
Configuration scripts can be used to clean up resources created
Download the following scripts located at /ibm_cloud_pak/pak_extensions/post-delete directory.
-
The post-delete instructions are located at
clusterAdministration/deleteSecurityClusterPrereqs.shfor cluster admins to delete the PodSecurityPolicy and ClusterRole for all releases of this chart. -
The namespace scoped instructions are located at
namespaceAdministration/deleteSecurityNamespacePrereqs.shfor team admin/operator to delete the RoleBinding for the namespace. This script takes one argument; the name of the namespace where the chart was installed.- Example usage:
./deleteSecurityNamespacePrereqs.sh myNamespace
- Example usage:
Red Hat OpenShift SecurityContextConstraints Requirements
This chart requires a SecurityContextConstraints to be bound to the target namespace prior to installation. To meet this requirement there may be cluster scoped as well as namespace scoped pre and post actions that need to occur.
The predefined SecurityContextConstraints name: ibm-restricted-scc has been verified for this chart, if your target namespace is bound to this SecurityContextConstraints resource you can proceed to install the chart.
Creating the required resources
This chart defines a custom SecurityContextConstraints which can be used to finely control the permissions/capabilities needed to deploy this chart. You can enable this custom SecurityContextConstraints resource using the supplied instructions or scripts in the pak_extensions/pre-install directory.
-
From the user interface, you can copy and paste the following snippets to enable the custom
SecurityContextConstraints- Custom
SecurityContextConstraintsdefinition:
apiVersion: security.openshift.io/v1 kind: SecurityContextConstraints metadata: annotations: name: ibm-open-liberty-spring-scc allowHostDirVolumePlugin: false allowHostIPC: false allowHostNetwork: false allowHostPID: false allowHostPorts: false allowPrivilegedContainer: false allowedCapabilities: [] allowedFlexVolumes: [] defaultAddCapabilities: [] fsGroup: type: MustRunAs ranges: - max: 65535 min: 1 readOnlyRootFilesystem: false requiredDropCapabilities: - ALL runAsUser: type: MustRunAsNonRoot seccompProfiles: - docker/default seLinuxContext: type: RunAsAny supplementalGroups: type: MustRunAs ranges: - max: 65535 min: 1 volumes: - configMap - downwardAPI - emptyDir - persistentVolumeClaim - projected - secret priority: 0 - Custom
-
From the command line, you can run the setup scripts included under
pak_extensions/pre-installAs a cluster admin the pre-install instructions are located at:pre-install/clusterAdministration/createSecurityClusterPrereqs.sh
As team admin the namespace scoped instructions are located at:
pre-install/namespaceAdministration/createSecurityNamespacePrereqs.sh
Limitations
See RELEASENOTES.md
Installing the Chart
The Helm chart can also be installed using the Helm command-line interface (CLI). The default parameter values specified in values.yaml can be overridden by using --set name=value.
For example, to deploy the sample Spring Pet Clinic application run the following commands:
helm repo add ibm-charts https://raw.githubusercontent.com/IBM/charts/master/repo/stable/helm install --name my-release --set image.repository=openliberty/samples --set image.tag=springPetClinic ibm-charts/ibm-open-liberty-spring --tls
To get the application URL, run the commands provided in the NOTES section from the output of running above commands.
Resource constraints can be enabled using resources.constraints.enabled parameter. Required resource can be configured using resources.requests.cpu and resources.requests.memory parameters. Resource limits can be configured using resources.limits.cpu and resources.limits.memory parameters. Review the default values specified by the chart and adjust according to your needs. It is recommended not to use Xmx or Xms. Use –XX:MaxRAMPercentage and –XX:InitialRAMPercentage for any fine tuning, such as if there are other processes set to run in the same container.
Verifying the Chart
See the instruction after the helm installation completes for chart verification. The instruction can also be displayed by viewing the installed helm release under Menu -> Workloads -> Helm Releases or by running the command: helm status my-release --tls
Uninstalling the Chart
To uninstall/delete the my-release deployment:
helm delete my-release --purge --tls
This command removes all the Kubernetes components associated with the chart, except any persistent volume claims (PVCs) which is created when logs.persistLogs or logs.persistTransactionLogs is set to true. This is the default behavior of Kubernetes, and ensures that valuable data is not deleted. In order to delete the server data, you can delete the PVC using the following command:
kubectl delete pvc my-pvc
Note: You can use kubectl get pvc to see the list of available PVCs.
Configuration
| Qualifier | Parameter | Definition | Allowed Value |
|---|---|---|---|
image | pullPolicy | Image Pull Policy | Always, Never, or IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. See Kubernetes - Updating Images |
repository | Name of image, including repository prefix (if required). | See Docker - Extended tag description | |
tag | Docker image tag. | See Docker - Tag | |
pullSecret | Image pull secret, if using a Docker registry that requires credentials. | See Kubernetes - ImagePullSecrets | |
readinessProbe | Configure when container is ready to start accepting traffic. Use this to override the default readiness probe configuration. See Configure Liveness and Readiness Probes for more information. | YAML object of readiness probe | |
livenessProbe | Configure when to restart container. Use this to override the default liveness probe configuration. See Configure Liveness and Readiness Probes for more information. | YAML object of liveness probe | |
extraEnvs | Extra environment variables for the image. | YAML array of environment variables | |
lifecycle | Handlers for the PostStart and PreStop lifecycle events of container. | YAML object of lifecycle handlers | |
serverOverridesConfigMapName | Name of the ConfigMap that contains server configuration overrides (within key 'server-overrides.xml') to configure your Liberty server at deployment. | Name of ConfigMap | |
extraVolumeMounts | Additional volumeMounts for server pods | YAML array of volumeMounts definitions | |
security | Configure the security attributes of the image | YAML object of security attributes | |
resourceNameOverride | This name will be appended to the release name to form the name of resources created by the chart. By default, this is set to the chart name. | ||
deployment | annotations | Additional annotations to be added to Deployment (or StatefulSet if persistence is enabled) | YAML object of annotations |
labels | Additional labels to be added to Deployment (or StatefulSet if persistence is enabled) | YAML object of labels | |
pod | annotations | Additio |
Deploy ibm-open-liberty-spring with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has ibm-open-liberty-spring on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartibm-open-liberty-spring is pinned at v1.10.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply