Using detached applications#

All the other samples use an application that is deployed inside of an instance. However, you can also deploy an application detached from the instance as a solo chart.

The reason for this is, that you

  • can update the instance without running the application update
  • update the application without touching the instance
  • have multiple applications deployed within one instance

There are two major things you need to do:

  1. make sure the application charts sets the instance name of the instance, it should connect to
  2. take the default values of the application match the ones it would get by an instance deployment

This is a sample: (find the complete one in the application.yaml)

nameOverride: SBS
docAreas:
  - id: "SBS"
    name: "DocArea with SBS"
    description: "This is a sample DocArea with the SBS Apps installed"
    apps:
    ...

instance:
  # this is the name of the instance, it should belong to
  name: "sample-detached"

# make sure it can wait for the nappl of the instance to be ready, before it deploys.
waitImage:
  repo: git.42i.org/nplus
  name: toolbox2
  tag: 1.2.1300
  pullPolicy: IfNotPresent
waitFor:
  - "-service {{ .component.prefix }}nappl.{{ .Release.Namespace }}.svc.cluster.local:{{ .this.nappl.port }} -timeout 1800"

# Now we define where and what to deploy 
nappl:
  host: "{{ .component.prefix }}nappl.{{ .Release.Namespace }}"
  port: 8080
  ssl: false
  instance: "nscalealinst1"
  account: admin
  domain: nscale
  password: admin
  secret:
nstl:
  host: "{{ .component.prefix }}nstl.{{ .Release.Namespace }}"
rs:
  host: "{{ .component.prefix }}rs.{{ .Release.Namespace }}"

Files#

Download all files of this sample

application.yaml#

nameOverride: SBS
docAreas:
  - id: "SBS"
    name: "DocArea with SBS"
    description: "This is a sample DocArea with the SBS Apps installed"
    apps:
    - "/pool/nstore/bl-app-9.0.1202.zip"
    - "/pool/nstore/gdpr-app-9.0.1302.zip"
    - "/pool/nstore/sbs-base-9.0.1302.zip"
    - "/pool/nstore/sbs-app-9.0.1302.zip"
    - "/pool/nstore/tmpl-app-9.0.1302.zip"
    - "/pool/nstore/cm-base-9.0.1302.zip"
    - "/pool/nstore/cm-app-9.0.1302.zip"
    - "/pool/nstore/hr-base-9.0.1302.zip"
    - "/pool/nstore/hr-app-9.0.1302.zip"
    - "/pool/nstore/pm-base-9.0.1302.zip"
    - "/pool/nstore/pm-app-9.0.1302.zip"
    - "/pool/nstore/sd-base-9.0.1302.zip"
    - "/pool/nstore/sd-app-9.0.1302.zip"
    - "/pool/nstore/kon-app-9.0.1302.zip"
    - "/pool/nstore/kal-app-9.0.1302.zip"
    - "/pool/nstore/dok-app-9.0.1302.zip"
    - "/pool/nstore/ts-base-9.0.1302.zip"
    - "/pool/nstore/ts-app-9.0.1302.zip"
    - "/pool/nstore/ocr-base-9.0.1302.zip"

resources:
  requests:
    cpu: "10m"
    memory: "512Mi"
  limits:
    cpu: "4000m"
    memory: "2Gi"

instance:
  name: "sample-detached"
waitImage:
  repo: git.42i.org/nplus
  name: toolbox2
  tag: 1.2.1300
  pullPolicy: IfNotPresent
nappl:
  host: "{{ .component.prefix }}nappl.{{ .Release.Namespace }}"
  port: 8080
  ssl: false
  instance: "nscalealinst1"
  account: admin
  domain: nscale
  password: admin
  secret:
waitFor:
  - "-service {{ .component.prefix }}nappl.{{ .Release.Namespace }}.svc.cluster.local:{{ .this.nappl.port }} -timeout 1800"
nstl:
  host: "{{ .component.prefix }}nstl.{{ .Release.Namespace }}"
rs:
  host: "{{ .component.prefix }}rs.{{ .Release.Namespace }}"

build.sh#

#!/bin/bash
#
# This sample script builds the example as described. It is also used to build the test environment in our lab,
# so it should be well tested.
#

# Make sure it fails immediately, if anything goes wrong
set -e

# -- ENVironment variables:
# CHARTS: The path to the source code
# DEST: The path to the build destination
# SAMPLE: The directory of the sample
# NAME: The name of the sample, used as the .Release.Name
# KUBE_CONTEXT: The name of the kube context, used to build this sample depending on where you run it against. You might have different Environments such as lab, dev, qa, prod, demo, local, ...

# Check, if we have the source code available
if [ ! -d "$CHARTS" ]; then
    echo "ERROR Building $SAMPLE example: The Charts Sources folder is not set. Please make sure to run this script with the full Source Code available"
    exit 1
fi
if [ ! -d "$DEST" ]; then
    echo "ERROR Building $SAMPLE example: DEST folder not found."
    exit 1
fi
if [ ! -d "$CHARTS/instance" ]; then
    echo "ERROR Building $SAMPLE example: Chart Sources in $CHARTS/instance not found. Are you running this script as a subscriber?"
    exit 1
fi

# Set the Variables
SAMPLE="detached"
NAME="sample-$SAMPLE"

# Output what is happening
echo "Building $NAME"

# Create the manifest
mkdir -p $DEST/instance
helm template --debug \
     --values $SAMPLES/environment/$KUBE_CONTEXT.yaml \
     --values $SAMPLES/resources/$KUBE_CONTEXT.yaml \
     $NAME $CHARTS/instance > $DEST/instance/$SAMPLE.yaml

mkdir -p $DEST/application
helm template --debug \
     --values $SAMPLES/environment/$KUBE_CONTEXT.yaml \
     --values $SAMPLES/detached/application.yaml \
     $NAME-app $CHARTS/application > $DEST/application/$SAMPLE.yaml