ibm-nodejs-loopback

by Helm

Helm chartv1.0.0App 1.0.0Apache-2.0

Helm chart for deploying LoopBack Application.

About this chart

IBM-Nodejs-LoopBack Helm Chart

Encapsulates Helm chart and other cloud pak artifacts for a Node.js LoopBack application.

Introduction

Node.js is an open source runtime build on the V8 JavaScript Engine. LoopBack is an open source server-side web framework written in Node.js.

Resources Required

Minimum resources required will be dependant on your application.

Chart Details

This chart will install the following:

Prerequisites

You will need to provide your own Node.js LoopBack application. This chart does not include an application image of its own.

If you prefer to install from the command prompt, you will need:

  • The cloudctl, kubectl and helm commands available.
  • Your environment configured to connect to the target cluster.

The installation environment has the following prerequisites:

  • Kubernetes version >=1.9.1.

PodSecurityPolicy Requirements

This chart requires a PodSecurityPolicy 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 PodSecurityPolicy name: ibm-anyuid-psp has been verified for this chart, if your target namespace is bound to this PodSecurityPolicy you can proceed to install the chart.

This chart also defines a custom PodSecurityPolicy which can be used to finely control the permissions/capabilities needed to deploy this chart. You can enable this custom PodSecurityPolicy using the ICP user interface or the supplied instructions/scripts in the pak_extension pre-install directory.

  • From the user interface, you can copy and paste the following snippets to enable the custom PodSecurityPolicy

    • Custom PodSecurityPolicy definition:
      apiVersion: extensions/v1beta1
      kind: PodSecurityPolicy
      metadata:
        name: ibm-nodejs-loopback-psp
      spec:
        allowPrivilegeEscalation: false
        readOnlyRootFilesystem: false
        allowedCapabilities:
        - CHOWN
        - DAC_OVERRIDE
        - SETGID
        - SETUID
        - NET_BIND_SERVICE
        seLinux:
          rule: RunAsAny
        supplementalGroups:
          rule: RunAsAny
        runAsUser:
          rule: RunAsAny
        fsGroup:
          rule: RunAsAny
        volumes:
        - configMap
        - secret
      
    • Custom ClusterRole for the custom PodSecurityPolicy:
      apiVersion: rbac.authorization.k8s.io/v1
      kind: ClusterRole
      metadata:
        name: ibm-nodejs-loopback-clusterrole
      rules:
      - apiGroups:
        - extensions
        resourceNames:
        - ibm-nodejs-loopback-psp
        resources:
        - podsecuritypolicies
        verbs:
        - use
      
  • From the command line, you can run the setup scripts included under pak_extensions

    As 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

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.sh for cluster admins to create the PodSecurityPolicy and ClusterRole for all releases of this chart.

  • The namespace scoped instructions are located at namespaceAdministration/createSecurityNamespacePrereqs.sh for 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

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.sh for cluster admins to delete the PodSecurityPolicy and ClusterRole for all releases of this chart.

  • The namespace scoped instructions are located at namespaceAdministration/deleteSecurityNamespacePrereqs.sh for 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

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-anyuid-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 SecurityContextConstraints definition:
    apiVersion: security.openshift.io/v1
    kind: SecurityContextConstraints
    metadata:
      name: ibm-nodejs-loopback-scc
    readOnlyRootFilesystem: false
    allowedCapabilities:
    - CHOWN
    - DAC_OVERRIDE
    - SETGID
    - SETUID
    - NET_BIND_SERVICE
    seLinuxContext:
      type: RunAsAny
    supplementalGroups:
      type: RunAsAny
    runAsUser:
      type: RunAsAny
    fsGroup:
      rule: RunAsAny
    volumes:
    - configMap
    - secret
    
  • From the command line, you can run the setup scripts included under pak_extensions/pre-install As 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

Installing the Chart

There are two steps to run your LoopBack application:

  • Create a Node.js LoopBack application image
    • For information on LoopBack see https://loopback.io/doc/en/lb4/
  • Install the Helm chart

Install the Helm chart

Add the internal Helm repository called local-charts to the Helm CLI as an external repository, as described here.

Install the chart, specifying the release name and namespace with the following command:

helm install --name <release_name> --namespace=<namespace_name> loopback --tls

NOTE: The release name should consist of lower-case alphanumeric characters and not start with a digit or contain a space.

The command deploys a Node.js application with LoopBack included on the Kubernetes cluster with the default configuration.

The Configuration lists the parameters that can be overridden during installation by adding them to the Helm install command as follows:

--set key=value[,key=value]

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

Uninstalling the Chart

To uninstall/delete the my-release deployment:

helm delete my-release --purge --tls

Configuration

The following tables lists the configurable parameters of the Node.js LoopBack chart and their default values.

ParameterDescriptionDefault
replicaCountThe number of desired replica pods that run simultaneously1
image.repositoryDocker image repository``
image.pullPolicyDocker image pull policy. Defaults to Always when the latest tag is specified.IfNotPresent
image.tagDocker image tag``
image.pullSecretsImage pull secrets, if using Docker registries that require credentials.[]
image.extraEnvsAdditional Environment Variables[]
image.extraVolumeMountsExtra Volume Mounts[]
image.securityConfigure the security attributes of the image{}
image.readinessProbe.initialDelaySecondsNumber of seconds after the container has started before readiness probe is initiated30
image.readinessProbe.periodSecondsHow often (in seconds) to perform the readiness probe. Minimum value is 15
image.readinessProbe.httpGet.pathPath to access on the server/health
image.livenessProbe.initialDelaySecondsNumber of seconds after the container has started before liveness probe is initiated180
image.livenessProbe.periodSecondsHow often (in seconds) to perform the liveness probe. Minimum value is 120
image.livenessProbe.httpGet.pathPath to access on the server/health
deployment.annotationsCustom deployment annotations{}
deployment.labelsCustom deployment labels{}
pod.annotationsCustom pod annotations{}
pod.labelsCustom pod labels{}
pod.extraVolumesAdditional Volumes for server pods.{}
pod.securityConfigure the security attributes of the pod{}
service.typeKubernetes service type exposing portsNodePort
service.nameKubernetes service name for HTTPhttps-was
service.externalPortThe abstracted service port for HTTP, which other pods use to access this service3000
service.annotationsKubernetes service custom annotations"{}
service.labelsKubernetes service custom labels"{}
ingress.enabledSpecifies whether to enable Ingressfalse
ingress.rewriteTargetSpecifies the target URI where the traffic must be redirected
ingress.pathSpecifies the path for the Ingress HTTP rule
ingress.hostSpecifies a fully qualified domain names of Ingress, as defined by RFC 3986
ingress.secretNameSpecifies the name of the Kubernetes secret that contains Ingress' TLS certificate and key
ingress.annotationsKubernetes ingress custom annotations{}
ingress.labelsKubernetes ingress custom labels{}
ingress.hostsSpecifies an array of fully qualified domain names of Ingress, as defined by RFC 3986.[]
autoscaling.enabledEnables a Horizontal Pod Autoscaler. Enabling this field disables the replicaCount fieldfalse
autoscaling.minReplicasLower limit for the number of pods that can be set by the autoscaler1
autoscaling.maxReplicasUpper li

Deploy ibm-nodejs-loopback with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has ibm-nodejs-loopback 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartibm-nodejs-loopback is pinned at v1.0.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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