diff --git a/charts/core/.helmignore b/charts/core/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/core/.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/core/Chart.yaml b/charts/core/Chart.yaml new file mode 100644 index 0000000..5128f45 --- /dev/null +++ b/charts/core/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: core +description: A Helm chart for CodeZero's sample-project-core + +# 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.1 + +# 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.0.1" diff --git a/charts/core/templates/NOTES.txt b/charts/core/templates/NOTES.txt new file mode 100644 index 0000000..50c5fc2 --- /dev/null +++ b/charts/core/templates/NOTES.txt @@ -0,0 +1 @@ +Hurray, the core service has been deployed! \ No newline at end of file diff --git a/charts/core/templates/_helpers.tpl b/charts/core/templates/_helpers.tpl new file mode 100644 index 0000000..766b02a --- /dev/null +++ b/charts/core/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "core.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 "core.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 "core.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "core.labels" -}} +helm.sh/chart: {{ include "core.chart" . }} +{{ include "core.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "core.selectorLabels" -}} +app.kubernetes.io/name: {{ include "core.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} \ No newline at end of file diff --git a/charts/core/templates/configmap.yaml b/charts/core/templates/configmap.yaml new file mode 100644 index 0000000..52902aa --- /dev/null +++ b/charts/core/templates/configmap.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "core.fullname" . }}-config + labels: + {{- include "core.labels" . | nindent 4 }} +data: + # These are here to demonstrate capturing config + # values in using the environment features of czctl + SAMPLE1_KEY: VALUE1 + SAMPLE2_KEY: VALUE2 + SAMPLE_PROJECT_VERSION: "Version Production" + SAMPLE_PROJECT_API_PORT: "{{ .Values.config.containerPort }}" \ No newline at end of file diff --git a/charts/core/templates/deployment.yaml b/charts/core/templates/deployment.yaml new file mode 100644 index 0000000..99060d6 --- /dev/null +++ b/charts/core/templates/deployment.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "core.fullname" . }} + labels: + {{- include "core.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "core.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "core.selectorLabels" . | nindent 8 }} + spec: + securityContext: + containers: + - name: {{ .Chart.Name }} + securityContext: + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: SP_LEAF_URL + value: http://sample-project-leaf:3010 + - name: SP_DB_URL + value: mongodb://sample-project-database:27017/sample-project-database + envFrom: + - configMapRef: + name: {{ include "core.fullname" . }}-config + volumeMounts: + - name: data + mountPath: /usr/src/app/data + ports: + - name: http + containerPort: {{ .Values.config.containerPort }} + protocol: TCP + livenessProbe: + httpGet: + path: /api + port: http + readinessProbe: + httpGet: + path: /api + port: http + volumes: + - name: data + persistentVolumeClaim: + claimName: {{ include "core.fullname" . }}-pvc diff --git a/charts/core/templates/pvc.yaml b/charts/core/templates/pvc.yaml new file mode 100644 index 0000000..d90120d --- /dev/null +++ b/charts/core/templates/pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "core.fullname" . }}-pvc + labels: + {{- include "core.labels" . | nindent 4 }} +spec: + resources: + requests: + storage: 1Gi + accessModes: + - ReadWriteOnce \ No newline at end of file diff --git a/charts/core/templates/service.yaml b/charts/core/templates/service.yaml new file mode 100644 index 0000000..f0214d5 --- /dev/null +++ b/charts/core/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "core.fullname" . }} + labels: + {{- include "core.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.config.containerPort }} + protocol: TCP + name: http + selector: + {{- include "core.selectorLabels" . | nindent 4 }} diff --git a/charts/core/values.yaml b/charts/core/values.yaml new file mode 100644 index 0000000..b06a65b --- /dev/null +++ b/charts/core/values.yaml @@ -0,0 +1,22 @@ +# Default values for core. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: c6oio/sample-project-core + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +service: + type: ClusterIP + port: 3000 + +config: + containerPort: 3000