From 7735105eeba30aac2d1dfd8bf62b76bade90758d Mon Sep 17 00:00:00 2001 From: thusara sarath Date: Tue, 10 Jun 2025 17:32:24 -0400 Subject: [PATCH 1/2] nginx service service --- charts/nginx-service/.helmignore | 23 ++++++ charts/nginx-service/Chart.lock | 6 ++ charts/nginx-service/Chart.yaml | 29 +++++++ charts/nginx-service/templates/_helpers.tpl | 55 +++++++++++++ .../nginx-service/templates/deployment.yaml | 51 ++++++++++++ charts/nginx-service/templates/service.yaml | 15 ++++ charts/nginx-service/values.yaml | 82 +++++++++++++++++++ environments/gamma/rendered/app-of-apps.yaml | 8 ++ .../gamma/rendered/nginx-service.yaml | 13 +++ environments/gamma/values.yaml | 14 ++++ templates/environment.py | 3 +- templates/nginx-service.j2 | 4 + 12 files changed, 302 insertions(+), 1 deletion(-) create mode 100644 charts/nginx-service/.helmignore create mode 100644 charts/nginx-service/Chart.lock create mode 100644 charts/nginx-service/Chart.yaml create mode 100644 charts/nginx-service/templates/_helpers.tpl create mode 100644 charts/nginx-service/templates/deployment.yaml create mode 100644 charts/nginx-service/templates/service.yaml create mode 100644 charts/nginx-service/values.yaml create mode 100644 environments/gamma/rendered/nginx-service.yaml create mode 100644 templates/nginx-service.j2 diff --git a/charts/nginx-service/.helmignore b/charts/nginx-service/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/nginx-service/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/nginx-service/Chart.lock b/charts/nginx-service/Chart.lock new file mode 100644 index 0000000..e6fd010 --- /dev/null +++ b/charts/nginx-service/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: nginx + repository: https://charts.bitnami.com/bitnami + version: 20.1.0 +digest: sha256:c9eabfa2af92e4a37034020151d3e373d5316dc265712a2c3490ba12f0f62553 +generated: "2025-06-10T16:52:38.890077-04:00" diff --git a/charts/nginx-service/Chart.yaml b/charts/nginx-service/Chart.yaml new file mode 100644 index 0000000..63c23a0 --- /dev/null +++ b/charts/nginx-service/Chart.yaml @@ -0,0 +1,29 @@ +apiVersion: v2 +name: nginx-service +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.0.0" + +dependencies: + - name: nginx + version: 20.1.0 + repository: https://charts.bitnami.com/bitnami diff --git a/charts/nginx-service/templates/_helpers.tpl b/charts/nginx-service/templates/_helpers.tpl new file mode 100644 index 0000000..73f721d --- /dev/null +++ b/charts/nginx-service/templates/_helpers.tpl @@ -0,0 +1,55 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "nginx-service.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "nginx-service.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "nginx-service.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "nginx-service.ddTags" -}} +{{- printf "env:%s, service:%s" $.Values.global.environmentName "nginx-service" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "nginx-service.labels" -}} +helm.sh/chart: {{ include "nginx-service.chart" . }} +{{ include "nginx-service.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "nginx-service.selectorLabels" -}} +app.kubernetes.io/name: {{ include "nginx-service.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/nginx-service/templates/deployment.yaml b/charts/nginx-service/templates/deployment.yaml new file mode 100644 index 0000000..f8b8e4b --- /dev/null +++ b/charts/nginx-service/templates/deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "nginx-service.fullname" . }} + labels: + {{- include "nginx-service.labels" . | nindent 4 }} +spec: + replicas: 2 + strategy: + type: Recreate #Tell k8s to recreate the pod when the deployment is updated + selector: + matchLabels: + {{- include "nginx-service.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + ad.datadoghq.com/app-registry-service.logs: '[{"service": "app-registry-service"}]' + ad.datadoghq.com/app-registry-service.checks: | + { + "openmetrics": { + "instances": [ + { + "prometheus_url": "http://%%host%%:8081/metrics", + "namespace": "app-registry-service", + "metrics": ["*"] + } + ] + } + } + labels: + {{- include "nginx-service.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + serviceAccountName: main-service-account + containers: + - name: nginx + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: 80 + name: http diff --git a/charts/nginx-service/templates/service.yaml b/charts/nginx-service/templates/service.yaml new file mode 100644 index 0000000..b7f4206 --- /dev/null +++ b/charts/nginx-service/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "nginx-service.fullname" . }} + labels: + {{- include "nginx-service.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: 80 + targetPort: http + protocol: TCP + name: http + selector: + {{- include "nginx-service.selectorLabels" . | nindent 4 }} diff --git a/charts/nginx-service/values.yaml b/charts/nginx-service/values.yaml new file mode 100644 index 0000000..97530fb --- /dev/null +++ b/charts/nginx-service/values.yaml @@ -0,0 +1,82 @@ +# Default values for app-registry-service. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +replicaCount: 1 + +# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +image: + repository: bitnami/nginx + # This sets the pull policy for images. + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +# This is for the secretes for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# This is to override the chart name. +nameOverride: "" +fullnameOverride: "" + +# This is for setting Kubernetes Annotations to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} +# This is for setting Kubernetes Labels to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: + {} + # fsGroup: 2000 + +securityContext: + {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: LoadBalancer + +# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ + +resources: + limits: + cpu: 1 + memory: 8Gi + requests: + cpu: 1 + memory: 8Gi + +# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/environments/gamma/rendered/app-of-apps.yaml b/environments/gamma/rendered/app-of-apps.yaml index e686216..497e639 100644 --- a/environments/gamma/rendered/app-of-apps.yaml +++ b/environments/gamma/rendered/app-of-apps.yaml @@ -116,3 +116,11 @@ appOfApps: - ./values.yaml - ../../environments/gamma/rendered/global.yaml - ../../environments/gamma/rendered/app-registry-service.yaml + + - name: nginx-service + disable: true + namespace: default + valueFiles: + - ./values.yaml + - ../../environments/gamma/rendered/global.yaml + - ../../environments/gamma/rendered/nginx-service.yaml diff --git a/environments/gamma/rendered/nginx-service.yaml b/environments/gamma/rendered/nginx-service.yaml new file mode 100644 index 0000000..69cf2d3 --- /dev/null +++ b/environments/gamma/rendered/nginx-service.yaml @@ -0,0 +1,13 @@ +############### WARNING #################### +# This file is generated by the environment.py script. Do not edit this file directly. +# Instead, edit the corresponding template file in the templates directory and run the environment.py script. + +image: + tag: "latest" +resources: + limits: + cpu: 500m + memory: 2Gi + requests: + cpu: 100m + memory: 1Gi diff --git a/environments/gamma/values.yaml b/environments/gamma/values.yaml index 2281b50..7d991ec 100644 --- a/environments/gamma/values.yaml +++ b/environments/gamma/values.yaml @@ -65,6 +65,17 @@ appRegistryService: cpu: 1 memory: 2Gi +nginxService: + image: + tag: latest + resources: + requests: + cpu: '100m' + memory: 1Gi + limits: + cpu: '500m' + memory: 2Gi + rpcGateway: image: tag: "5b23033" @@ -114,3 +125,6 @@ appOfApps: - name: app-registry-service namespace: default disable: true + - name: nginx-service + namespace: default + disable: true diff --git a/templates/environment.py b/templates/environment.py index e8eb6a1..dd725d3 100644 --- a/templates/environment.py +++ b/templates/environment.py @@ -20,7 +20,8 @@ 'xchain-monitor', 'river-node', 'rpc-gateway', - 'subgraph' + 'subgraph', + 'nginx-service' ) GENERATED_FILE_WARNING_MESSAGE = """############### WARNING #################### diff --git a/templates/nginx-service.j2 b/templates/nginx-service.j2 new file mode 100644 index 0000000..89285c7 --- /dev/null +++ b/templates/nginx-service.j2 @@ -0,0 +1,4 @@ +image: + tag: "{{ nginxService.image.tag }}" +resources: + {{ nginxService.resources | to_yaml | indent(2) }} From bfab82a6b4d234268c1f472fca777404d88ba5ab Mon Sep 17 00:00:00 2001 From: thusara sarath Date: Tue, 10 Jun 2025 17:53:48 -0400 Subject: [PATCH 2/2] fix datadog annotation --- charts/nginx-service/templates/deployment.yaml | 6 +++--- charts/nginx-service/values.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/nginx-service/templates/deployment.yaml b/charts/nginx-service/templates/deployment.yaml index f8b8e4b..0df054e 100644 --- a/charts/nginx-service/templates/deployment.yaml +++ b/charts/nginx-service/templates/deployment.yaml @@ -14,14 +14,14 @@ spec: template: metadata: annotations: - ad.datadoghq.com/app-registry-service.logs: '[{"service": "app-registry-service"}]' - ad.datadoghq.com/app-registry-service.checks: | + ad.datadoghq.com/nginx-service.logs: '[{"service": "nginx-service"}]' + ad.datadoghq.com/nginx-service.checks: | { "openmetrics": { "instances": [ { "prometheus_url": "http://%%host%%:8081/metrics", - "namespace": "app-registry-service", + "namespace": "nginx-service", "metrics": ["*"] } ] diff --git a/charts/nginx-service/values.yaml b/charts/nginx-service/values.yaml index 97530fb..8b1b23c 100644 --- a/charts/nginx-service/values.yaml +++ b/charts/nginx-service/values.yaml @@ -1,4 +1,4 @@ -# Default values for app-registry-service. +# Default values for nginx-service. # This is a YAML-formatted file. # Declare variables to be passed into your templates.