ibm-nodejs-express
by Helm
Helm chart for deploying Express.js Application.
About this chart
IBM-Nodejs-Express Helm Chart
Encapsulates Helm chart and other cloud pak artifacts for a Node.js Express application.
Introduction
Node.js is an open source runtime build on the V8 JavaScript Engine. Express 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:
- One Deployment to rollout a ReplicaSet to create Pods with Node.js based containers.
- A NodePort Service to enable secure connection from outside the cluster.
Prerequisites
You will need to provide your own Node.js Express 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,kubectlandhelmcommands 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-express-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-express-clusterrole rules: - apiGroups: - extensions resourceNames: - ibm-nodejs-express-psp resources: - podsecuritypolicies verbs: - use
- Custom PodSecurityPolicy definition:
-
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.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-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
SecurityContextConstraintsdefinition:
apiVersion: security.openshift.io/v1 kind: SecurityContextConstraints metadata: name: ibm-nodejs-express-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 - 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
Installing the Chart
There are two steps to run your Express application:
- Create a Node.js Express application image
- For information on Express see https://expressjs.com/en/4x/api.html
- For information on how to build your application into an image see https://github.com/CloudNativeJS/tutorial
- 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> express --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 Express 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 Express chart and their default values.
| Parameter | Description | Default |
|---|---|---|
replicaCount | The number of desired replica pods that run simultaneously | 1 |
image.repository | Docker image repository | `` |
image.pullPolicy | Docker image pull policy. Defaults to Always when the latest tag is specified. | IfNotPresent |
image.tag | Docker image tag | `` |
image.pullSecrets | Image pull secrets, if using Docker registries that require credentials. | [] |
image.extraEnvs | Additional Environment Variables | [] |
image.extraVolumeMounts | Extra Volume Mounts | [] |
image.security | Configure the security attributes of the image | {} |
image.readinessProbe.initialDelaySeconds | Number of seconds after the container has started before readiness probe is initiated | 30 |
image.readinessProbe.periodSeconds | How often (in seconds) to perform the readiness probe. Minimum value is 1 | 5 |
image.readinessProbe.httpGet.path | Path to access on the server | /health |
image.livenessProbe.initialDelaySeconds | Number of seconds after the container has started before liveness probe is initiated | 180 |
image.livenessProbe.periodSeconds | How often (in seconds) to perform the liveness probe. Minimum value is 1 | 20 |
image.livenessProbe.httpGet.path | Path to access on the server | /health |
deployment.annotations | Custom deployment annotations | {} |
deployment.labels | Custom deployment labels | {} |
pod.annotations | Custom pod annotations | {} |
pod.labels | Custom pod labels | {} |
pod.extraVolumes | Additional Volumes for server pods. | {} |
pod.security | Configure the security attributes of the pod | {} |
service.type | Kubernetes service type exposing ports | NodePort |
service.name | Kubernetes service name for HTTP | https-was |
service.externalPort | The abstracted service port for HTTP, which other pods use to access this service | 3000 |
service.annotations | Kubernetes service custom annotations" | {} |
service.labels | Kubernetes service custom labels" | {} |
ingress.enabled | Specifies whether to enable Ingress | false |
ingress.rewriteTarget | Specifies the target URI where the traffic must be redirected | |
ingress.path | Specifies the path for the Ingress HTTP rule | |
ingress.host | Specifies a fully qualified domain names of Ingress, as defined by RFC 3986 | |
ingress.secretName | Specifies the name of the Kubernetes secret that contains Ingress' TLS certificate and key | |
ingress.annotations | Kubernetes ingress custom annotations | {} |
ingress.labels | Kubernetes ingress custom labels | {} |
ingress.hosts | Specifies an array of fully qualified domain names of Ingress, as defined by RFC 3986. | [] |
autoscaling.enabled | Enables a Horizontal Pod Autoscaler. Enabling this field disables the replicaCount field | false |
autoscaling.minReplicas | Lower limit for the number of pods that can b |
Deploy ibm-nodejs-express 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-express 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-nodejs-express is pinned at v1.0.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