From 5ed45e961c733b039b699e5d9393b94ec2b0933e Mon Sep 17 00:00:00 2001 From: Tucker Siegel <tgsiegel@terpmail.umd.edu> Date: Sun, 2 Oct 2022 16:45:28 -0400 Subject: [PATCH] add chart --- VERSION | 1 + chart/.helmignore | 23 ++++++++++++ chart/Chart.yaml | 24 +++++++++++++ chart/templates/_helpers.tpl | 62 +++++++++++++++++++++++++++++++++ chart/templates/configMap.yaml | 25 +++++++++++++ chart/templates/deployment.yaml | 43 +++++++++++++++++++++++ chart/templates/service.yaml | 16 +++++++++ chart/values.yaml | 25 +++++++++++++ spec.yaml | 8 +++++ 9 files changed, 227 insertions(+) create mode 100644 VERSION create mode 100644 chart/.helmignore create mode 100644 chart/Chart.yaml create mode 100644 chart/templates/_helpers.tpl create mode 100644 chart/templates/configMap.yaml create mode 100644 chart/templates/deployment.yaml create mode 100644 chart/templates/service.yaml create mode 100644 chart/values.yaml create mode 100644 spec.yaml diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6c6aa7c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 \ No newline at end of file diff --git a/chart/.helmignore b/chart/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/chart/.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/chart/Chart.yaml b/chart/Chart.yaml new file mode 100644 index 0000000..4acf55a --- /dev/null +++ b/chart/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: dawn-gdd +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: "0.1.0" diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl new file mode 100644 index 0000000..57ac2c9 --- /dev/null +++ b/chart/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "dawn-gateway.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 "dawn-gateway.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 "dawn-gateway.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "dawn-gateway.labels" -}} +helm.sh/chart: {{ include "dawn-gateway.chart" . }} +{{ include "dawn-gateway.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "dawn-gateway.selectorLabels" -}} +app.kubernetes.io/name: {{ include "dawn-gateway.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "dawn-gateway.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "dawn-gateway.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/chart/templates/configMap.yaml b/chart/templates/configMap.yaml new file mode 100644 index 0000000..fb0c1d2 --- /dev/null +++ b/chart/templates/configMap.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: dawn-gdd-conf + namespace: {{ .Release.Namespace }} +data: + conf: | + app: + name: {{ .Values.conf.app.name }} + logLevel: {{ .Values.conf.app.logLevel }} + logType: {{ .Values.conf.app.logType }} + swagger: {{ .Values.conf.app.swagger }} + auth: {{ .Values.conf.app.auth }} + swagger-host-url: {{ .Values.conf.app.swaggerHostUrl }} + api-version: {{ .Values.conf.app.apiVersion }} + + server: + host: {{ .Values.conf.server.host }} + port: {{ .Values.conf.server.port }} + context-path: {{ .Values.conf.server.contextPath }} + + db: + uri: {{ .Values.conf.db.uri }} + database: {{ .Values.conf.db.database }} + \ No newline at end of file diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml new file mode 100644 index 0000000..940317e --- /dev/null +++ b/chart/templates/deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1 # for k8s versions before 1.9.0 use apps/v1beta2 and before 1.8.0 use extensions/v1beta1 +kind: Deployment +metadata: + name: dawn-gdd + namespace: {{ .Release.Namespace }} + labels: + version: {{ .Chart.AppVersion }} +spec: + selector: + matchLabels: + service: dawn-gdd + env: {{ .Release.Namespace }} + replicas: 1 + template: + metadata: + labels: + service: dawn-gdd + env: {{ .Release.Namespace }} + version: {{ .Chart.AppVersion }} + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configMap.yaml") . | sha256sum }} + spec: + containers: + - name: dawn-gdd + image: docker.registry.dawn.int:5000/dawn/dawn-gdd:{{.Chart.AppVersion}} + resources: + requests: + cpu: {{.Values.resources.requests.cpu}} + memory: {{.Values.resources.requests.memory}} + volumeMounts: + - name: conf + mountPath: "/root/config/conf" + subPath: conf + readOnly: true + args: + - --config + - conf + ports: + - containerPort: {{.Values.port}} + volumes: + - name: conf + configMap: + name: dawn-gdd-conf diff --git a/chart/templates/service.yaml b/chart/templates/service.yaml new file mode 100644 index 0000000..af3b224 --- /dev/null +++ b/chart/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: dawn-gdd + namespace: {{ .Release.Namespace }} + labels: + service: dawn-gdd + env: {{ .Release.Namespace }} +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: {{.Values.port}} + selector: + service: dawn-gdd + env: {{ .Release.Namespace }} \ No newline at end of file diff --git a/chart/values.yaml b/chart/values.yaml new file mode 100644 index 0000000..069af18 --- /dev/null +++ b/chart/values.yaml @@ -0,0 +1,25 @@ +port: 5000 +resources: + requests: + cpu: 100m + memory: 100Mi + +# default for staging +conf: + app: + name: gdd-service + logType: json + logLevel: DEBUG + swagger: true + auth: false + swaggerHostUrl: "localhost:5000" + apiVersion: 1 + + server: + host: "localhost" + port: 5000 + contextPath: "/api/weather" + + db: + uri: "mongodb://deployment-internal-mongo.deployment-internal.svc.cluster.local:27017/" + database: "weather-service" diff --git a/spec.yaml b/spec.yaml new file mode 100644 index 0000000..8517e4b --- /dev/null +++ b/spec.yaml @@ -0,0 +1,8 @@ +kind: product +name: dawn-gdd +--- +kind: release +product-name: dawn-gdd +product-version: 0.1.0 +release-channel: DEV +helm-chart: dawn/dawn-gdd \ No newline at end of file -- GitLab