Skip to content

Commit

Permalink
Merge pull request #27 from opensrp/feature/update_hapi_version
Browse files Browse the repository at this point in the history
Feature/update hapi version
  • Loading branch information
dubdabasoduba authored Jan 31, 2022
2 parents cb73fe2 + 123a55e commit f0047f2
Show file tree
Hide file tree
Showing 19 changed files with 289 additions and 192 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/chart-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ jobs:
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.7.0

- name: Add bitnami repo
run: helm repo add bitnami https://charts.bitnami.com/bitnami

Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/chart-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ jobs:
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.7.0

- name: Set up chart-testing
uses: helm/[email protected]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ using the `gcr.io/distroless/java-debian10:11` base image:
docker build --target=release-distroless -t hapi-fhir:distroless .
```

Note that distroless images are also automatically build and pushed to the container registry,
Note that distroless images are also automatically built and pushed to the container registry,
see the `-distroless` suffix in the image tags.

## Adding custom operations
Expand Down
9 changes: 6 additions & 3 deletions charts/hapi-fhir-jpaserver/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ annotations:
# added, changed, deprecated, removed, fixed, and security.
- kind: changed
description: |
updated HAPI FHIR starter image to 5.5.1
appVersion: v5.5.1
version: 0.6.0
updated HAPI FHIR starter image to 5.6.0
- kind: added
description: |
added support for configuring PodDisruptionBudget for the server pods
appVersion: v5.6.0
version: 0.7.0
31 changes: 25 additions & 6 deletions charts/hapi-fhir-jpaserver/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HAPI FHIR JPA Server Starter Helm Chart

![Version: 0.6.0](https://img.shields.io/badge/Version-0.6.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v5.5.1](https://img.shields.io/badge/AppVersion-v5.5.1-informational?style=flat-square)
![Version: 0.7.0](https://img.shields.io/badge/Version-0.7.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v5.6.0](https://img.shields.io/badge/AppVersion-v5.6.0-informational?style=flat-square)

This helm chart will help you install the HAPI FHIR JPA Server in a Kubernetes environment.

Expand All @@ -11,6 +11,9 @@ helm repo add hapifhir https://hapifhir.github.io/hapi-fhir-jpaserver-starter/
helm install --render-subchart-notes hapi-fhir-jpaserver hapifhir/hapi-fhir-jpaserver
```

> ⚠ By default, the included [PostgreSQL Helm chart](https://github.com/bitnami/charts/tree/master/bitnami/postgresql#upgrading)
> auto-generates a random password for the database which may cause problems when upgrading the chart (see [here for details](https://github.com/bitnami/charts/tree/master/bitnami/postgresql#upgrading)).
## Values

| Key | Type | Default | Description |
Expand All @@ -24,11 +27,12 @@ helm install --render-subchart-notes hapi-fhir-jpaserver hapifhir/hapi-fhir-jpas
| externalDatabase.password | string | `""` | database password |
| externalDatabase.port | int | `5432` | database port number |
| externalDatabase.user | string | `"fhir"` | username for the external database |
| extraEnv | list | `[]` | extra environment variables to set on the server container |
| fullnameOverride | string | `""` | override the chart fullname |
| image.flavor | string | `"distroless"` | the flavor or variant of the image to use. appended to the image tag by `-`. |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.registry | string | `"docker.io"` | |
| image.repository | string | `"hapiproject/hapi"` | |
| image.pullPolicy | string | `"IfNotPresent"` | image pullPolicy to use |
| image.registry | string | `"docker.io"` | registry where the HAPI FHIR server image is hosted |
| image.repository | string | `"hapiproject/hapi"` | the path inside the repository |
| image.tag | string | `""` | defaults to `Chart.appVersion` |
| imagePullSecrets | list | `[]` | image pull secrets to use when pulling the image |
| ingress.annotations | object | `{}` | provide any additional annotations which may be required. Evaluated as a template. |
Expand All @@ -43,6 +47,9 @@ helm install --render-subchart-notes hapi-fhir-jpaserver hapifhir/hapi-fhir-jpas
| networkPolicy.explicitNamespacesSelector | object | `{}` | a Kubernetes LabelSelector to explicitly select namespaces from which ingress traffic could be allowed |
| nodeSelector | object | `{}` | node selector for the pod |
| podAnnotations | object | `{}` | annotations applied to the server pod |
| podDisruptionBudget.enabled | bool | `false` | Enable PodDisruptionBudget for the server pods. uses policy/v1/PodDisruptionBudget thus requiring k8s 1.21+ |
| podDisruptionBudget.maxUnavailable | string | `""` | maximum unavailable instances |
| podDisruptionBudget.minAvailable | int | `1` | minimum available instances |
| podSecurityContext | object | `{}` | pod security context |
| postgresql.containerSecurityContext.allowPrivilegeEscalation | bool | `false` | |
| postgresql.containerSecurityContext.capabilities.drop[0] | string | `"ALL"` | |
Expand All @@ -61,14 +68,26 @@ helm install --render-subchart-notes hapi-fhir-jpaserver hapifhir/hapi-fhir-jpas
| securityContext.readOnlyRootFilesystem | bool | `true` | |
| securityContext.runAsNonRoot | bool | `true` | |
| securityContext.runAsUser | int | `65532` | |
| service.port | int | `8080` | |
| service.type | string | `"ClusterIP"` | |
| service.port | int | `8080` | port where the server will be exposed at |
| service.type | string | `"ClusterIP"` | service type |
| startupProbe.failureThreshold | int | `10` | |
| startupProbe.initialDelaySeconds | int | `60` | |
| startupProbe.periodSeconds | int | `30` | |
| startupProbe.successThreshold | int | `1` | |
| startupProbe.timeoutSeconds | int | `30` | |
| tolerations | list | `[]` | pod tolerations |

## Development

To update the Helm chart when a new version of the `hapiproject/hapi` image is released, the [Chart.yaml](Chart.yaml)'s
`appVersion` and `version` fields need to be updated accordingly. Afterwards, re-generate the [README.md](README.md)
by running:

```sh
$ helm-docs
INFO[2021-11-20T12:38:04Z] Found Chart directories [charts/hapi-fhir-jpaserver]
INFO[2021-11-20T12:38:04Z] Generating README Documentation for chart /usr/src/app/charts/hapi-fhir-jpaserver
```

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0)
15 changes: 15 additions & 0 deletions charts/hapi-fhir-jpaserver/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ helm repo add hapifhir https://hapifhir.github.io/hapi-fhir-jpaserver-starter/
helm install --render-subchart-notes hapi-fhir-jpaserver hapifhir/hapi-fhir-jpaserver
```

> ⚠ By default, the included [PostgreSQL Helm chart](https://github.com/bitnami/charts/tree/master/bitnami/postgresql#upgrading)
> auto-generates a random password for the database which may cause problems when upgrading the chart (see [here for details](https://github.com/bitnami/charts/tree/master/bitnami/postgresql#upgrading)).

{{ template "chart.valuesSection" . }}

## Development

To update the Helm chart when a new version of the `hapiproject/hapi` image is released, the [Chart.yaml](Chart.yaml)'s
`appVersion` and `version` fields need to be updated accordingly. Afterwards, re-generate the [README.md](README.md)
by running:

```sh
$ helm-docs
INFO[2021-11-20T12:38:04Z] Found Chart directories [charts/hapi-fhir-jpaserver]
INFO[2021-11-20T12:38:04Z] Generating README Documentation for chart /usr/src/app/charts/hapi-fhir-jpaserver
```

{{ template "helm-docs.versionFooter" . }}
18 changes: 18 additions & 0 deletions charts/hapi-fhir-jpaserver/templates/poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.podDisruptionBudget.enabled }}
kind: PodDisruptionBudget
apiVersion: policy/v1
metadata:
name: {{ include "hapi-fhir-jpaserver.fullname" . }}
labels:
{{- include "hapi-fhir-jpaserver.labels" . | nindent 4 }}
spec:
{{- if .Values.podDisruptionBudget.minAvailable }}
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
{{- end }}
{{- if .Values.podDisruptionBudget.maxUnavailable }}
maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
{{- end }}
selector:
matchLabels:
{{- include "hapi-fhir-jpaserver.selectorLabels" . | nindent 6 }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/hapi-fhir-jpaserver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
replicaCount: 1

image:
# -- registry where the HAPI FHIR server image is hosted
registry: docker.io
# -- the path inside the repository
repository: hapiproject/hapi
# -- defaults to `Chart.appVersion`
tag: ""
# -- the flavor or variant of the image to use.
# appended to the image tag by `-`.
flavor: "distroless"
# -- image pullPolicy to use
pullPolicy: IfNotPresent

# -- image pull secrets to use when pulling the image
Expand Down Expand Up @@ -42,7 +45,9 @@ securityContext:

# service to expose the server
service:
# -- service type
type: ClusterIP
# -- port where the server will be exposed at
port: 8080

ingress:
Expand Down Expand Up @@ -157,3 +162,18 @@ networkPolicy:
# matchLabels:
# app.kubernetes.io/name: {{ $.Release.Name }}
allowedFrom: []

# -- extra environment variables to set on the server container
extraEnv:
[]
# - name: SPRING_FLYWAY_BASELINE_ON_MIGRATE
# value: "true"

podDisruptionBudget:
# -- Enable PodDisruptionBudget for the server pods.
# uses policy/v1/PodDisruptionBudget thus requiring k8s 1.21+
enabled: false
# -- minimum available instances
minAvailable: 1
# -- maximum unavailable instances
maxUnavailable: ""
14 changes: 11 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>5.5.1</version>
<version>5.6.0</version>
</parent>

<artifactId>hapi-fhir-jpaserver-starter</artifactId>
<groupId>org.smartregister</groupId>
<version>5.5.3-SNAPSHOT</version>
<version>5.6.0-SNAPSHOT</version>

<properties>
<java.version>8</java.version>
<hapi.fhir.version>5.5.1</hapi.fhir.version>
<hapi.fhir.version>5.6.0</hapi.fhir.version>
<spring_boot_version>2.5.6</spring_boot_version>
</properties>

<prerequisites>
Expand Down Expand Up @@ -72,6 +73,7 @@
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
<exclusions>
<exclusion>
<groupId>javax.activation</groupId>
Expand Down Expand Up @@ -115,6 +117,12 @@
<artifactId>hapi-fhir-jpaserver-mdm</artifactId>
<version>${hapi.fhir.version}</version>
</dependency>
<!-- This dependency includes the OpenAPI Server -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-server-openapi</artifactId>
<version>${hapi.fhir.version}</version>
</dependency>
<!-- This dependency is used for the "FHIR Tester" web app overlay -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
public class AppProperties {

private Boolean cql_enabled = false;
private Boolean openapi_enabled = false;
private Boolean mdm_enabled = false;
private Boolean allow_cascading_deletes = false;
private Boolean allow_contains_searches = true;
Expand Down Expand Up @@ -75,6 +76,14 @@ public class AppProperties {
private Boolean use_apache_address_strategy = false;
private Boolean use_apache_address_strategy_https = false;

public Boolean getOpenapi_enabled() {
return openapi_enabled;
}

public void setOpenapi_enabled(Boolean openapi_enabled) {
this.openapi_enabled = openapi_enabled;
}

public Boolean getUse_apache_address_strategy() {
return use_apache_address_strategy;
}
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/ca/uhn/fhir/jpa/starter/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ public class Application extends SpringBootServletInitializer {

public static void main(String[] args) {

/*
* https://github.com/hapifhir/hapi-fhir-jpaserver-starter/issues/246
* This will be allowed for a short period until we know how MDM should be configured
* or don't have multiple equal bean instantiations.
*
* This will require changes in the main project as stated in the Github comment
* */
System.setProperty("spring.main.allow-bean-definition-overriding","true");

System.setProperty("spring.batch.job.enabled", "false");
SpringApplication.run(Application.class, args);

//Server is now accessible at eg. http://localhost:8080/fhir/metadata
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/ca/uhn/fhir/jpa/starter/BaseJpaRestfulServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider;
import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider;
import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3;
import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor;
import ca.uhn.fhir.mdm.provider.MdmProviderLoader;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.narrative2.NullNarrativeGenerator;
import ca.uhn.fhir.rest.openapi.OpenApiInterceptor;
import ca.uhn.fhir.rest.server.ApacheProxyAddressStrategy;
import ca.uhn.fhir.rest.server.ETagSupportEnum;
import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
Expand Down Expand Up @@ -91,6 +93,8 @@ public class BaseJpaRestfulServer extends RestfulServer {
@Autowired
PartitionManagementProvider partitionManagementProvider;
@Autowired
ValueSetOperationProvider valueSetOperationProvider;
@Autowired
BinaryStorageInterceptor binaryStorageInterceptor;
@Autowired
IPackageInstallerSvc packageInstallerSvc;
Expand Down Expand Up @@ -357,11 +361,18 @@ protected void initialize() throws ServletException {

daoConfig.setDeferIndexingForCodesystemsOfSize(appProperties.getDefer_indexing_for_codesystems_of_size());

if (appProperties.getOpenapi_enabled()) {
registerInterceptor(new OpenApiInterceptor());
}

// Bulk Export
if (appProperties.getBulk_export_enabled()) {
registerProvider(bulkDataExportProvider);
}

// valueSet Operations i.e $expand
registerProvider(valueSetOperationProvider);

// Partitioning
if (appProperties.getPartitioning() != null) {
registerInterceptor(new RequestTenantPartitionInterceptor());
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/ca/uhn/fhir/jpa/starter/EnvironmentHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.hibernate.search.mapper.orm.automaticindexing.session.AutomaticIndexingSynchronizationStrategyNames;
import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy;
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
import org.springframework.core.env.CompositePropertySource;
Expand All @@ -25,7 +26,8 @@

public class EnvironmentHelper {

public static Properties getHibernateProperties(ConfigurableEnvironment environment) {
public static Properties getHibernateProperties(ConfigurableEnvironment environment,
ConfigurableListableBeanFactory myConfigurableListableBeanFactory) {
Properties properties = new Properties();
Map<String, Object> jpaProps = getPropertiesStartingWith(environment, "spring.jpa.properties");
for (Map.Entry<String, Object> entry : jpaProps.entrySet()) {
Expand All @@ -41,7 +43,7 @@ public static Properties getHibernateProperties(ConfigurableEnvironment environm
//properties.putIfAbsent(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory));

//hapi-fhir-jpaserver-base "sensible defaults"
Map<String, Object> hapiJpaPropertyMap = new HapiFhirLocalContainerEntityManagerFactoryBean().getJpaPropertyMap();
Map<String, Object> hapiJpaPropertyMap = new HapiFhirLocalContainerEntityManagerFactoryBean(myConfigurableListableBeanFactory).getJpaPropertyMap();
hapiJpaPropertyMap.forEach(properties::putIfAbsent);

//hapi-fhir-jpaserver-starter defaults
Expand Down Expand Up @@ -73,7 +75,7 @@ public static Properties getHibernateProperties(ConfigurableEnvironment environm
ElasticsearchHibernatePropertiesBuilder builder = new ElasticsearchHibernatePropertiesBuilder();
IndexStatus requiredIndexStatus = environment.getProperty("elasticsearch.required_index_status", IndexStatus.class);
builder.setRequiredIndexStatus(requireNonNullElse(requiredIndexStatus, IndexStatus.YELLOW));
builder.setRestUrl(getElasticsearchServerUrl(environment));
builder.setHosts(getElasticsearchServerUrl(environment));
builder.setUsername(getElasticsearchServerUsername(environment));
builder.setPassword(getElasticsearchServerPassword(environment));
builder.setProtocol(getElasticsearchServerProtocol(environment));
Expand Down
Loading

0 comments on commit f0047f2

Please sign in to comment.