From b1fbbdf4f7ba19c32dee3ee27a8114f2e31f77c1 Mon Sep 17 00:00:00 2001 From: Petr Hracek Date: Tue, 6 Feb 2024 14:52:31 +0100 Subject: [PATCH] Nginx-template helm chart (#1197) --- .../nginx-template/0.0.1/src/Chart.yaml | 15 ++++++ .../redhat/nginx-template/0.0.1/src/README.md | 23 ++++++++ .../0.0.1/src/templates/buildconfig.yaml | 36 +++++++++++++ .../0.0.1/src/templates/deployment.yaml | 54 +++++++++++++++++++ .../0.0.1/src/templates/imagestream.yaml | 9 ++++ .../0.0.1/src/templates/route.yaml | 14 +++++ .../0.0.1/src/templates/service.yaml | 16 ++++++ .../tests/test-nginx-connection.yaml | 21 ++++++++ .../0.0.1/src/values.schema.json | 51 ++++++++++++++++++ .../nginx-template/0.0.1/src/values.yaml | 9 ++++ 10 files changed, 248 insertions(+) create mode 100644 charts/redhat/redhat/nginx-template/0.0.1/src/Chart.yaml create mode 100644 charts/redhat/redhat/nginx-template/0.0.1/src/README.md create mode 100644 charts/redhat/redhat/nginx-template/0.0.1/src/templates/buildconfig.yaml create mode 100644 charts/redhat/redhat/nginx-template/0.0.1/src/templates/deployment.yaml create mode 100644 charts/redhat/redhat/nginx-template/0.0.1/src/templates/imagestream.yaml create mode 100644 charts/redhat/redhat/nginx-template/0.0.1/src/templates/route.yaml create mode 100644 charts/redhat/redhat/nginx-template/0.0.1/src/templates/service.yaml create mode 100644 charts/redhat/redhat/nginx-template/0.0.1/src/templates/tests/test-nginx-connection.yaml create mode 100644 charts/redhat/redhat/nginx-template/0.0.1/src/values.schema.json create mode 100644 charts/redhat/redhat/nginx-template/0.0.1/src/values.yaml diff --git a/charts/redhat/redhat/nginx-template/0.0.1/src/Chart.yaml b/charts/redhat/redhat/nginx-template/0.0.1/src/Chart.yaml new file mode 100644 index 0000000000..62a9d28444 --- /dev/null +++ b/charts/redhat/redhat/nginx-template/0.0.1/src/Chart.yaml @@ -0,0 +1,15 @@ +description: An example Nginx HTTP server and a reverse proxy (nginx) application + that serves static content. For more information about using this template, including + OpenShift considerations, see https://github.com/sclorg/nginx-ex/blob/master/README.md. +name: nginx-template +tags: quickstart,nginx +version: 0.0.1 +kubeVersion: '>=1.20.0' +annotations: + charts.openshift.io/name: Red Hat Nginx HTTP Server (nginx) application (experimental). + charts.openshift.io/provider: Red Hat + charts.openshift.io/providerType: redhat +apiVersion: v2 +appVersion: 0.0.1 +sources: + - https://github.com/sclorg/helm-charts \ No newline at end of file diff --git a/charts/redhat/redhat/nginx-template/0.0.1/src/README.md b/charts/redhat/redhat/nginx-template/0.0.1/src/README.md new file mode 100644 index 0000000000..e6b4589c95 --- /dev/null +++ b/charts/redhat/redhat/nginx-template/0.0.1/src/README.md @@ -0,0 +1,23 @@ +# Nginx helm chart + +A Helm chart for building and deploying a [Nginx](https://github/sclorg/nginx-container) application on OpenShift. + +For more information about helm charts see the official [Helm Charts Documentation](https://helm.sh/). + +You need to have access to a cluster for each operation with OpenShift 4, like deploying and testing. + +## Values +Below is a table of each value used to configure this chart. + +| Value | Description | Default | Additional Information | +|---------------------------------------------| ----------- |----------------------------------------------------| ---------------------- | +| `name` | The name assigned to all of the frontend objects defined in this helm chart. | `httpd-example` | | +| `namespace` | The OpenShift Namespace where the ImageStream resides. | `httpd-template` | | +| `nginx_version` | Version of NGINX image to be used (1.20-ubi8 by default). | `1.20-ubi8` | | +| `memory_limit` | Maximum amount of memory the container can use. | `521Mi` | | +| `source_repository_url` | The URL of the repository with your application source code. | `https://github.com/sclorg/nginx-ex.git` | | +| `source_repository_ref` | Set this to a branch name, tag or other ref of your repository if you are not using the default branch. | | | +| `context_dir` | Set this to the relative path to your project if it is not in the root of your repository. | | | +| `application_domain` | The exposed hostname that will route to the httpd service, if left blank a value will be defaulted. | | | +| `generic_webhook_secret` | A secret string used to configure the Generic webhook. | | | +| `github_webhook_secret` | Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted. | | | diff --git a/charts/redhat/redhat/nginx-template/0.0.1/src/templates/buildconfig.yaml b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/buildconfig.yaml new file mode 100644 index 0000000000..cecf1685ef --- /dev/null +++ b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/buildconfig.yaml @@ -0,0 +1,36 @@ +apiVersion: build.openshift.io/v1 +kind: BuildConfig +metadata: + annotations: + description: Defines how to build the application + template.alpha.openshift.io/wait-for-ready: "true" + labels: + app: {{ .Values.name }} + template: {{ .Values.name }} + name: {{ .Values.name }} +spec: + output: + to: + kind: ImageStreamTag + name: {{ .Values.name }}:latest + source: + contextDir: {{ .Values.context_dir }} + git: + ref: {{ .Values.source_repository_ref }} + uri: {{ .Values.source_repository_url }} + type: Git + strategy: + sourceStrategy: + from: + kind: ImageStreamTag + name: nginx:{{ .Values.nginx_version }} + type: Source + triggers: + - type: ImageChange + - type: ConfigChange + - github: + secret: {{ .Values.github_webhook_secret }} + type: GitHub + - generic: + secret: {{ .Values.generic_webhook_secret }} + type: Generic diff --git a/charts/redhat/redhat/nginx-template/0.0.1/src/templates/deployment.yaml b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/deployment.yaml new file mode 100644 index 0000000000..b68f62e024 --- /dev/null +++ b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + description: Defines how to deploy the application server + template.alpha.openshift.io/wait-for-ready: "true" + image.openshift.io/triggers: |- + [ + { + "from": { + "kind": "ImageStreamTag", + "name": "{{ .Values.name }}:latest" + }, + "fieldPath": "spec.template.spec.containers[0].image" + } + ] + labels: + app: nginx-template + template: nginx-template + name: {{ .Values.name }} +spec: + replicas: 1 + selector: + matchLabels: + name: {{ .Values.name }} + strategy: + type: RollingUpdate + template: + metadata: + labels: + name: {{ .Values.name }} + name: {{ .Values.name }} + spec: + containers: + - env: [] + image: " " + livenessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 30 + timeoutSeconds: 3 + name: nginx-template + ports: + - containerPort: 8080 + readinessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 3 + timeoutSeconds: 3 + resources: + limits: + memory: {{ .Values.memory_limit }} diff --git a/charts/redhat/redhat/nginx-template/0.0.1/src/templates/imagestream.yaml b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/imagestream.yaml new file mode 100644 index 0000000000..cd14a8a141 --- /dev/null +++ b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/imagestream.yaml @@ -0,0 +1,9 @@ +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: + annotations: + description: Keeps track of changes in the application image + labels: + app: dancer-example + template: dancer-example + name: {{ .Values.name }} \ No newline at end of file diff --git a/charts/redhat/redhat/nginx-template/0.0.1/src/templates/route.yaml b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/route.yaml new file mode 100644 index 0000000000..d1a605d6e9 --- /dev/null +++ b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/route.yaml @@ -0,0 +1,14 @@ +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + annotations: + template.openshift.io/expose-uri: http://{.spec.host}{.spec.path} + labels: + app: {{ .Values.name }} + template: {{ .Values.name }} + name: {{ .Values.name }} +spec: + host: {{ .Values.application_domain }} + to: + kind: Service + name: {{ .Values.name }} diff --git a/charts/redhat/redhat/nginx-template/0.0.1/src/templates/service.yaml b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/service.yaml new file mode 100644 index 0000000000..7501d7dbdb --- /dev/null +++ b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + description: Exposes and load balances the application pods + labels: + app: {{ .Values.name }} + template: {{ .Values.name }} + name: {{ .Values.name }} +spec: + ports: + - name: web + port: 8080 + targetPort: 8080 + selector: + name: {{ .Values.name }} diff --git a/charts/redhat/redhat/nginx-template/0.0.1/src/templates/tests/test-nginx-connection.yaml b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/tests/test-nginx-connection.yaml new file mode 100644 index 0000000000..e91d41b17b --- /dev/null +++ b/charts/redhat/redhat/nginx-template/0.0.1/src/templates/tests/test-nginx-connection.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ .Release.Name }}-connection-test" + namespace: "{{ .Release.Namespace }}" + annotations: + "helm.sh/hook": test + labels: + name: {{ .Values.database_service_name }} +spec: + #serviceAccount: {{ .Values.serviceAccount }} + containers: + - name: "nginx-connection-test" + image: "registry.redhat.io/ubi8/nginx-122:latest" + imagePullPolicy: IfNotPresent + command: + - '/bin/bash' + - '-exc' + - > + curl {{ .Values.name }}.{{ .Release.Namespace }}:8080 | grep "{{ .Values.expected_str }}" + restartPolicy: Never diff --git a/charts/redhat/redhat/nginx-template/0.0.1/src/values.schema.json b/charts/redhat/redhat/nginx-template/0.0.1/src/values.schema.json new file mode 100644 index 0000000000..f2842e2dbd --- /dev/null +++ b/charts/redhat/redhat/nginx-template/0.0.1/src/values.schema.json @@ -0,0 +1,51 @@ +{ + "$schema": "http://json-schema.org/schema#", + "type": "object", + "properties": { + "name": { + "type": "string", + "pattern": "^[a-z0-9-_]+$" + }, + "namespace": { + "type": "string", + "title": "The URL of the repository with your application source code." + }, + "nginx_version": { + "type": "string", + "description": "Version of NGINX image to be used (1.20-ubi8 by default).", + "enum": [ "latest", "1.20-ubi8", "1.20-ubi9", "1.22-ubi8", "1.22-ubi9", "1.20-ubi7" ] + }, + "memory_limit": { + "type": "string", + "title": "Maximum amount of memory the container can use.", + "form": true, + "render": "slider", + "sliderMin": 512, + "sliderMax": 65536, + "sliderUnit": "Mi" + }, + "source_repository_url": { + "type": "string" + }, + "source_repository_ref": { + "type": "string" + }, + "context_dir": { + "type": "string", + "description": "Set this to the relative path to your project if it is not in the root of your repository." + }, + "application_domain": { + "type": "string", + "description": "The exposed hostname that will route to the httpd service, if left blank a value will be defaulted." + }, + "github_webhook_secret": { + "type": "string", + "description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted." + }, + "generic_webhook_secret": { + "type": "string", + "description": "A secret string used to configure the Generic webhook." + } + } +} + diff --git a/charts/redhat/redhat/nginx-template/0.0.1/src/values.yaml b/charts/redhat/redhat/nginx-template/0.0.1/src/values.yaml new file mode 100644 index 0000000000..492a03bf19 --- /dev/null +++ b/charts/redhat/redhat/nginx-template/0.0.1/src/values.yaml @@ -0,0 +1,9 @@ +context_dir: "" # TODO: must define a default value for .context_dir +generic_webhook_secret: "SOMETHING" # TODO: must define a default value for .generic_webhook_secret +github_webhook_secret: "FOOBAR" # TODO: must define a default value for .github_webhook_secret +memory_limit: 512Mi +name: nginx-example +namespace: openshift +nginx_version: 1.20-ubi8 +source_repository_ref: master # TODO: must define a default value for .source_repository_ref +source_repository_url: https://github.com/sclorg/nginx-ex.git