diff --git a/helm-charts/Micro_services b/helm-charts/Micro_services new file mode 160000 index 0000000..08f0836 --- /dev/null +++ b/helm-charts/Micro_services @@ -0,0 +1 @@ +Subproject commit 08f08368e49fb1e63ec01fb36dd315826565f967 diff --git a/helm-charts/carts-db/.helmignore b/helm-charts/carts-db/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/carts-db/.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/helm-charts/carts-db/Chart.yaml b/helm-charts/carts-db/Chart.yaml new file mode 100644 index 0000000..9fb44f7 --- /dev/null +++ b/helm-charts/carts-db/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: carts-db +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.16.0" diff --git a/helm-charts/carts-db/templates/NOTES.txt b/helm-charts/carts-db/templates/NOTES.txt new file mode 100644 index 0000000..3fe5e48 --- /dev/null +++ b/helm-charts/carts-db/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "carts-db.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "carts-db.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "carts-db.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "carts-db.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm-charts/carts-db/templates/_helpers.tpl b/helm-charts/carts-db/templates/_helpers.tpl new file mode 100644 index 0000000..23d79f4 --- /dev/null +++ b/helm-charts/carts-db/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "carts-db.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 "carts-db.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 "carts-db.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "carts-db.labels" -}} +helm.sh/chart: {{ include "carts-db.chart" . }} +{{ include "carts-db.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "carts-db.selectorLabels" -}} +app.kubernetes.io/name: {{ include "carts-db.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "carts-db.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "carts-db.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/carts-db/templates/deployment.yaml b/helm-charts/carts-db/templates/deployment.yaml new file mode 100644 index 0000000..82628ac --- /dev/null +++ b/helm-charts/carts-db/templates/deployment.yaml @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "carts-db.fullname" . }} + labels: + {{- include "carts-db.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "carts-db.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "carts-db.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}" + {{- with .Values.ports }} + ports: + - name: {{ .name}} + containerPort: {{ .containerPort}} + {{- end }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + - mountPath: {{ .mountPath}} + name: {{ .name}} + {{- end }} + volumes: + {{- toYaml .Values.volumes | nindent 10 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm-charts/carts-db/templates/service.yaml b/helm-charts/carts-db/templates/service.yaml new file mode 100644 index 0000000..8d9e77c --- /dev/null +++ b/helm-charts/carts-db/templates/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "carts-db.fullname" . }} + labels: + {{- include "carts-db.labels" . | nindent 4 }} + namespace: sock-shop +spec: + type: {{ .Values.service.type }} + {{- with .Values.service }} + ports: + - port: {{ .port }} + targetPort: {{ .targetPort }} + {{- end }} + selector: + {{- include "carts-db.selectorLabels" . | nindent 4 }} diff --git a/helm-charts/carts-db/templates/tests/test-connection.yaml b/helm-charts/carts-db/templates/tests/test-connection.yaml new file mode 100644 index 0000000..58a8b6e --- /dev/null +++ b/helm-charts/carts-db/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "carts-db.fullname" . }}-test-connection" + labels: + {{- include "carts-db.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "carts-db.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/carts-db/values.yaml b/helm-charts/carts-db/values.yaml new file mode 100644 index 0000000..ac2a2ff --- /dev/null +++ b/helm-charts/carts-db/values.yaml @@ -0,0 +1,49 @@ +namespace: sock-shop +replicaCount: 1 + +image: + repository: mongo + +ports: + name: mongo + containerPort: 27017 + +securityContext: + capabilities: + drop: + - all + add: + - CHOWN + - SETGID + - SETUID + readOnlyRootFilesystem: true + +volumeMounts: + mountPath: /tmp + name: tmp-volume + +volumes: + - name: tmp-volume + emptyDir: + medium: Memory + + +service: + type: ClusterIP + port: 27017 + targetPort: 27017 + +ingress: + enabled: false + +autoscaling: + enabled: false +# minReplicas: 1 + # maxReplicas: 100 +# targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: + beta.kubernetes.io/os: linux + + diff --git a/helm-charts/carts/.helmignore b/helm-charts/carts/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/carts/.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/helm-charts/carts/Chart.yaml b/helm-charts/carts/Chart.yaml new file mode 100644 index 0000000..fb301ec --- /dev/null +++ b/helm-charts/carts/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: carts +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.16.0" diff --git a/helm-charts/carts/templates/NOTES.txt b/helm-charts/carts/templates/NOTES.txt new file mode 100644 index 0000000..a9383df --- /dev/null +++ b/helm-charts/carts/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "carts.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "carts.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "carts.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "carts.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm-charts/carts/templates/_helpers.tpl b/helm-charts/carts/templates/_helpers.tpl new file mode 100644 index 0000000..edddb1b --- /dev/null +++ b/helm-charts/carts/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "carts.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 "carts.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 "carts.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "carts.labels" -}} +helm.sh/chart: {{ include "carts.chart" . }} +{{ include "carts.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "carts.selectorLabels" -}} +app.kubernetes.io/name: {{ include "carts.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "carts.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "carts.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/carts/templates/deployment.yaml b/helm-charts/carts/templates/deployment.yaml new file mode 100644 index 0000000..6c25c78 --- /dev/null +++ b/helm-charts/carts/templates/deployment.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "carts.fullname" . }} + labels: + {{- include "carts.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "carts.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "carts.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}" + env: + - name: {{ .Values.env.name }} + value: {{ .Values.env.value }} + ports: + - containerPort: {{ .Values.ports.containerPort }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + volumeMounts: + - mountPath: {{ .Values.volumeMounts.mountPath }} + name: {{ .Values.volumeMounts.name }} + volumes: + {{- toYaml .Values.volumes | nindent 10 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm-charts/carts/templates/service.yaml b/helm-charts/carts/templates/service.yaml new file mode 100644 index 0000000..aa514c4 --- /dev/null +++ b/helm-charts/carts/templates/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "carts.fullname" . }} + annotations: + prometheus.io/scrape: {{ .Values.annotations.prometheus | quote }} + labels: + {{- include "carts.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + selector: + {{- include "carts.selectorLabels" . | nindent 4 }} + diff --git a/helm-charts/carts/templates/tests/test-connection.yaml b/helm-charts/carts/templates/tests/test-connection.yaml new file mode 100644 index 0000000..6ad29fb --- /dev/null +++ b/helm-charts/carts/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "carts.fullname" . }}-test-connection" + labels: + {{- include "carts.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "carts.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/carts/values.yaml b/helm-charts/carts/values.yaml new file mode 100644 index 0000000..1881c24 --- /dev/null +++ b/helm-charts/carts/values.yaml @@ -0,0 +1,46 @@ +namespace: sock-shop +replicaCount: 1 +image: + repository: weaveworksdemos/carts:0.4.8 +env: + name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false +ports: + containerPort: 80 +securityContext: + runAsNonRoot: true + runAsUser: 10001 + capabilities: + drop: + - all + add: + - NET_BIND_SERVICE + readOnlyRootFilesystem: true +nodeSelector: + beta.kubernetes.io/os: linux + +service: + type: ClusterIP + port: 80 + targetPort: 80 +ingress: + enabled: false + +volumes: + - name: tmp-volume + emptyDir: + medium: Memory + +volumeMounts: + mountPath: /tmp + name: tmp-volume +autoscaling: + enabled: false + #minReplicas: 1 + #maxReplicas: 100 + #targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 +annotations: + prometheus: 'true' +ingress: + enabled: false diff --git a/helm-charts/catalogue-db/.helmignore b/helm-charts/catalogue-db/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/catalogue-db/.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/helm-charts/catalogue-db/Chart.yaml b/helm-charts/catalogue-db/Chart.yaml new file mode 100644 index 0000000..b682c66 --- /dev/null +++ b/helm-charts/catalogue-db/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: catalogue-db +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.16.0" diff --git a/helm-charts/catalogue-db/templates/NOTES.txt b/helm-charts/catalogue-db/templates/NOTES.txt new file mode 100644 index 0000000..f65c76d --- /dev/null +++ b/helm-charts/catalogue-db/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "catalogue-db.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "catalogue-db.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "catalogue-db.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "catalogue-db.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm-charts/catalogue-db/templates/_helpers.tpl b/helm-charts/catalogue-db/templates/_helpers.tpl new file mode 100644 index 0000000..298f78e --- /dev/null +++ b/helm-charts/catalogue-db/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "catalogue-db.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 "catalogue-db.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 "catalogue-db.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "catalogue-db.labels" -}} +helm.sh/chart: {{ include "catalogue-db.chart" . }} +{{ include "catalogue-db.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "catalogue-db.selectorLabels" -}} +app.kubernetes.io/name: {{ include "catalogue-db.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "catalogue-db.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "catalogue-db.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/catalogue-db/templates/deployment.yaml b/helm-charts/catalogue-db/templates/deployment.yaml new file mode 100644 index 0000000..245ddb4 --- /dev/null +++ b/helm-charts/catalogue-db/templates/deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "catalogue-db.fullname" . }} + labels: + {{- include "catalogue-db.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "catalogue-db.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "catalogue-db.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}" + env: + - name: {{ .Values.env.name1 | upper }} + value: {{ .Values.env.value1 | lower}} + - name: {{ .Values.env.name2 | upper }} + value: {{ .Values.env.value2 | lower}} + ports: + - name: {{ .Values.ports.name }} + containerPort: {{ .Values.ports.containerPort }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + diff --git a/helm-charts/catalogue-db/templates/service.yaml b/helm-charts/catalogue-db/templates/service.yaml new file mode 100644 index 0000000..ee255b5 --- /dev/null +++ b/helm-charts/catalogue-db/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "catalogue-db.fullname" . }} + labels: + {{- include "catalogue-db.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + selector: + {{- include "catalogue-db.selectorLabels" . | nindent 4 }} diff --git a/helm-charts/catalogue-db/templates/tests/test-connection.yaml b/helm-charts/catalogue-db/templates/tests/test-connection.yaml new file mode 100644 index 0000000..6fa5764 --- /dev/null +++ b/helm-charts/catalogue-db/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "catalogue-db.fullname" . }}-test-connection" + labels: + {{- include "catalogue-db.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "catalogue-db.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/catalogue-db/values.yaml b/helm-charts/catalogue-db/values.yaml new file mode 100644 index 0000000..b7723a0 --- /dev/null +++ b/helm-charts/catalogue-db/values.yaml @@ -0,0 +1,36 @@ +namespace: sock-shop +replicaCount: 1 + +image: + repository: weaveworksdemos/catalogue-db:0.3.0 + +env: + name1: Mysql_ROOT_PASSWORD + value1: faKE_password + name2: MYsqL_DATABASE + value2: socksDB + +ports: + name: mysql + containerPort: 3306 + + +nodeSelector: + beta.kubernetes.io/os: linux + +service: + type: ClusterIP + port: 3306 + targetPort: 3306 + +ingress: + enabled: false + +autoscaling: + enabled: false + #minReplicas: 1 + #maxReplicas: 100 + #targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + diff --git a/helm-charts/catalogue/.helmignore b/helm-charts/catalogue/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/catalogue/.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/helm-charts/catalogue/Chart.yaml b/helm-charts/catalogue/Chart.yaml new file mode 100644 index 0000000..1647394 --- /dev/null +++ b/helm-charts/catalogue/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: catalogue +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.16.0" diff --git a/helm-charts/catalogue/templates/NOTES.txt b/helm-charts/catalogue/templates/NOTES.txt new file mode 100644 index 0000000..e8ff57e --- /dev/null +++ b/helm-charts/catalogue/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "catalogue.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "catalogue.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "catalogue.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "catalogue.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm-charts/catalogue/templates/_helpers.tpl b/helm-charts/catalogue/templates/_helpers.tpl new file mode 100644 index 0000000..91457ef --- /dev/null +++ b/helm-charts/catalogue/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "catalogue.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 "catalogue.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 "catalogue.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "catalogue.labels" -}} +helm.sh/chart: {{ include "catalogue.chart" . }} +{{ include "catalogue.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "catalogue.selectorLabels" -}} +app.kubernetes.io/name: {{ include "catalogue.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "catalogue.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "catalogue.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/catalogue/templates/deployment.yaml b/helm-charts/catalogue/templates/deployment.yaml new file mode 100644 index 0000000..82652f2 --- /dev/null +++ b/helm-charts/catalogue/templates/deployment.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "catalogue.fullname" . }} + labels: + {{- include "catalogue.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "catalogue.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "catalogue.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}" + command: [ {{ .Values.command | quote }} ] + args: + {{ toYaml .Values.args | nindent 10 }} + ports: + - containerPort: {{ .Values.ports.containerPort }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 10 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 10 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + diff --git a/helm-charts/catalogue/templates/service.yaml b/helm-charts/catalogue/templates/service.yaml new file mode 100644 index 0000000..f56150e --- /dev/null +++ b/helm-charts/catalogue/templates/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "catalogue.fullname" . }} + annotations: + prometheus.io/scrape: {{ .Values.annotations.prometheus | quote}} + labels: + {{- include "catalogue.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + selector: + {{- include "catalogue.selectorLabels" . | nindent 4 }} + diff --git a/helm-charts/catalogue/templates/tests/test-connection.yaml b/helm-charts/catalogue/templates/tests/test-connection.yaml new file mode 100644 index 0000000..7e7fc7b --- /dev/null +++ b/helm-charts/catalogue/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "catalogue.fullname" . }}-test-connection" + labels: + {{- include "catalogue.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "catalogue.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/catalogue/values.yaml b/helm-charts/catalogue/values.yaml new file mode 100644 index 0000000..2c19cf5 --- /dev/null +++ b/helm-charts/catalogue/values.yaml @@ -0,0 +1,57 @@ +namespace: sock-shop +replicaCount: 1 + +image: + repository: weaveworksdemos/catalogue:0.3.5 + +command: /app +args: +- -port=80 + +ports: + containerPort: 80 + +securityContext: + runAsNonRoot: true + runAsUser: 10001 + capabilities: + drop: + - all + add: + - NET_BIND_SERVICE + readOnlyRootFilesystem: true + +livenessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 5 + periodSeconds: 3 + +readinessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 5 + periodSeconds: 3 + +nodeSelector: + beta.kubernetes.io/os: linux + +service: + type: ClusterIP + port: 80 + targetPort: 80 + +ingress: + enabled: false + +autoscaling: + enabled: false + #minReplicas: 1 + #maxReplicas: 100 + #targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +annotations: + prometheus: 'true' + + diff --git a/helm-charts/front-end/.helmignore b/helm-charts/front-end/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/front-end/.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/helm-charts/front-end/Chart.yaml b/helm-charts/front-end/Chart.yaml new file mode 100644 index 0000000..98954f1 --- /dev/null +++ b/helm-charts/front-end/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: front-end +description: A Helm chart for Front End + +# 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.16.0" diff --git a/helm-charts/front-end/templates/10-front-end-svc.yaml b/helm-charts/front-end/templates/10-front-end-svc.yaml new file mode 100644 index 0000000..c3dd956 --- /dev/null +++ b/helm-charts/front-end/templates/10-front-end-svc.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "front-end.fullname" . }} + annotations: + prometheus.io/scrape: {{ .Values.annotations.prometheus | quote}} + labels: + {{- include "front-end.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + nodePort: {{ .Values.service.nodePort }} + selector: + {{- include "front-end.selectorLabels" . | nindent 4 }} diff --git a/helm-charts/front-end/templates/NOTES.txt b/helm-charts/front-end/templates/NOTES.txt new file mode 100644 index 0000000..2b35595 --- /dev/null +++ b/helm-charts/front-end/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "front-end.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "front-end.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "front-end.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "front-end.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm-charts/front-end/templates/_helpers.tpl b/helm-charts/front-end/templates/_helpers.tpl new file mode 100644 index 0000000..191b7dd --- /dev/null +++ b/helm-charts/front-end/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "front-end.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 "front-end.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 "front-end.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "front-end.labels" -}} +helm.sh/chart: {{ include "front-end.chart" . }} +{{ include "front-end.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "front-end.selectorLabels" -}} +app.kubernetes.io/name: {{ include "front-end.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "front-end.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "front-end.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/front-end/templates/deployment.yaml b/helm-charts/front-end/templates/deployment.yaml new file mode 100644 index 0000000..3f5b343 --- /dev/null +++ b/helm-charts/front-end/templates/deployment.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "front-end.fullname" . }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "front-end.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "front-end.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}" + ports: + - containerPort: {{ .Values.ports.containerPort }} + env: + - name: {{ .Values.env.name | upper }} + value: {{ .Values.env.value | lower | quote }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 10 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 10 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + diff --git a/helm-charts/front-end/templates/front-end-network-policy.yaml b/helm-charts/front-end/templates/front-end-network-policy.yaml new file mode 100644 index 0000000..401ec00 --- /dev/null +++ b/helm-charts/front-end/templates/front-end-network-policy.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ include "front-end.fullname" . }} + namespace: {{ .Values.namespace }} +spec: + podSelector: + matchLabels: + {{- include "front-end.selectorLabels" . | nindent 6 }} + ingress: + - ports: + - protocol: TCP + port: {{ .Values.ports.containerPort }} diff --git a/helm-charts/front-end/templates/tests/test-connection.yaml b/helm-charts/front-end/templates/tests/test-connection.yaml new file mode 100644 index 0000000..b930bd7 --- /dev/null +++ b/helm-charts/front-end/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "front-end.fullname" . }}-test-connection" + labels: + {{- include "front-end.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "front-end.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/front-end/values.yaml b/helm-charts/front-end/values.yaml new file mode 100644 index 0000000..c8e6a2b --- /dev/null +++ b/helm-charts/front-end/values.yaml @@ -0,0 +1,57 @@ +namespace: sock-shop +replicaCount: 1 + +image: + repository: weaveworksdemos/front-end:0.3.12 + + +ports: + containerPort: 8079 + +env: + name: SESSION_redis + value: "true" + +securityContext: + runAsNonRoot: true + runAsUser: 10001 + capabilities: + drop: + - all + readOnlyRootFilesystem: true + +livenessProbe: + tcpSocket: + port: 8079 + initialDelaySeconds: 5 + periodSeconds: 3 + +readinessProbe: + tcpSocket: + port: 8079 + initialDelaySeconds: 5 + periodSeconds: 3 + +nodeSelector: + beta.kubernetes.io/os: linux + +service: + type: NodePort + port: 80 + targetPort: 8079 + nodePort: 30001 + +ingress: + enabled: false + +autoscaling: + enabled: false + #minReplicas: 1 + #maxReplicas: 100 + #targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +annotations: + prometheus: true + + diff --git a/helm-charts/orders-db/.helmignore b/helm-charts/orders-db/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/orders-db/.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/helm-charts/orders-db/Chart.yaml b/helm-charts/orders-db/Chart.yaml new file mode 100644 index 0000000..ec71589 --- /dev/null +++ b/helm-charts/orders-db/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: orders-db +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.16.0" diff --git a/helm-charts/orders-db/templates/13-orders-db-dep.yaml b/helm-charts/orders-db/templates/13-orders-db-dep.yaml new file mode 100644 index 0000000..e3600dd --- /dev/null +++ b/helm-charts/orders-db/templates/13-orders-db-dep.yaml @@ -0,0 +1,40 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "orders-db.fullname" . }} + labels: + {{- include "orders-db.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "orders-db.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "orders-db.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image.repository }} + ports: + - name: mongo + containerPort: 27017 + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + volumeMounts: + - mountPath: {{ .Values.volumes.mountPath }} + name: {{ .Values.volumes.name }} + volumes: + - name: {{ .Values.volumes.name }} + emptyDir: + medium: Memory + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + diff --git a/helm-charts/orders-db/templates/14-orders-db-svc.yaml b/helm-charts/orders-db/templates/14-orders-db-svc.yaml new file mode 100644 index 0000000..d0490b6 --- /dev/null +++ b/helm-charts/orders-db/templates/14-orders-db-svc.yaml @@ -0,0 +1,18 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "orders-db.fullname" . }} + labels: + {{- include "orders-db.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + ports: + # the port that this service should serve on + {{- with .Values.service }} + - port: {{ .port }} + targetPort: {{ .targetPort }} + {{- end }} + selector: + {{- include "orders-db.selectorLabels" . | nindent 4 }} + diff --git a/helm-charts/orders-db/templates/NOTES.txt b/helm-charts/orders-db/templates/NOTES.txt new file mode 100644 index 0000000..42db1fa --- /dev/null +++ b/helm-charts/orders-db/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "orders-db.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "orders-db.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "orders-db.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "orders-db.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm-charts/orders-db/templates/_helpers.tpl b/helm-charts/orders-db/templates/_helpers.tpl new file mode 100644 index 0000000..dc4c488 --- /dev/null +++ b/helm-charts/orders-db/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "orders-db.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 "orders-db.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 "orders-db.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "orders-db.labels" -}} +helm.sh/chart: {{ include "orders-db.chart" . }} +{{ include "orders-db.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "orders-db.selectorLabels" -}} +app.kubernetes.io/name: {{ include "orders-db.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "orders-db.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "orders-db.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/orders-db/templates/tests/test-connection.yaml b/helm-charts/orders-db/templates/tests/test-connection.yaml new file mode 100644 index 0000000..fb37db8 --- /dev/null +++ b/helm-charts/orders-db/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "orders-db.fullname" . }}-test-connection" + labels: + {{- include "orders-db.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "orders-db.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/orders-db/values.yaml b/helm-charts/orders-db/values.yaml new file mode 100644 index 0000000..a7d36ea --- /dev/null +++ b/helm-charts/orders-db/values.yaml @@ -0,0 +1,36 @@ +namespace: sock-shop + +replicaCount: 1 + +image: + repository: mongo + +securityContext: + capabilities: + drop: + - all + add: + - CHOWN + - SETGID + - SETUID + readOnlyRootFilesystem: true + +volumes: + mountPath: /tmp + name: tmp-volume + +service: + type: ClusterIP + port: 27017 + targetPort: 27017 + +ingress: + enabled: false + +autoscaling: + enabled: false + +nodeSelector: + beta.kubernetes.io/os: linux + + diff --git a/helm-charts/orders/.helmignore b/helm-charts/orders/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/orders/.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/helm-charts/orders/Chart.yaml b/helm-charts/orders/Chart.yaml new file mode 100644 index 0000000..17e0416 --- /dev/null +++ b/helm-charts/orders/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: orders +description: A Helm chart for Orders + +# 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.16.0" diff --git a/helm-charts/orders/templates/11-orders-dep.yaml b/helm-charts/orders/templates/11-orders-dep.yaml new file mode 100644 index 0000000..3da41f5 --- /dev/null +++ b/helm-charts/orders/templates/11-orders-dep.yaml @@ -0,0 +1,41 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "orders.fullname" . }} + labels: + {{- include "orders.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "orders.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "orders.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + env: + - name: {{ .Values.env.name }} + value: {{ .Values.env.value }} + ports: + - containerPort: 80 + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + volumeMounts: + - mountPath: {{ .Values.volume.volumeMountPath }} + name: {{ .Values.volume.name }} + volumes: + - name: {{ .Values.volume.name }} + emptyDir: + medium: Memory + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm-charts/orders/templates/12-orders-svc.yaml b/helm-charts/orders/templates/12-orders-svc.yaml new file mode 100644 index 0000000..10d6ce9 --- /dev/null +++ b/helm-charts/orders/templates/12-orders-svc.yaml @@ -0,0 +1,18 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "orders.fullname" . }} + annotations: + prometheus.io/scrape: {{ .Values.prometheus | quote }} + labels: + {{- include "orders.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + ports: + # the port that this service should serve on + - port: {{ .Values.service.port }} + targetPort: 80 + selector: + {{- include "orders.selectorLabels" . | nindent 4 }} + diff --git a/helm-charts/orders/templates/NOTES.txt b/helm-charts/orders/templates/NOTES.txt new file mode 100644 index 0000000..b46066d --- /dev/null +++ b/helm-charts/orders/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "orders.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "orders.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "orders.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "orders.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm-charts/orders/templates/_helpers.tpl b/helm-charts/orders/templates/_helpers.tpl new file mode 100644 index 0000000..f35ea31 --- /dev/null +++ b/helm-charts/orders/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "orders.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 "orders.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 "orders.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "orders.labels" -}} +helm.sh/chart: {{ include "orders.chart" . }} +{{ include "orders.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "orders.selectorLabels" -}} +app.kubernetes.io/name: {{ include "orders.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "orders.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "orders.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/orders/templates/tests/test-connection.yaml b/helm-charts/orders/templates/tests/test-connection.yaml new file mode 100644 index 0000000..449d014 --- /dev/null +++ b/helm-charts/orders/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "orders.fullname" . }}-test-connection" + labels: + {{- include "orders.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "orders.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/orders/values.yaml b/helm-charts/orders/values.yaml new file mode 100644 index 0000000..8561515 --- /dev/null +++ b/helm-charts/orders/values.yaml @@ -0,0 +1,59 @@ + +namespace: sock-shop + +replicaCount: 1 + +image: + repository: weaveworksdemos/orders + tag: "0.4.7" + +env: + name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + +securityContext: + runAsNonRoot: true + runAsUser: 10001 + capabilities: + drop: + - all + add: + - NET_BIND_SERVICE + readOnlyRootFilesystem: true + +volume: + volumeMountPath: /tmp + name: tmp-volume + +prometheus: true + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +autoscaling: + enabled: false + # minReplicas: 1 + # maxReplicas: 100 + # targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: + beta.kubernetes.io/os: linux + diff --git a/helm-charts/payment/.helmignore b/helm-charts/payment/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/payment/.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/helm-charts/payment/Chart.yaml b/helm-charts/payment/Chart.yaml new file mode 100644 index 0000000..13bc7ca --- /dev/null +++ b/helm-charts/payment/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: payment +description: A Helm chart for Payment + +# 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.16.0" diff --git a/helm-charts/payment/templates/15-payment-dep.yaml b/helm-charts/payment/templates/15-payment-dep.yaml new file mode 100644 index 0000000..d9132aa --- /dev/null +++ b/helm-charts/payment/templates/15-payment-dep.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "payment.fullname" . }} + labels: + {{- include "payment.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "payment.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "payment.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + ports: + - containerPort: 80 + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + livenessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 5 + periodSeconds: 3 + readinessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 5 + periodSeconds: 3 + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + diff --git a/helm-charts/payment/templates/16-payment-svc.yaml b/helm-charts/payment/templates/16-payment-svc.yaml new file mode 100644 index 0000000..263660c --- /dev/null +++ b/helm-charts/payment/templates/16-payment-svc.yaml @@ -0,0 +1,18 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "payment.fullname" . }} + annotations: + prometheus.io/scrape: {{ .Values.prometheus | quote }} + labels: + {{- include "payment.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + ports: + # the port that this service should serve on + - port: {{ .Values.service.port }} + targetPort: 80 + selector: + {{- include "payment.selectorLabels" . | nindent 4 }} + diff --git a/helm-charts/payment/templates/NOTES.txt b/helm-charts/payment/templates/NOTES.txt new file mode 100644 index 0000000..21ed4b4 --- /dev/null +++ b/helm-charts/payment/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "payment.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "payment.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "payment.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "payment.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm-charts/payment/templates/_helpers.tpl b/helm-charts/payment/templates/_helpers.tpl new file mode 100644 index 0000000..74b097c --- /dev/null +++ b/helm-charts/payment/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "payment.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 "payment.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 "payment.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "payment.labels" -}} +helm.sh/chart: {{ include "payment.chart" . }} +{{ include "payment.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "payment.selectorLabels" -}} +app.kubernetes.io/name: {{ include "payment.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "payment.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "payment.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/payment/templates/tests/test-connection.yaml b/helm-charts/payment/templates/tests/test-connection.yaml new file mode 100644 index 0000000..1506adc --- /dev/null +++ b/helm-charts/payment/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "payment.fullname" . }}-test-connection" + labels: + {{- include "payment.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "payment.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/payment/values.yaml b/helm-charts/payment/values.yaml new file mode 100644 index 0000000..b027d0e --- /dev/null +++ b/helm-charts/payment/values.yaml @@ -0,0 +1,34 @@ + +namespace: sock-shop + +replicaCount: 1 + +image: + repository: weaveworksdemos/payment + tag: "0.4.3" + +securityContext: + runAsNonRoot: true + runAsUser: 10001 + capabilities: + drop: + - all + add: + - NET_BIND_SERVICE + readOnlyRootFilesystem: true + +prometheus: true + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + +autoscaling: + enabled: false + +nodeSelector: + beta.kubernetes.io/os: linux + diff --git a/helm-charts/queue-master/.helmignore b/helm-charts/queue-master/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/queue-master/.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/helm-charts/queue-master/Chart.yaml b/helm-charts/queue-master/Chart.yaml new file mode 100644 index 0000000..54814b7 --- /dev/null +++ b/helm-charts/queue-master/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: queue-master +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.16.0" diff --git a/helm-charts/queue-master/templates/17-queue-master-dep.yaml b/helm-charts/queue-master/templates/17-queue-master-dep.yaml new file mode 100644 index 0000000..14df02a --- /dev/null +++ b/helm-charts/queue-master/templates/17-queue-master-dep.yaml @@ -0,0 +1,33 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "queue-master.fullname" . }} + labels: + {{- include "queue-master.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "queue-master.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "queue-master.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + env: + - name: {{ .Values.env.name | upper }} + value: {{ .Values.env.value }} + ports: + - containerPort: 80 + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + diff --git a/helm-charts/queue-master/templates/18-queue-master-svc.yaml b/helm-charts/queue-master/templates/18-queue-master-svc.yaml new file mode 100644 index 0000000..bc959c5 --- /dev/null +++ b/helm-charts/queue-master/templates/18-queue-master-svc.yaml @@ -0,0 +1,18 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "queue-master.fullname" . }} + annotations: + prometheus.io/scrape: {{ .Values.prometheus | quote }} + labels: + {{- include "queue-master.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + ports: + # the port that this service should serve on + - port: {{ .Values.service.port }} + targetPort: 80 + selector: + {{- include "queue-master.selectorLabels" . | nindent 4 }} + diff --git a/helm-charts/queue-master/templates/NOTES.txt b/helm-charts/queue-master/templates/NOTES.txt new file mode 100644 index 0000000..38b18a1 --- /dev/null +++ b/helm-charts/queue-master/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "queue-master.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "queue-master.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "queue-master.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "queue-master.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm-charts/queue-master/templates/_helpers.tpl b/helm-charts/queue-master/templates/_helpers.tpl new file mode 100644 index 0000000..60011e9 --- /dev/null +++ b/helm-charts/queue-master/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "queue-master.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 "queue-master.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 "queue-master.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "queue-master.labels" -}} +helm.sh/chart: {{ include "queue-master.chart" . }} +{{ include "queue-master.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "queue-master.selectorLabels" -}} +app.kubernetes.io/name: {{ include "queue-master.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "queue-master.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "queue-master.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/queue-master/templates/tests/test-connection.yaml b/helm-charts/queue-master/templates/tests/test-connection.yaml new file mode 100644 index 0000000..2dc859f --- /dev/null +++ b/helm-charts/queue-master/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "queue-master.fullname" . }}-test-connection" + labels: + {{- include "queue-master.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "queue-master.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/queue-master/values.yaml b/helm-charts/queue-master/values.yaml new file mode 100644 index 0000000..06ff659 --- /dev/null +++ b/helm-charts/queue-master/values.yaml @@ -0,0 +1,28 @@ +namespace: sock-shop + +replicaCount: 1 + +image: + repository: weaveworksdemos/queue-master + tag: "0.3.1" + +env: + name: JAVA_OPTS + value: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + +prometheus: true + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + +autoscaling: + enabled: false + +nodeSelector: + beta.kubernetes.io/os: linux + + diff --git a/helm-charts/rabbitmq/.helmignore b/helm-charts/rabbitmq/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/rabbitmq/.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/helm-charts/rabbitmq/Chart.yaml b/helm-charts/rabbitmq/Chart.yaml new file mode 100644 index 0000000..a54865f --- /dev/null +++ b/helm-charts/rabbitmq/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: rabbitmq +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.16.0" diff --git a/helm-charts/rabbitmq/templates/19-rabbitmq-dep.yaml b/helm-charts/rabbitmq/templates/19-rabbitmq-dep.yaml new file mode 100644 index 0000000..91d9a81 --- /dev/null +++ b/helm-charts/rabbitmq/templates/19-rabbitmq-dep.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "rabbitmq.fullname" . }} + labels: + {{- include "rabbitmq.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "rabbitmq.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "rabbitmq.selectorLabels" . | nindent 8 }} + annotations: + prometheus.io/scrape: {{ .Values.prometheus | quote }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + ports: + - containerPort: 15672 + name: management + - containerPort: 5672 + name: rabbitmq + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + - name: {{ .Values.export.name }} + image: {{ .Values.export.image }} + ports: + - containerPort: 9090 + name: exporter + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + diff --git a/helm-charts/rabbitmq/templates/_helpers.tpl b/helm-charts/rabbitmq/templates/_helpers.tpl new file mode 100644 index 0000000..0e218d7 --- /dev/null +++ b/helm-charts/rabbitmq/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "rabbitmq.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 "rabbitmq.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 "rabbitmq.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "rabbitmq.labels" -}} +helm.sh/chart: {{ include "rabbitmq.chart" . }} +{{ include "rabbitmq.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "rabbitmq.selectorLabels" -}} +app.kubernetes.io/name: {{ include "rabbitmq.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "rabbitmq.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "rabbitmq.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/rabbitmq/templates/service.yaml b/helm-charts/rabbitmq/templates/service.yaml new file mode 100644 index 0000000..66b627e --- /dev/null +++ b/helm-charts/rabbitmq/templates/service.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: Service +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "rabbitmq.fullname" . }} + annotations: + prometheus.io/scrape: {{ .Values.annotations.prometheus.scrape | quote }} + prometheus.io/port: {{ .Values.annotations.prometheus.port | quote }} + labels: + {{- include "rabbitmq.labels" . | nindent 4 }} +spec: + ports: + - port: {{ .Values.service.port }} + name: {{ .Values.service.name }} + targetPort: {{ .Values.service.targetPort }} + - port: {{ .Values.exporter.port }} + name: {{ .Values.exporter.name }} + targetPort: {{ .Values.exporter.targetPort }} + protocol: {{.Values.exporter.type}} + selector: + {{- include "rabbitmq.selectorLabels" . | nindent 4 }} + diff --git a/helm-charts/rabbitmq/templates/tests/test-connection.yaml b/helm-charts/rabbitmq/templates/tests/test-connection.yaml new file mode 100644 index 0000000..302f4f4 --- /dev/null +++ b/helm-charts/rabbitmq/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "rabbitmq.fullname" . }}-test-connection" + labels: + {{- include "rabbitmq.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "rabbitmq.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/rabbitmq/values.yaml b/helm-charts/rabbitmq/values.yaml new file mode 100644 index 0000000..7df0ee9 --- /dev/null +++ b/helm-charts/rabbitmq/values.yaml @@ -0,0 +1,51 @@ + +namespace: sock-shop + +replicaCount: 1 + +prometheus: false + +image: + repository: rabbitmq + tag: "3.6.8-management" + +annotations: + prometheus: + scrape: true + port: 9090 + +securityContext: + capabilities: + drop: + - all + add: + - CHOWN + - SETGID + - SETUID + - DAC_OVERRIDE + readOnlyRootFilesystem: true + +export: + name: rabbitmq-exporter + image: kbudde/rabbitmq-exporter + +service: + targetPort: 5672 + port: 5672 + name: rabbitmq + +exporter: + port: 9090 + name: exporter + targetPort: exporter + type: TCP + +ingress: + enabled: false + +autoscaling: + enabled: false + +nodeSelector: + beta.kubernetes.io/os: linux + diff --git a/helm-charts/session-db/.helmignore b/helm-charts/session-db/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/session-db/.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/helm-charts/session-db/Chart.yaml b/helm-charts/session-db/Chart.yaml new file mode 100644 index 0000000..e2a0c04 --- /dev/null +++ b/helm-charts/session-db/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: session-db +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.16.0" diff --git a/helm-charts/session-db/templates/_helpers.tpl b/helm-charts/session-db/templates/_helpers.tpl new file mode 100644 index 0000000..d2e27e0 --- /dev/null +++ b/helm-charts/session-db/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "session-db.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 "session-db.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 "session-db.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "session-db.labels" -}} +helm.sh/chart: {{ include "session-db.chart" . }} +{{ include "session-db.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "session-db.selectorLabels" -}} +app.kubernetes.io/name: {{ include "session-db.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "session-db.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "session-db.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/session-db/templates/deployment.yaml b/helm-charts/session-db/templates/deployment.yaml new file mode 100644 index 0000000..c6f7b30 --- /dev/null +++ b/helm-charts/session-db/templates/deployment.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "session-db.fullname" . }} + labels: + {{- include "session-db.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "session-db.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "session-db.selectorLabels" . | nindent 8 }} + annotations: + prometheus.io.scrape: {{ .Values.annotations.prometheus.scrape | quote }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}" + ports: + - name: "{{ .Values.ports.name }}" + containerPort: {{ .Values.ports.containerPort }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm-charts/session-db/templates/service.yaml b/helm-charts/session-db/templates/service.yaml new file mode 100644 index 0000000..db18cbd --- /dev/null +++ b/helm-charts/session-db/templates/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "session-db.fullname" . }} + labels: + {{- include "session-db.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + selector: + {{- include "session-db.selectorLabels" . | nindent 4 }} diff --git a/helm-charts/session-db/templates/tests/test-connection.yaml b/helm-charts/session-db/templates/tests/test-connection.yaml new file mode 100644 index 0000000..df6f00f --- /dev/null +++ b/helm-charts/session-db/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "session-db.fullname" . }}-test-connection" + labels: + {{- include "session-db.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "session-db.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/session-db/values.yaml b/helm-charts/session-db/values.yaml new file mode 100644 index 0000000..f908eda --- /dev/null +++ b/helm-charts/session-db/values.yaml @@ -0,0 +1,30 @@ +--- +namespace: sock-shop +replicaCount: 1 + +image: + repository: redis:alpine + +annotations: + prometheus : + scrape: false + +service: + port: 6379 + targetPort: 6379 + +ports: + name: redis + containerPort: 6379 + +securityContext: + capabilities: + drop: + - all + add: + - CHOWN + - SETGID + - SETUID + readOnlyRootFilesystem: true +nodeSelector: + beta.kubernetes.io/os: linux diff --git a/helm-charts/shipping/.helmignore b/helm-charts/shipping/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/shipping/.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/helm-charts/shipping/Chart.yaml b/helm-charts/shipping/Chart.yaml new file mode 100644 index 0000000..9029f0d --- /dev/null +++ b/helm-charts/shipping/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: shipping +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.16.0" diff --git a/helm-charts/shipping/templates/_helpers.tpl b/helm-charts/shipping/templates/_helpers.tpl new file mode 100644 index 0000000..f08b18d --- /dev/null +++ b/helm-charts/shipping/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "shipping.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 "shipping.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 "shipping.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "shipping.labels" -}} +helm.sh/chart: {{ include "shipping.chart" . }} +{{ include "shipping.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "shipping.selectorLabels" -}} +app.kubernetes.io/name: {{ include "shipping.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "shipping.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "shipping.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/shipping/templates/deployment.yaml b/helm-charts/shipping/templates/deployment.yaml new file mode 100644 index 0000000..c1f8773 --- /dev/null +++ b/helm-charts/shipping/templates/deployment.yaml @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "shipping.fullname" . }} + labels: + {{- include "shipping.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "shipping.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "shipping.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image.repository }} + + env: + - name: {{ .Values.env.name1 }} + value: {{ .Values.env.value1 }} + - name: {{ .Values.env.name2 }} + value: {{ .Values.env.value2 }} + + ports: + - containerPort: {{ .Values.ports.containerPort }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + volumeMounts: + - mountPath: "{{ .Values.volumeMounts.mountPath }}" + name: "{{ .Values.volumeMounts.name }}" + volumes: + {{- toYaml .Values.volumes | nindent 10 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm-charts/shipping/templates/service.yaml b/helm-charts/shipping/templates/service.yaml new file mode 100644 index 0000000..89d057d --- /dev/null +++ b/helm-charts/shipping/templates/service.yaml @@ -0,0 +1,17 @@ +--- + +apiVersion: v1 +kind: Service +metadata: + name: {{ include "shipping.fullname" . }} + annotations: + prometheus.io/scrape: {{ .Values.annotations.prometheus.scrape | quote }} + labels: + {{- include "shipping.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + selector: + {{- include "shipping.selectorLabels" . | nindent 4 }} diff --git a/helm-charts/shipping/templates/tests/test-connection.yaml b/helm-charts/shipping/templates/tests/test-connection.yaml new file mode 100644 index 0000000..334300a --- /dev/null +++ b/helm-charts/shipping/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "shipping.fullname" . }}-test-connection" + labels: + {{- include "shipping.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "shipping.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/shipping/values.yaml b/helm-charts/shipping/values.yaml new file mode 100644 index 0000000..1aaea1d --- /dev/null +++ b/helm-charts/shipping/values.yaml @@ -0,0 +1,43 @@ +--- +namespace: sock-shop +replicaCount: 1 + +image: + repository: weaveworksdemos/shipping:0.4.8 + +annotations: + prometheus: + scrape: true + +service: + port: 80 + targetPort: 80 + +ports: + containerPort: 80 + +securityContext: + runAsNonRoot: true + runAsUser: 10001 + capabilities: + drop: + - all + add: + - NET_BIND_SERVICE + readOnlyRootFilesystem: true + +volumeMounts: + mountPath: /tmp + name: tmp-volume +volumes: + - name: tmp-volume + emptyDir: + medium: Memory +env: + name1: ZIPKIN + value1: zipkin.jaeger.svc.cluster.local + name2: JAVA_OPTS + value2: -Xms64m -Xmx128m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.zipkin.enabled=false + +nodeSelector: + beta.kubernetes.io/os: linux diff --git a/helm-charts/user-db/.helmignore b/helm-charts/user-db/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/user-db/.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/helm-charts/user-db/Chart.yaml b/helm-charts/user-db/Chart.yaml new file mode 100644 index 0000000..3dc9ddb --- /dev/null +++ b/helm-charts/user-db/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: user-db +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.16.0" diff --git a/helm-charts/user-db/templates/_helpers.tpl b/helm-charts/user-db/templates/_helpers.tpl new file mode 100644 index 0000000..50b1ae6 --- /dev/null +++ b/helm-charts/user-db/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "user-db.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 "user-db.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 "user-db.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "user-db.labels" -}} +helm.sh/chart: {{ include "user-db.chart" . }} +{{ include "user-db.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "user-db.selectorLabels" -}} +app.kubernetes.io/name: {{ include "user-db.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "user-db.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "user-db.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/user-db/templates/deployment.yaml b/helm-charts/user-db/templates/deployment.yaml new file mode 100644 index 0000000..1c1c248 --- /dev/null +++ b/helm-charts/user-db/templates/deployment.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "user-db.fullname" . }} + labels: + {{- include "user-db.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "user-db.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "user-db.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}" + ports: + - name: {{ .Values.ports.name }} + containerPort: {{ .Values.ports.containerPort }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + - mountPath: {{ .mountPath }} + name: {{ .name }} + {{- end }} + volumes: + {{- toYaml .Values.volumes | nindent 10 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm-charts/user-db/templates/service.yaml b/helm-charts/user-db/templates/service.yaml new file mode 100644 index 0000000..a9579e8 --- /dev/null +++ b/helm-charts/user-db/templates/service.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "user-db.fullname" . }} + labels: + {{- include "user-db.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + selector: + {{- include "user-db.selectorLabels" . | nindent 4 }} diff --git a/helm-charts/user-db/templates/tests/test-connection.yaml b/helm-charts/user-db/templates/tests/test-connection.yaml new file mode 100644 index 0000000..c452fb0 --- /dev/null +++ b/helm-charts/user-db/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "user-db.fullname" . }}-test-connection" + labels: + {{- include "user-db.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "user-db.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/user-db/values.yaml b/helm-charts/user-db/values.yaml new file mode 100644 index 0000000..5120179 --- /dev/null +++ b/helm-charts/user-db/values.yaml @@ -0,0 +1,38 @@ +--- +namespace: sock-shop +replicaCount: 1 + +image: + repository: weaveworksdemos/user-db:0.3.0 + +annotations: + prometheus: + scrape: true + +service: + port: 27017 + targetPort: 27017 + +ports: + name: mongo + containerPort: 27017 + +securityContext: + capabilities: + drop: + - all + add: + - CHOWN + - SETGID + - SETUID + + readOnlyRootFilesystem: true +volumeMounts: + mountPath: /tmp + name: tmp-volume +volumes: + - name: tmp-volume + emptyDir: + medium: Memory +nodeSelector: + beta.kubernetes.io/os: linux diff --git a/helm-charts/user/.helmignore b/helm-charts/user/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm-charts/user/.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/helm-charts/user/Chart.yaml b/helm-charts/user/Chart.yaml new file mode 100644 index 0000000..8bfcab6 --- /dev/null +++ b/helm-charts/user/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: user +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.16.0" diff --git a/helm-charts/user/templates/_helpers.tpl b/helm-charts/user/templates/_helpers.tpl new file mode 100644 index 0000000..29b2a93 --- /dev/null +++ b/helm-charts/user/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "user.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 "user.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 "user.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "user.labels" -}} +helm.sh/chart: {{ include "user.chart" . }} +{{ include "user.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "user.selectorLabels" -}} +app.kubernetes.io/name: {{ include "user.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "user.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "user.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/user/templates/deployment.yaml b/helm-charts/user/templates/deployment.yaml new file mode 100644 index 0000000..073867a --- /dev/null +++ b/helm-charts/user/templates/deployment.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "user.fullname" . }} + labels: + {{- include "user.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "user.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "user.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}" + env: + - name: {{ .Values.env.name }} + value: {{ .Values.env.value }} + ports: + - containerPort: {{ .Values.ports.containerPort }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + + + diff --git a/helm-charts/user/templates/hpa.yaml b/helm-charts/user/templates/hpa.yaml new file mode 100644 index 0000000..3a5d3e2 --- /dev/null +++ b/helm-charts/user/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "user.fullname" . }} + labels: + {{- include "user.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "user.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/helm-charts/user/templates/ingress.yaml b/helm-charts/user/templates/ingress.yaml new file mode 100644 index 0000000..c506250 --- /dev/null +++ b/helm-charts/user/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "user.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "user.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/helm-charts/user/templates/service.yaml b/helm-charts/user/templates/service.yaml new file mode 100644 index 0000000..3cfbe2c --- /dev/null +++ b/helm-charts/user/templates/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "user.fullname" . }} + labels: + {{- include "user.labels" . | nindent 4 }} + annotations: + prometheus.io/scrape: {{ .Values.annotations.prometheus.scrape | quote }} + namespace: {{ .Values.namespace }} +spec: + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + selector: + {{- include "user.selectorLabels" . | nindent 4 }} + + diff --git a/helm-charts/user/templates/tests/test-connection.yaml b/helm-charts/user/templates/tests/test-connection.yaml new file mode 100644 index 0000000..bdfd1fd --- /dev/null +++ b/helm-charts/user/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "user.fullname" . }}-test-connection" + labels: + {{- include "user.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "user.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm-charts/user/values.yaml b/helm-charts/user/values.yaml new file mode 100644 index 0000000..22d73d2 --- /dev/null +++ b/helm-charts/user/values.yaml @@ -0,0 +1,44 @@ +--- +namespace: sock-shop +replicaCount: 1 + +image: + repository: weaveworksdemos/user:0.4.7 + +annotations: + prometheus: + scrape: true + +env: + name: mongo + value: user-db:27017 + +service: + port: 80 + targetPort: 80 + +ports: + containerPort: 80 + +securityContext: + runAsNonRoot: true + runAsUser: 10001 + capabilities: + drop: + - all + add: + - NET_BIND_SERVICE + readOnlyRootFilesystem: true +ingress: + enabled: false + +autoscaling: + enabled: false + #minReplicas: 1 + #maxReplicas: 100 + #targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: + beta.kubernetes.io/os: linux +