bitnamicharts/nginx
Bitnami Helm chart for NGINX Open Source
1M+
NGINX Open Source is a web server that can be also used as a reverse proxy, load balancer, and HTTP cache. Recommended for high-demanding sites due to its ability to provide faster content.
Overview of NGINX Open Source
Trademarks: This software listing is packaged by Bitnami. The respective trademarks mentioned in the offering are owned by the respective companies, and use of them does not imply any affiliation or endorsement.
helm install my-release oci://registry-1.docker.io/bitnamicharts/nginx
Looking to use NGINX Open Source in production? Try VMware Tanzu Application Catalog, the commercial edition of the Bitnami catalog.
Bitnami charts for Helm are carefully engineered, actively maintained and are the quickest and easiest way to deploy containers on a Kubernetes cluster that are ready to handle production workloads.
This chart bootstraps a NGINX Open Source deployment on a Kubernetes cluster using the Helm package manager.
Bitnami charts can be used with Kubeapps for deployment and management of Helm Charts in clusters.
To install the chart with the release name my-release
:
helm install my-release oci://REGISTRY_NAME/REPOSITORY_NAME/nginx
Note: You need to substitute the placeholders
REGISTRY_NAME
andREPOSITORY_NAME
with a reference to your Helm chart registry and repository. For example, in the case of Bitnami, you need to useREGISTRY_NAME=registry-1.docker.io
andREPOSITORY_NAME=bitnamicharts
.
These commands deploy NGINX Open Source on the Kubernetes cluster in the default configuration.
Tip: List all releases using
helm list
Bitnami charts allow setting resource requests and limits for all containers inside the chart deployment. These are inside the resources
value (check parameter table). Setting requests is essential for production workloads and these should be adapted to your specific use case.
To make this process easier, the chart contains the resourcesPreset
values, which automatically sets the resources
section according to different presets. Check these presets in the bitnami/common chart. However, in production workloads using resourcesPreset
is discouraged as it may not fully adapt to your specific needs. Find more information on container resource management in the official Kubernetes documentation.
This chart can be integrated with Prometheus by setting metrics.enabled
to true
. This will deploy a sidecar container with nginx-prometheus-exporter in all pods and will expose it via the Nginx service. This service will be have the necessary annotations to be automatically scraped by Prometheus.
Prometheus requirements
It is necessary to have a working installation of Prometheus or Prometheus Operator for the integration to work. Install the Bitnami Prometheus helm chart or the Bitnami Kube Prometheus helm chart to easily have a working Prometheus in your cluster.
Integration with Prometheus Operator
The chart can deploy ServiceMonitor
objects for integration with Prometheus Operator installations. To do so, set the value metrics.serviceMonitor.enabled=true
. Ensure that the Prometheus Operator CustomResourceDefinitions
are installed in the cluster or it will fail with the following error:
no matches for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"
Install the Bitnami Kube Prometheus helm chart for having the necessary CRDs and the Prometheus Operator.
Nginx can encrypt communications by setting tls.enabled=true
. The chart allows two configuration options:
tls.certificatesSecret
value. Also set the correct name of the certificate files using the tls.certFilename
, tls.certKeyFilename
and tls.certCAFilename
values.tls.autoGenerated=true
.It is strongly recommended to use immutable tags in a production environment. This ensures your deployment does not change automatically if the same tag is updated with a different image.
Bitnami will release a new chart updating its containers if a new version of the main container, significant changes, or critical vulnerabilities exist.
To modify the application version used in this chart, specify a different version of the image using the image.tag
parameter and/or a different repository using the image.repository
parameter.
To back up and restore Helm chart deployments on Kubernetes, you need to back up the persistent volumes from the source deployment and attach them to a new deployment using Velero, a Kubernetes backup/restore tool. Find the instructions for using Velero in this guide.
The NGINX chart allows you to deploy a custom web application using one of the following methods:
cloneStaticSiteFromGit.enabled
to true
and set the repository and branch using the cloneStaticSiteFromGit.repository
and cloneStaticSiteFromGit.branch
parameters. A sidecar will also pull the latest changes in an interval set by cloneStaticSitesFromGit.interval
.staticSiteConfigmap
value to mount a ConfigMap in the NGINX html folder.staticSitePVC
value to mount an PersistentVolumeClaim with the static site content.You can deploy a example web application using git deploying the chart with the following parameters:
cloneStaticSiteFromGit.enabled=true
cloneStaticSiteFromGit.repository=https://github.com/mdn/beginner-html-site-styled.git
cloneStaticSiteFromGit.branch=master
This helm chart supports using custom custom server block for NGINX to use.
You can use the serverBlock
or streamServerBlock
value to provide a custom server block for NGINX to use. To do this, create a values files with your server block and install the chart using it:
serverBlock: |-
server {
listen 0.0.0.0:8080;
location / {
return 200 "hello!";
}
}
Warning: The above example is not compatible with enabling Prometheus metrics since it affects the
/status
endpoint.
In addition, you can also set an external ConfigMap with the configuration file. This is done by setting the existingServerBlockConfigmap
parameter. Note that this will override the previous option.
In case you want to add extra environment variables (useful for advanced operations like custom init scripts), you can use the extraEnvVars
property.
extraEnvVars:
- name: LOG_LEVEL
value: error
Alternatively, you can use a ConfigMap or a Secret with the environment variables. To do so, use the extraEnvVarsCM
or the extraEnvVarsSecret
values.
This chart allows you to set your custom affinity using the affinity
parameter. Find more information about Pod's affinity in the kubernetes documentation.
As an alternative, you can use of the preset configurations for pod affinity, pod anti-affinity, and node affinity available at the bitnami/common chart. To do so, set the podAffinityPreset
, podAntiAffinityPreset
, or nodeAffinityPreset
parameters.
There are cases where you may want to deploy extra objects, such a ConfigMap containing your app's configuration or some extra deployment with a micro service used by your app. For covering this case, the chart allows adding the full specification of other objects using the extraDeploy
parameter.
This chart provides support for ingress resources. If you have an ingress controller installed on your cluster, such as nginx-ingress-controller or contour you can utilize the ingress controller to serve your application.
To enable ingress integration, please set ingress.enabled
to true
.
Hosts
Most likely you will only want to have one hostname that maps to this NGINX installation. If that's your case, the property ingress.hostname
will set it. However, it is possible to have more than one host. To facilitate this, the ingress.extraHosts
object can be specified as an array. You can also use ingress.extraTLS
to add the TLS configuration for extra hosts.
For each host indicated at ingress.extraHosts
, please indicate a name
, path
, and any annotations
that you may want the ingress controller to know about.
For annotations, please see this document. Not all annotations are supported by all ingress controllers, but this document does a good job of indicating which annotation is supported by many popular ingress controllers.
Name | Description | Value |
---|---|---|
global.imageRegistry | Global Docker image registry | "" |
global.imagePullSecrets | Global Docker registry secret names as an array | [] |
global.security.allowInsecureImages | Allows skipping image verification | false |
global.compatibility.openshift.adaptSecurityContext | Adapt the securityContext sections of the deployment to make them compatible with Openshift restricted-v2 SCC: remove runAsUser, runAsGroup and fsGroup and let the platform use their allowed default IDs. Possible values: auto (apply if the detected running cluster is Openshift), force (perform the adaptation always), disabled (do not perform adaptation) | auto |
Name | Description | Value |
---|---|---|
nameOverride | String to partially override nginx.fullname template (will maintain the release name) | "" |
fullnameOverride | String to fully override nginx.fullname template | "" |
namespaceOverride | String to fully override common.names.namespace | "" |
kubeVersion | Force target Kubernetes version (using Helm capabilities if not set) | "" |
clusterDomain | Kubernetes Cluster Domain | cluster.local |
extraDeploy | Extra objects to deploy (value evaluated as a template) | [] |
commonLabels | Add labels to all the deployed resources | {} |
commonAnnotations | Add annotations to all the deployed resources | {} |
diagnosticMode.enabled | Enable diagnostic mode (all probes will be disabled and the command will be overridden) | false |
diagnosticMode.command | Command to override all containers in the the deployment(s)/statefulset(s) | ["sleep"] |
diagnosticMode.args | Args to override all containers in the the deployment(s)/statefulset(s) | ["infinity"] |
Name | Description | Value |
---|---|---|
image.registry | NGINX image registry | REGISTRY_NAME |
image.repository | NGINX image repository | REPOSITORY_NAME/nginx |
image.digest | NGINX image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag | "" |
image.pullPolicy | NGINX image pull policy | IfNotPresent |
image.pullSecrets | Specify docker-registry secret names as an array | [] |
image.debug | Set to true if you would like to see extra information on logs | false |
automountServiceAccountToken | Mount Service Account token in pod | false |
hostAliases | Deployment pod host aliases | [] |
command | Override default container command (useful when using custom images) | [] |
args | Override default container args (useful when using custom images) | [] |
extraEnvVars | Extra environment variables to be set on NGINX containers | [] |
extraEnvVarsCM | ConfigMap with extra environment variables | "" |
extraEnvVarsSecret | Secret with extra environment variables | "" |
Name | Description | Value |
---|---|---|
replicaCount | Number of NGINX replicas to deploy | 1 |
revisionHistoryLimit | The number of old history to retain to allow rollback | 10 |
updateStrategy.type | NGINX deployment strategy type | RollingUpdate |
updateStrategy.rollingUpdate | NGINX deployment rolling update configuration parameters | {} |
podLabels | Additional labels for NGINX pods | {} |
podAnnotations | Annotations for NGINX pods | {} |
podAffinityPreset | Pod affinity preset. Ignored if affinity is set. Allowed values: soft or hard | "" |
podAntiAffinityPreset | Pod anti-affinity preset. Ignored if affinity is set. Allowed values: soft or hard | soft |
nodeAffinityPreset.type | Node affinity preset type. Ignored if affinity is set. Allowed values: soft or hard | "" |
nodeAffinityPreset.key | Node label key to match Ignored if affinity is set. | "" |
nodeAffinityPreset.values | Node label values to match. Ignored if affinity is set. | [] |
affinity | Affinity for pod assignment | {} |
hostNetwork | Specify if host network should be enabled for NGINX pod | false |
hostIPC | Specify if host IPC should be enabled for NGINX pod | false |
dnsPolicy | Specifies the DNS policy for the NGINX pod | "" |
dnsConfig | Allows users more control on the DNS settings for a Pod. Required if dnsPolicy is set to None | {} |
nodeSelector | Node labels for pod assignment. Evaluated as a template. | {} |
tolerations | Tolerations for pod assignment. Evaluated as a template. | [] |
priorityClassName | NGINX pods' priorityClassName | "" |
schedulerName | Name of the k8s scheduler (other than default) | "" |
terminationGracePeriodSeconds | In seconds, time the given to the NGINX pod needs to terminate gracefully | "" |
topologySpreadConstraints | Topology Spread Constraints for pod assignment | [] |
tls.enabled | Enable TLS transport | true |
tls.autoGenerated | Auto-generate self-signed certificates |
Note: the README for this chart is longer than the DockerHub length limit of 25000, so it has been trimmed. The full README can be found at https://github.com/bitnami/charts/blob/main/bitnami/nginx/README.md