From 9f07e3b70ef75880b01435b4b1ad636a45d9b2d4 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 7 Oct 2021 16:57:00 +0300 Subject: [PATCH 01/12] added default helm chart --- etc/k8s/eshoponabp/.helmignore | 23 ++++++ etc/k8s/eshoponabp/Chart.yaml | 24 ++++++ etc/k8s/eshoponabp/templates/NOTES.txt | 22 +++++ etc/k8s/eshoponabp/templates/_helpers.tpl | 62 ++++++++++++++ etc/k8s/eshoponabp/templates/deployment.yaml | 61 ++++++++++++++ etc/k8s/eshoponabp/templates/hpa.yaml | 28 +++++++ etc/k8s/eshoponabp/templates/ingress.yaml | 61 ++++++++++++++ etc/k8s/eshoponabp/templates/service.yaml | 15 ++++ .../eshoponabp/templates/serviceaccount.yaml | 12 +++ .../templates/tests/test-connection.yaml | 15 ++++ etc/k8s/eshoponabp/values.yaml | 82 +++++++++++++++++++ 11 files changed, 405 insertions(+) create mode 100644 etc/k8s/eshoponabp/.helmignore create mode 100644 etc/k8s/eshoponabp/Chart.yaml create mode 100644 etc/k8s/eshoponabp/templates/NOTES.txt create mode 100644 etc/k8s/eshoponabp/templates/_helpers.tpl create mode 100644 etc/k8s/eshoponabp/templates/deployment.yaml create mode 100644 etc/k8s/eshoponabp/templates/hpa.yaml create mode 100644 etc/k8s/eshoponabp/templates/ingress.yaml create mode 100644 etc/k8s/eshoponabp/templates/service.yaml create mode 100644 etc/k8s/eshoponabp/templates/serviceaccount.yaml create mode 100644 etc/k8s/eshoponabp/templates/tests/test-connection.yaml create mode 100644 etc/k8s/eshoponabp/values.yaml diff --git a/etc/k8s/eshoponabp/.helmignore b/etc/k8s/eshoponabp/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/etc/k8s/eshoponabp/.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/etc/k8s/eshoponabp/Chart.yaml b/etc/k8s/eshoponabp/Chart.yaml new file mode 100644 index 00000000..a1801db0 --- /dev/null +++ b/etc/k8s/eshoponabp/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: eshoponabp +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/etc/k8s/eshoponabp/templates/NOTES.txt b/etc/k8s/eshoponabp/templates/NOTES.txt new file mode 100644 index 00000000..c9abfbdb --- /dev/null +++ b/etc/k8s/eshoponabp/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 "eshoponabp.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 "eshoponabp.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "eshoponabp.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 "eshoponabp.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/etc/k8s/eshoponabp/templates/_helpers.tpl b/etc/k8s/eshoponabp/templates/_helpers.tpl new file mode 100644 index 00000000..901e5bb0 --- /dev/null +++ b/etc/k8s/eshoponabp/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "eshoponabp.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 "eshoponabp.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 "eshoponabp.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "eshoponabp.labels" -}} +helm.sh/chart: {{ include "eshoponabp.chart" . }} +{{ include "eshoponabp.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "eshoponabp.selectorLabels" -}} +app.kubernetes.io/name: {{ include "eshoponabp.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "eshoponabp.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "eshoponabp.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/etc/k8s/eshoponabp/templates/deployment.yaml b/etc/k8s/eshoponabp/templates/deployment.yaml new file mode 100644 index 00000000..37c737d6 --- /dev/null +++ b/etc/k8s/eshoponabp/templates/deployment.yaml @@ -0,0 +1,61 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "eshoponabp.fullname" . }} + labels: + {{- include "eshoponabp.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "eshoponabp.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "eshoponabp.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "eshoponabp.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/etc/k8s/eshoponabp/templates/hpa.yaml b/etc/k8s/eshoponabp/templates/hpa.yaml new file mode 100644 index 00000000..c0aa8528 --- /dev/null +++ b/etc/k8s/eshoponabp/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "eshoponabp.fullname" . }} + labels: + {{- include "eshoponabp.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "eshoponabp.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/etc/k8s/eshoponabp/templates/ingress.yaml b/etc/k8s/eshoponabp/templates/ingress.yaml new file mode 100644 index 00000000..0a263c3e --- /dev/null +++ b/etc/k8s/eshoponabp/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "eshoponabp.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 "eshoponabp.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/etc/k8s/eshoponabp/templates/service.yaml b/etc/k8s/eshoponabp/templates/service.yaml new file mode 100644 index 00000000..f99c7ded --- /dev/null +++ b/etc/k8s/eshoponabp/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "eshoponabp.fullname" . }} + labels: + {{- include "eshoponabp.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "eshoponabp.selectorLabels" . | nindent 4 }} diff --git a/etc/k8s/eshoponabp/templates/serviceaccount.yaml b/etc/k8s/eshoponabp/templates/serviceaccount.yaml new file mode 100644 index 00000000..d9a4279f --- /dev/null +++ b/etc/k8s/eshoponabp/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "eshoponabp.serviceAccountName" . }} + labels: + {{- include "eshoponabp.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/etc/k8s/eshoponabp/templates/tests/test-connection.yaml b/etc/k8s/eshoponabp/templates/tests/test-connection.yaml new file mode 100644 index 00000000..9ca7d87c --- /dev/null +++ b/etc/k8s/eshoponabp/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "eshoponabp.fullname" . }}-test-connection" + labels: + {{- include "eshoponabp.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "eshoponabp.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/etc/k8s/eshoponabp/values.yaml b/etc/k8s/eshoponabp/values.yaml new file mode 100644 index 00000000..26502a7b --- /dev/null +++ b/etc/k8s/eshoponabp/values.yaml @@ -0,0 +1,82 @@ +# Default values for eshoponabp. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +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 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} From 2d4a67c43dd4b4b56f5c1df7411b581c11f8d9ec Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 7 Oct 2021 16:57:41 +0300 Subject: [PATCH 02/12] added sql server, redis and rabbitmq charts --- etc/k8s/eshoponabp/charts/rabbitmq/Chart.yaml | 6 +++ .../rabbitmq/templates/rabbitmq-service.yaml | 20 +++++++++ .../charts/rabbitmq/templates/rabbitmq.yaml | 25 +++++++++++ .../eshoponabp/charts/rabbitmq/values.yaml | 0 etc/k8s/eshoponabp/charts/redis/Chart.yaml | 6 +++ .../charts/redis/templates/redis-service.yaml | 13 ++++++ .../charts/redis/templates/redis.yaml | 20 +++++++++ etc/k8s/eshoponabp/charts/redis/values.yaml | 0 .../eshoponabp/charts/sqlserver/Chart.yaml | 6 +++ .../templates/sqlserver-service.yaml | 14 ++++++ .../charts/sqlserver/templates/sqlserver.yaml | 43 +++++++++++++++++++ .../eshoponabp/charts/sqlserver/values.yaml | 0 12 files changed, 153 insertions(+) create mode 100644 etc/k8s/eshoponabp/charts/rabbitmq/Chart.yaml create mode 100644 etc/k8s/eshoponabp/charts/rabbitmq/templates/rabbitmq-service.yaml create mode 100644 etc/k8s/eshoponabp/charts/rabbitmq/templates/rabbitmq.yaml create mode 100644 etc/k8s/eshoponabp/charts/rabbitmq/values.yaml create mode 100644 etc/k8s/eshoponabp/charts/redis/Chart.yaml create mode 100644 etc/k8s/eshoponabp/charts/redis/templates/redis-service.yaml create mode 100644 etc/k8s/eshoponabp/charts/redis/templates/redis.yaml create mode 100644 etc/k8s/eshoponabp/charts/redis/values.yaml create mode 100644 etc/k8s/eshoponabp/charts/sqlserver/Chart.yaml create mode 100644 etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver-service.yaml create mode 100644 etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml create mode 100644 etc/k8s/eshoponabp/charts/sqlserver/values.yaml diff --git a/etc/k8s/eshoponabp/charts/rabbitmq/Chart.yaml b/etc/k8s/eshoponabp/charts/rabbitmq/Chart.yaml new file mode 100644 index 00000000..50b9af01 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/rabbitmq/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: rabbitmq +appVersion: "1.0" +description: Runs RabbitMQ Message Broker Instance +version: 1.0.0 +type: application diff --git a/etc/k8s/eshoponabp/charts/rabbitmq/templates/rabbitmq-service.yaml b/etc/k8s/eshoponabp/charts/rabbitmq/templates/rabbitmq-service.yaml new file mode 100644 index 00000000..5e08c975 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/rabbitmq/templates/rabbitmq-service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + type: ClusterIP + ports: + - name: http + protocol: TCP + port: 15672 + targetPort: 15672 + - name: amqp + protocol: TCP + port: 5672 + targetPort: 5672 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} + diff --git a/etc/k8s/eshoponabp/charts/rabbitmq/templates/rabbitmq.yaml b/etc/k8s/eshoponabp/charts/rabbitmq/templates/rabbitmq.yaml new file mode 100644 index 00000000..7bf082c7 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/rabbitmq/templates/rabbitmq.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + serviceName: {{ .Release.Name }}-{{ .Chart.Name }} + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: rabbitmq:management-alpine + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: http + protocol: TCP + containerPort: 15672 + - name: amqp + protocol: TCP + containerPort: 5672 \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/rabbitmq/values.yaml b/etc/k8s/eshoponabp/charts/rabbitmq/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/etc/k8s/eshoponabp/charts/redis/Chart.yaml b/etc/k8s/eshoponabp/charts/redis/Chart.yaml new file mode 100644 index 00000000..11ec26ce --- /dev/null +++ b/etc/k8s/eshoponabp/charts/redis/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: redis +appVersion: "1.0" +description: Runs Redis instance +version: 1.0.0 +type: application diff --git a/etc/k8s/eshoponabp/charts/redis/templates/redis-service.yaml b/etc/k8s/eshoponabp/charts/redis/templates/redis-service.yaml new file mode 100644 index 00000000..23800f96 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/redis/templates/redis-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + type: ClusterIP + ports: + - name: redis + port: 6379 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/redis/templates/redis.yaml b/etc/k8s/eshoponabp/charts/redis/templates/redis.yaml new file mode 100644 index 00000000..102dfb59 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/redis/templates/redis.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: redis:alpine + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: redis + containerPort: 6379 \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/redis/values.yaml b/etc/k8s/eshoponabp/charts/redis/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/etc/k8s/eshoponabp/charts/sqlserver/Chart.yaml b/etc/k8s/eshoponabp/charts/sqlserver/Chart.yaml new file mode 100644 index 00000000..dab9de40 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/sqlserver/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: sqlserver +appVersion: "1.0" +description: Runs SQL Server Instance +version: 1.0.0 +type: application diff --git a/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver-service.yaml b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver-service.yaml new file mode 100644 index 00000000..5896ca38 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + type: ClusterIP + ports: + - name: sqlserver + port: 1434 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} + diff --git a/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml new file mode 100644 index 00000000..3a5d85c9 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + serviceName: {{ .Release.Name }}-{{ .Chart.Name }} + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: mcr.microsoft.com/mssql/server + name: {{ .Release.Name }}-{{ .Chart.Name }} +{{- if eq .Release.Name "eh-az" }} + volumeMounts: + - mountPath: "/var/opt/mssql" + name: {{ .Release.Name }}-{{ .Chart.Name }}-database-volume + subPath: sqlserver-data +{{- end }} + ports: + - name: sqlserver + containerPort: 5432 + env: + - name: SA_PASSWORD + value: "myPassw0rd" + - name: ACCEPT_EULA + value: "Y" +{{- if eq .Release.Name "eh-az" }} + volumeClaimTemplates: + - metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-database-volume + spec: + accessModes: [ "ReadWriteOnce" ] + storageClassName: "managed-premium-retain" + resources: + requests: + storage: 64Gi +{{- end }} \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/sqlserver/values.yaml b/etc/k8s/eshoponabp/charts/sqlserver/values.yaml new file mode 100644 index 00000000..e69de29b From ff9e888b9a54f40b88233d09817d841edaa43bc3 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 7 Oct 2021 17:03:02 +0300 Subject: [PATCH 03/12] added web --- etc/k8s/eshoponabp/charts/web/Chart.yaml | 6 +++ .../charts/web/templates/www-ingress.yaml | 37 +++++++++++++++++++ .../charts/web/templates/www-service.yaml | 14 +++++++ .../eshoponabp/charts/web/templates/www.yaml | 24 ++++++++++++ etc/k8s/eshoponabp/charts/web/values.yaml | 0 5 files changed, 81 insertions(+) create mode 100644 etc/k8s/eshoponabp/charts/web/Chart.yaml create mode 100644 etc/k8s/eshoponabp/charts/web/templates/www-ingress.yaml create mode 100644 etc/k8s/eshoponabp/charts/web/templates/www-service.yaml create mode 100644 etc/k8s/eshoponabp/charts/web/templates/www.yaml create mode 100644 etc/k8s/eshoponabp/charts/web/values.yaml diff --git a/etc/k8s/eshoponabp/charts/web/Chart.yaml b/etc/k8s/eshoponabp/charts/web/Chart.yaml new file mode 100644 index 00000000..319d808f --- /dev/null +++ b/etc/k8s/eshoponabp/charts/web/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: www +appVersion: "1.0" +description: EventHub WWW Application +version: 1.0.0 +type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/web/templates/www-ingress.yaml b/etc/k8s/eshoponabp/charts/web/templates/www-ingress.yaml new file mode 100644 index 00000000..3426616c --- /dev/null +++ b/etc/k8s/eshoponabp/charts/web/templates/www-ingress.yaml @@ -0,0 +1,37 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/rewrite-target: / + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ .Values.global.nginxProxyBufferSize }}" + nginx.ingress.kubernetes.io/proxy-buffers-number: "{{ .Values.global.nginxProxyBuffersNumber }}" +{{- if eq .Release.Name "eh-az" }} + nginx.ingress.kubernetes.io/from-to-www-redirect: "true" +{{- end }} + cert-manager.io/cluster-issuer: letsencrypt +spec: + tls: + - hosts: + - {{ .Values.global.wwwDomain }} +{{- if eq .Release.Name "eh-az" }} + - {{ print "www." .Values.global.wwwDomain }} +{{- end }} + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls + rules: +{{- if eq .Release.Name "eh-az" }} + - host: "{{ print "www." .Values.global.wwwDomain }}" +{{- else }} + - host: "{{ .Values.global.wwwDomain }}" +{{- end }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }} + port: + number: 80 \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/web/templates/www-service.yaml b/etc/k8s/eshoponabp/charts/web/templates/www-service.yaml new file mode 100644 index 00000000..ee157c01 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/web/templates/www-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + ports: + - name: "80" + port: 80 + - name: "443" + port: 443 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/eshoponabp/charts/web/templates/www.yaml b/etc/k8s/eshoponabp/charts/web/templates/www.yaml new file mode 100644 index 00000000..0c29931c --- /dev/null +++ b/etc/k8s/eshoponabp/charts/web/templates/www.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: {{ .Values.containerImage }}:{{ .Values.global.eventHubImageVersion }} + imagePullPolicy: {{ .Values.global.imagePullPolicy }} + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + env: +{{ include "eshoponabp.global.env" . | indent 8 }} diff --git a/etc/k8s/eshoponabp/charts/web/values.yaml b/etc/k8s/eshoponabp/charts/web/values.yaml new file mode 100644 index 00000000..e69de29b From 7b2b8699c66df0edb89c2079b3649e802bbcc454 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Tue, 12 Oct 2021 16:50:53 +0300 Subject: [PATCH 04/12] added authserver and globals --- .../eshoponabp/charts/authserver/Chart.yaml | 6 ++++ .../templates/authserver-ingress.yaml | 29 ++++++++++++++++++ .../templates/authserver-service.yaml | 14 +++++++++ .../authserver/templates/authserver.yaml | 30 +++++++++++++++++++ .../eshoponabp/charts/authserver/values.yaml | 0 .../eshoponabp/charts/sqlserver/Chart.yaml | 2 +- etc/k8s/eshoponabp/templates/_helpers.tpl | 25 ++++++++++++++++ etc/k8s/eshoponabp/values.yaml | 26 ++++++++++++++++ 8 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 etc/k8s/eshoponabp/charts/authserver/Chart.yaml create mode 100644 etc/k8s/eshoponabp/charts/authserver/templates/authserver-ingress.yaml create mode 100644 etc/k8s/eshoponabp/charts/authserver/templates/authserver-service.yaml create mode 100644 etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml create mode 100644 etc/k8s/eshoponabp/charts/authserver/values.yaml diff --git a/etc/k8s/eshoponabp/charts/authserver/Chart.yaml b/etc/k8s/eshoponabp/charts/authserver/Chart.yaml new file mode 100644 index 00000000..361d0a7e --- /dev/null +++ b/etc/k8s/eshoponabp/charts/authserver/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: authserver +appVersion: "1.0" +description: eShop AuthServer Application +version: 1.0.0 +type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/authserver/templates/authserver-ingress.yaml b/etc/k8s/eshoponabp/charts/authserver/templates/authserver-ingress.yaml new file mode 100644 index 00000000..b1695560 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/authserver/templates/authserver-ingress.yaml @@ -0,0 +1,29 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/rewrite-target: / + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ .Values.global.nginxProxyBufferSize }}" + nginx.ingress.kubernetes.io/proxy-buffers-number: "{{ .Values.global.nginxProxyBuffersNumber }}" + cert-manager.io/cluster-issuer: letsencrypt + nginx.ingress.kubernetes.io/configuration-snippet: | + more_set_input_headers "from-ingress: true"; +spec: + tls: + - hosts: + - {{ .Values.global.authServerDomain }} + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls + rules: + - host: "{{ .Values.global.authServerDomain }}" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }} + port: + number: 80 \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/authserver/templates/authserver-service.yaml b/etc/k8s/eshoponabp/charts/authserver/templates/authserver-service.yaml new file mode 100644 index 00000000..ee157c01 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/authserver/templates/authserver-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + ports: + - name: "80" + port: 80 + - name: "443" + port: 443 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml b/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml new file mode 100644 index 00000000..c52e9430 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: {{ .Values.containerImage }}:{{ .Values.global.eshoponabpImageVersion }} + imagePullPolicy: {{ .Values.global.imagePullPolicy }} + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + env: +{{ include "eshoponabp.global.env" . | indent 8 }} + - name: "ConnectionStrings__IdentityService" + value: {{ .Values.global.identityServiceConnString }} + - name: "ConnectionStrings__AdministrationService" + value: {{ .Values.global.administrationServiceConnString }} + - name: "ConnectionStrings__SaasService" + value: {{ .Values.global.saasServiceConnString }} diff --git a/etc/k8s/eshoponabp/charts/authserver/values.yaml b/etc/k8s/eshoponabp/charts/authserver/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/etc/k8s/eshoponabp/charts/sqlserver/Chart.yaml b/etc/k8s/eshoponabp/charts/sqlserver/Chart.yaml index dab9de40..647c03d2 100644 --- a/etc/k8s/eshoponabp/charts/sqlserver/Chart.yaml +++ b/etc/k8s/eshoponabp/charts/sqlserver/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: sqlserver +name: sqldb appVersion: "1.0" description: Runs SQL Server Instance version: 1.0.0 diff --git a/etc/k8s/eshoponabp/templates/_helpers.tpl b/etc/k8s/eshoponabp/templates/_helpers.tpl index 901e5bb0..ef7abc38 100644 --- a/etc/k8s/eshoponabp/templates/_helpers.tpl +++ b/etc/k8s/eshoponabp/templates/_helpers.tpl @@ -60,3 +60,28 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{- define "eshoponabp.global.env" -}} +- name: "DOTNET_ENVIRONMENT" + value: "{{ .Values.global.dotnetEnvironment }}" +- name: "AppUrls__Account" + value: "{{ .Values.global.authServerUrl }}" +- name: "AppUrls__Web" + value: "{{ .Values.global.webUrl }}" +- name: "AppUrls__Api" + value: "{{ .Values.global.apiUrl }}" +- name: "AppUrls__ApiInternal" + value: "{{ .Values.global.apiUrlInternal }}" +- name: "AppUrls__Admin" + value: "{{ .Values.global.adminUrl }}" +- name: "AppUrls__AdminApi" + value: "{{ .Values.global.adminApiUrl }}" +- name: "Redis__Configuration" + value: "{{ .Values.global.redisConfiguration }}" +- name: "AuthServer__Authority" + value: "{{ .Values.global.internalAuthServerAuthority }}" +- name: "AuthServer__RequireHttpsMetadata" + value: "{{ .Values.global.internalAuthServerRequireHttpsMetadata }}" +- name: "StringEncryption__DefaultPassPhrase" + value: "{{ .Values.global.stringEncryptionDefaultPassPhrase }}" +{{- end }} diff --git a/etc/k8s/eshoponabp/values.yaml b/etc/k8s/eshoponabp/values.yaml index 26502a7b..bad0bc63 100644 --- a/etc/k8s/eshoponabp/values.yaml +++ b/etc/k8s/eshoponabp/values.yaml @@ -80,3 +80,29 @@ nodeSelector: {} tolerations: [] affinity: {} + +global: + dotnetEnvironment: "Staging" + authServer: + domain: eshoponabp-authserver + url: https://eshoponabp-authserver + containerImage: "eshoponabp.authserver" + identityService: + domain: eshoponabp-identity + url: https://eshoponabp-identity + containerImage: "eshoponabp.identity" + connString: "Server=eshoponabp-sqldb,1434;Database=EShopOnAbp_Identity;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" + administrationService: + domain: eshoponabp-administration + url: https://eshoponabp-administration + containerImage: "eshoponabp.authserver" + connString: "Server=eshoponabp-sqldb,1434;Database=EShopOnAbp_Administration;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" + saasService: + domain: eshoponabp-saas + url: https://eshoponabp-saas + containerImage: "eshoponabp.saas" + connString: "Server=eshoponabp-sqldb,1434;Database=EShopOnAbp_Saas;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" + redisConfiguration: "eshoponabp-redis" + nginxProxyBufferSize: "32k" + nginxProxyBuffersNumber: "8" + eshoponabpImageVersion: latest \ No newline at end of file From e8a4bc630f0786bcb0f6c20bc73ccb40af3d447b Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 14 Oct 2021 09:43:01 +0300 Subject: [PATCH 05/12] added deployment script --- etc/k8s/deploy-staging.ps1 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 etc/k8s/deploy-staging.ps1 diff --git a/etc/k8s/deploy-staging.ps1 b/etc/k8s/deploy-staging.ps1 new file mode 100644 index 00000000..70a88e57 --- /dev/null +++ b/etc/k8s/deploy-staging.ps1 @@ -0,0 +1,3 @@ +param ($version='latest') + +helm upgrade --install eshop eshoponabp --namespace eshop --create-namespace --set global.eventHubImageVersion=$version \ No newline at end of file From f4dd35708f3a835fb59def942852683d106ea769 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 14 Oct 2021 09:43:10 +0300 Subject: [PATCH 06/12] updated charts --- .../templates/authserver-ingress.yaml | 4 +- .../authserver/templates/authserver.yaml | 2 +- .../templates/sqlserver-service.yaml | 2 +- .../charts/sqlserver/templates/sqlserver.yaml | 2 +- etc/k8s/eshoponabp/charts/web/Chart.yaml | 6 -- .../charts/web/templates/www-ingress.yaml | 37 ----------- .../charts/web/templates/www-service.yaml | 14 ----- .../eshoponabp/charts/web/templates/www.yaml | 24 -------- etc/k8s/eshoponabp/charts/web/values.yaml | 0 etc/k8s/eshoponabp/templates/deployment.yaml | 61 ------------------- etc/k8s/eshoponabp/templates/hpa.yaml | 28 --------- etc/k8s/eshoponabp/templates/ingress.yaml | 61 ------------------- etc/k8s/eshoponabp/templates/service.yaml | 15 ----- .../eshoponabp/templates/serviceaccount.yaml | 12 ---- etc/k8s/eshoponabp/values.yaml | 6 +- 15 files changed, 8 insertions(+), 266 deletions(-) delete mode 100644 etc/k8s/eshoponabp/charts/web/Chart.yaml delete mode 100644 etc/k8s/eshoponabp/charts/web/templates/www-ingress.yaml delete mode 100644 etc/k8s/eshoponabp/charts/web/templates/www-service.yaml delete mode 100644 etc/k8s/eshoponabp/charts/web/templates/www.yaml delete mode 100644 etc/k8s/eshoponabp/charts/web/values.yaml delete mode 100644 etc/k8s/eshoponabp/templates/deployment.yaml delete mode 100644 etc/k8s/eshoponabp/templates/hpa.yaml delete mode 100644 etc/k8s/eshoponabp/templates/ingress.yaml delete mode 100644 etc/k8s/eshoponabp/templates/service.yaml delete mode 100644 etc/k8s/eshoponabp/templates/serviceaccount.yaml diff --git a/etc/k8s/eshoponabp/charts/authserver/templates/authserver-ingress.yaml b/etc/k8s/eshoponabp/charts/authserver/templates/authserver-ingress.yaml index b1695560..a09b9cc5 100644 --- a/etc/k8s/eshoponabp/charts/authserver/templates/authserver-ingress.yaml +++ b/etc/k8s/eshoponabp/charts/authserver/templates/authserver-ingress.yaml @@ -14,10 +14,10 @@ metadata: spec: tls: - hosts: - - {{ .Values.global.authServerDomain }} + - {{ .Values.global.authServer.domain }} secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls rules: - - host: "{{ .Values.global.authServerDomain }}" + - host: "{{ .Values.global.authServer.domain }}" http: paths: - path: / diff --git a/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml b/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml index c52e9430..4bed73b0 100644 --- a/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml +++ b/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml @@ -12,7 +12,7 @@ spec: app: {{ .Release.Name }}-{{ .Chart.Name }} spec: containers: - - image: {{ .Values.containerImage }}:{{ .Values.global.eshoponabpImageVersion }} + - image: {{ .Values.global.authServer.containerImage }}:{{ .Values.global.eshoponabpImageVersion }} imagePullPolicy: {{ .Values.global.imagePullPolicy }} name: {{ .Release.Name }}-{{ .Chart.Name }} ports: diff --git a/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver-service.yaml b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver-service.yaml index 5896ca38..653493f7 100644 --- a/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver-service.yaml +++ b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver-service.yaml @@ -8,7 +8,7 @@ spec: type: ClusterIP ports: - name: sqlserver - port: 1434 + port: 1433 selector: app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml index 3a5d85c9..3e9e2ac7 100644 --- a/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml +++ b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml @@ -39,5 +39,5 @@ spec: storageClassName: "managed-premium-retain" resources: requests: - storage: 64Gi + storage: 32Gi {{- end }} \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/web/Chart.yaml b/etc/k8s/eshoponabp/charts/web/Chart.yaml deleted file mode 100644 index 319d808f..00000000 --- a/etc/k8s/eshoponabp/charts/web/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: www -appVersion: "1.0" -description: EventHub WWW Application -version: 1.0.0 -type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/web/templates/www-ingress.yaml b/etc/k8s/eshoponabp/charts/web/templates/www-ingress.yaml deleted file mode 100644 index 3426616c..00000000 --- a/etc/k8s/eshoponabp/charts/web/templates/www-ingress.yaml +++ /dev/null @@ -1,37 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress - annotations: - kubernetes.io/ingress.class: nginx - nginx.ingress.kubernetes.io/rewrite-target: / - nginx.ingress.kubernetes.io/force-ssl-redirect: "true" - nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ .Values.global.nginxProxyBufferSize }}" - nginx.ingress.kubernetes.io/proxy-buffers-number: "{{ .Values.global.nginxProxyBuffersNumber }}" -{{- if eq .Release.Name "eh-az" }} - nginx.ingress.kubernetes.io/from-to-www-redirect: "true" -{{- end }} - cert-manager.io/cluster-issuer: letsencrypt -spec: - tls: - - hosts: - - {{ .Values.global.wwwDomain }} -{{- if eq .Release.Name "eh-az" }} - - {{ print "www." .Values.global.wwwDomain }} -{{- end }} - secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls - rules: -{{- if eq .Release.Name "eh-az" }} - - host: "{{ print "www." .Values.global.wwwDomain }}" -{{- else }} - - host: "{{ .Values.global.wwwDomain }}" -{{- end }} - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: {{ .Release.Name }}-{{ .Chart.Name }} - port: - number: 80 \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/web/templates/www-service.yaml b/etc/k8s/eshoponabp/charts/web/templates/www-service.yaml deleted file mode 100644 index ee157c01..00000000 --- a/etc/k8s/eshoponabp/charts/web/templates/www-service.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - name: {{ .Release.Name }}-{{ .Chart.Name }} - name: {{ .Release.Name }}-{{ .Chart.Name }} -spec: - ports: - - name: "80" - port: 80 - - name: "443" - port: 443 - selector: - app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/eshoponabp/charts/web/templates/www.yaml b/etc/k8s/eshoponabp/charts/web/templates/www.yaml deleted file mode 100644 index 0c29931c..00000000 --- a/etc/k8s/eshoponabp/charts/web/templates/www.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ .Release.Name }}-{{ .Chart.Name }} -spec: - selector: - matchLabels: - app: {{ .Release.Name }}-{{ .Chart.Name }} - template: - metadata: - labels: - app: {{ .Release.Name }}-{{ .Chart.Name }} - spec: - containers: - - image: {{ .Values.containerImage }}:{{ .Values.global.eventHubImageVersion }} - imagePullPolicy: {{ .Values.global.imagePullPolicy }} - name: {{ .Release.Name }}-{{ .Chart.Name }} - ports: - - name: http - containerPort: 80 - - name: https - containerPort: 443 - env: -{{ include "eshoponabp.global.env" . | indent 8 }} diff --git a/etc/k8s/eshoponabp/charts/web/values.yaml b/etc/k8s/eshoponabp/charts/web/values.yaml deleted file mode 100644 index e69de29b..00000000 diff --git a/etc/k8s/eshoponabp/templates/deployment.yaml b/etc/k8s/eshoponabp/templates/deployment.yaml deleted file mode 100644 index 37c737d6..00000000 --- a/etc/k8s/eshoponabp/templates/deployment.yaml +++ /dev/null @@ -1,61 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "eshoponabp.fullname" . }} - labels: - {{- include "eshoponabp.labels" . | nindent 4 }} -spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} - selector: - matchLabels: - {{- include "eshoponabp.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "eshoponabp.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "eshoponabp.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/etc/k8s/eshoponabp/templates/hpa.yaml b/etc/k8s/eshoponabp/templates/hpa.yaml deleted file mode 100644 index c0aa8528..00000000 --- a/etc/k8s/eshoponabp/templates/hpa.yaml +++ /dev/null @@ -1,28 +0,0 @@ -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "eshoponabp.fullname" . }} - labels: - {{- include "eshoponabp.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "eshoponabp.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/etc/k8s/eshoponabp/templates/ingress.yaml b/etc/k8s/eshoponabp/templates/ingress.yaml deleted file mode 100644 index 0a263c3e..00000000 --- a/etc/k8s/eshoponabp/templates/ingress.yaml +++ /dev/null @@ -1,61 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "eshoponabp.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 "eshoponabp.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/etc/k8s/eshoponabp/templates/service.yaml b/etc/k8s/eshoponabp/templates/service.yaml deleted file mode 100644 index f99c7ded..00000000 --- a/etc/k8s/eshoponabp/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "eshoponabp.fullname" . }} - labels: - {{- include "eshoponabp.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "eshoponabp.selectorLabels" . | nindent 4 }} diff --git a/etc/k8s/eshoponabp/templates/serviceaccount.yaml b/etc/k8s/eshoponabp/templates/serviceaccount.yaml deleted file mode 100644 index d9a4279f..00000000 --- a/etc/k8s/eshoponabp/templates/serviceaccount.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "eshoponabp.serviceAccountName" . }} - labels: - {{- include "eshoponabp.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/etc/k8s/eshoponabp/values.yaml b/etc/k8s/eshoponabp/values.yaml index bad0bc63..29f585dd 100644 --- a/etc/k8s/eshoponabp/values.yaml +++ b/etc/k8s/eshoponabp/values.yaml @@ -83,10 +83,11 @@ affinity: {} global: dotnetEnvironment: "Staging" + eshoponabpImageVersion: latest authServer: domain: eshoponabp-authserver url: https://eshoponabp-authserver - containerImage: "eshoponabp.authserver" + containerImage: "eshoponabp/app-authserver" identityService: domain: eshoponabp-identity url: https://eshoponabp-identity @@ -104,5 +105,4 @@ global: connString: "Server=eshoponabp-sqldb,1434;Database=EShopOnAbp_Saas;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" redisConfiguration: "eshoponabp-redis" nginxProxyBufferSize: "32k" - nginxProxyBuffersNumber: "8" - eshoponabpImageVersion: latest \ No newline at end of file + nginxProxyBuffersNumber: "8" \ No newline at end of file From b4e6a1d4f5908422b22c32e1bc7aa0ae5b31a8ca Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 14 Oct 2021 10:27:26 +0300 Subject: [PATCH 07/12] added identity service applications can't connect to redis --- .../authserver/templates/authserver.yaml | 6 ++-- etc/k8s/eshoponabp/charts/identity/Chart.yaml | 6 ++++ .../identity/templates/admin-api-service.yaml | 14 +++++++++ .../identity/templates/identity-ingress.yaml | 27 ++++++++++++++++ .../charts/identity/templates/identity.yaml | 31 +++++++++++++++++++ .../eshoponabp/charts/identity/values.yaml | 0 .../charts/sqlserver/templates/sqlserver.yaml | 2 +- etc/k8s/eshoponabp/templates/_helpers.tpl | 10 ------ etc/k8s/eshoponabp/values.yaml | 12 ++++--- 9 files changed, 90 insertions(+), 18 deletions(-) create mode 100644 etc/k8s/eshoponabp/charts/identity/Chart.yaml create mode 100644 etc/k8s/eshoponabp/charts/identity/templates/admin-api-service.yaml create mode 100644 etc/k8s/eshoponabp/charts/identity/templates/identity-ingress.yaml create mode 100644 etc/k8s/eshoponabp/charts/identity/templates/identity.yaml create mode 100644 etc/k8s/eshoponabp/charts/identity/values.yaml diff --git a/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml b/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml index 4bed73b0..ec7d9533 100644 --- a/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml +++ b/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml @@ -23,8 +23,8 @@ spec: env: {{ include "eshoponabp.global.env" . | indent 8 }} - name: "ConnectionStrings__IdentityService" - value: {{ .Values.global.identityServiceConnString }} + value: {{ .Values.global.identityService.connString }} - name: "ConnectionStrings__AdministrationService" - value: {{ .Values.global.administrationServiceConnString }} + value: {{ .Values.global.administrationService.connString }} - name: "ConnectionStrings__SaasService" - value: {{ .Values.global.saasServiceConnString }} + value: {{ .Values.global.saasService.connString }} diff --git a/etc/k8s/eshoponabp/charts/identity/Chart.yaml b/etc/k8s/eshoponabp/charts/identity/Chart.yaml new file mode 100644 index 00000000..0af4b111 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/identity/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: identity +appVersion: "1.0" +description: Identity Microservice +version: 1.0.0 +type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/identity/templates/admin-api-service.yaml b/etc/k8s/eshoponabp/charts/identity/templates/admin-api-service.yaml new file mode 100644 index 00000000..ee157c01 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/identity/templates/admin-api-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + ports: + - name: "80" + port: 80 + - name: "443" + port: 443 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/eshoponabp/charts/identity/templates/identity-ingress.yaml b/etc/k8s/eshoponabp/charts/identity/templates/identity-ingress.yaml new file mode 100644 index 00000000..3e8002eb --- /dev/null +++ b/etc/k8s/eshoponabp/charts/identity/templates/identity-ingress.yaml @@ -0,0 +1,27 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress + annotations: + kubernetes.io/ingress.class: "nginx" + nginx.ingress.kubernetes.io/rewrite-target: / + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ .Values.global.nginxProxyBufferSize }}" + nginx.ingress.kubernetes.io/proxy-buffers-number: "{{ .Values.global.nginxProxyBuffersNumber }}" + cert-manager.io/cluster-issuer: letsencrypt +spec: + tls: + - hosts: + - {{ .Values.global.identityService.domain }} + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls + rules: + - host: "{{ .Values.global.identityService.domain }}" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }} + port: + number: 80 \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/identity/templates/identity.yaml b/etc/k8s/eshoponabp/charts/identity/templates/identity.yaml new file mode 100644 index 00000000..ba929514 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/identity/templates/identity.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: {{ .Values.global.identityService.containerImage }}:{{ .Values.global.eventHubImageVersion }} + imagePullPolicy: {{ .Values.global.imagePullPolicy }} + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + env: +{{ include "eshoponabp.global.env" . | indent 8 }} + - name: "ConnectionStrings__IdentityService" + value: {{ .Values.global.identityService.connString }} + - name: "ConnectionStrings__AdministrationService" + value: {{ .Values.global.administrationService.connString }} + - name: "ConnectionStrings__SaasService" + value: {{ .Values.global.saasService.connString }} + diff --git a/etc/k8s/eshoponabp/charts/identity/values.yaml b/etc/k8s/eshoponabp/charts/identity/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml index 3e9e2ac7..fed9b5cf 100644 --- a/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml +++ b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml @@ -24,7 +24,7 @@ spec: {{- end }} ports: - name: sqlserver - containerPort: 5432 + containerPort: 1434 env: - name: SA_PASSWORD value: "myPassw0rd" diff --git a/etc/k8s/eshoponabp/templates/_helpers.tpl b/etc/k8s/eshoponabp/templates/_helpers.tpl index ef7abc38..50d1115c 100644 --- a/etc/k8s/eshoponabp/templates/_helpers.tpl +++ b/etc/k8s/eshoponabp/templates/_helpers.tpl @@ -64,18 +64,8 @@ Create the name of the service account to use {{- define "eshoponabp.global.env" -}} - name: "DOTNET_ENVIRONMENT" value: "{{ .Values.global.dotnetEnvironment }}" -- name: "AppUrls__Account" - value: "{{ .Values.global.authServerUrl }}" -- name: "AppUrls__Web" - value: "{{ .Values.global.webUrl }}" -- name: "AppUrls__Api" - value: "{{ .Values.global.apiUrl }}" - name: "AppUrls__ApiInternal" value: "{{ .Values.global.apiUrlInternal }}" -- name: "AppUrls__Admin" - value: "{{ .Values.global.adminUrl }}" -- name: "AppUrls__AdminApi" - value: "{{ .Values.global.adminApiUrl }}" - name: "Redis__Configuration" value: "{{ .Values.global.redisConfiguration }}" - name: "AuthServer__Authority" diff --git a/etc/k8s/eshoponabp/values.yaml b/etc/k8s/eshoponabp/values.yaml index 29f585dd..fd40c5f1 100644 --- a/etc/k8s/eshoponabp/values.yaml +++ b/etc/k8s/eshoponabp/values.yaml @@ -83,6 +83,7 @@ affinity: {} global: dotnetEnvironment: "Staging" + imagePullPolicy: Never eshoponabpImageVersion: latest authServer: domain: eshoponabp-authserver @@ -91,18 +92,21 @@ global: identityService: domain: eshoponabp-identity url: https://eshoponabp-identity - containerImage: "eshoponabp.identity" + containerImage: "eshoponabp/service-identity" connString: "Server=eshoponabp-sqldb,1434;Database=EShopOnAbp_Identity;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" administrationService: domain: eshoponabp-administration url: https://eshoponabp-administration - containerImage: "eshoponabp.authserver" + containerImage: "eshoponabp/service-administration" connString: "Server=eshoponabp-sqldb,1434;Database=EShopOnAbp_Administration;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" saasService: domain: eshoponabp-saas url: https://eshoponabp-saas - containerImage: "eshoponabp.saas" + containerImage: "eshoponabp/service-saas" connString: "Server=eshoponabp-sqldb,1434;Database=EShopOnAbp_Saas;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" redisConfiguration: "eshoponabp-redis" nginxProxyBufferSize: "32k" - nginxProxyBuffersNumber: "8" \ No newline at end of file + nginxProxyBuffersNumber: "8" + internalAuthServerAuthority: "http://eshoponabp-authserver" + internalAuthServerRequireHttpsMetadata: "false" + stringEncryptionDefaultPassPhrase: "TxVIZFPxK33czbbv" \ No newline at end of file From dc5b96867dd0749fff260b84151b2f8ae3b09390 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 14 Oct 2021 11:02:07 +0300 Subject: [PATCH 08/12] fixed app selectors --- etc/k8s/deploy-staging.ps1 | 2 +- .../charts/authserver/templates/authserver.yaml | 2 +- .../eshoponabp/charts/sqlserver/templates/sqlserver.yaml | 4 ++-- etc/k8s/eshoponabp/templates/_helpers.tpl | 2 ++ etc/k8s/eshoponabp/values.yaml | 9 +++++---- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/etc/k8s/deploy-staging.ps1 b/etc/k8s/deploy-staging.ps1 index 70a88e57..458642a7 100644 --- a/etc/k8s/deploy-staging.ps1 +++ b/etc/k8s/deploy-staging.ps1 @@ -1,3 +1,3 @@ param ($version='latest') -helm upgrade --install eshop eshoponabp --namespace eshop --create-namespace --set global.eventHubImageVersion=$version \ No newline at end of file +helm upgrade --install eshoponabp eshoponabp --namespace eshop --create-namespace --set global.eventHubImageVersion=$version \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml b/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml index ec7d9533..e59d1c5a 100644 --- a/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml +++ b/etc/k8s/eshoponabp/charts/authserver/templates/authserver.yaml @@ -27,4 +27,4 @@ spec: - name: "ConnectionStrings__AdministrationService" value: {{ .Values.global.administrationService.connString }} - name: "ConnectionStrings__SaasService" - value: {{ .Values.global.saasService.connString }} + value: {{ .Values.global.saasService.connString }} \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml index fed9b5cf..57a5bcac 100644 --- a/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml +++ b/etc/k8s/eshoponabp/charts/sqlserver/templates/sqlserver.yaml @@ -24,10 +24,10 @@ spec: {{- end }} ports: - name: sqlserver - containerPort: 1434 + containerPort: 1433 env: - name: SA_PASSWORD - value: "myPassw0rd" + value: "myPassw@rd" - name: ACCEPT_EULA value: "Y" {{- if eq .Release.Name "eh-az" }} diff --git a/etc/k8s/eshoponabp/templates/_helpers.tpl b/etc/k8s/eshoponabp/templates/_helpers.tpl index 50d1115c..80649639 100644 --- a/etc/k8s/eshoponabp/templates/_helpers.tpl +++ b/etc/k8s/eshoponabp/templates/_helpers.tpl @@ -74,4 +74,6 @@ Create the name of the service account to use value: "{{ .Values.global.internalAuthServerRequireHttpsMetadata }}" - name: "StringEncryption__DefaultPassPhrase" value: "{{ .Values.global.stringEncryptionDefaultPassPhrase }}" +- name: "RabbitMQ__Connections__Default__HostName" + value: "{{ .Values.global.rabbitMqHostName }}" {{- end }} diff --git a/etc/k8s/eshoponabp/values.yaml b/etc/k8s/eshoponabp/values.yaml index fd40c5f1..a2dcc6b0 100644 --- a/etc/k8s/eshoponabp/values.yaml +++ b/etc/k8s/eshoponabp/values.yaml @@ -93,20 +93,21 @@ global: domain: eshoponabp-identity url: https://eshoponabp-identity containerImage: "eshoponabp/service-identity" - connString: "Server=eshoponabp-sqldb,1434;Database=EShopOnAbp_Identity;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" + connString: "Server=eshoponabp-sqldb,1433;Database=EShopOnAbp_Identity;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" administrationService: domain: eshoponabp-administration url: https://eshoponabp-administration containerImage: "eshoponabp/service-administration" - connString: "Server=eshoponabp-sqldb,1434;Database=EShopOnAbp_Administration;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" + connString: "Server=eshoponabp-sqldb,1433;Database=EShopOnAbp_Administration;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" saasService: domain: eshoponabp-saas url: https://eshoponabp-saas containerImage: "eshoponabp/service-saas" - connString: "Server=eshoponabp-sqldb,1434;Database=EShopOnAbp_Saas;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" + connString: "Server=eshoponabp-sqldb,1433;Database=EShopOnAbp_Saas;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" redisConfiguration: "eshoponabp-redis" + rabbitMqHostName: "eshoponabp-rabbitmq" nginxProxyBufferSize: "32k" nginxProxyBuffersNumber: "8" internalAuthServerAuthority: "http://eshoponabp-authserver" internalAuthServerRequireHttpsMetadata: "false" - stringEncryptionDefaultPassPhrase: "TxVIZFPxK33czbbv" \ No newline at end of file + stringEncryptionDefaultPassPhrase: "gsKnGZ041HLL4IM8" \ No newline at end of file From fd8bd927262a55d54a680519e3eabe6cff6af5eb Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 14 Oct 2021 11:39:58 +0300 Subject: [PATCH 09/12] added saas and administration service charts --- .../charts/administration/Chart.yaml | 6 ++++ .../templates/administration-ingress.yaml | 27 +++++++++++++++++ .../templates/administration-service.yaml} | 0 .../templates/administration.yaml | 29 +++++++++++++++++++ .../charts/administration/values.yaml | 0 .../identity/templates/identity-service.yaml | 14 +++++++++ etc/k8s/eshoponabp/charts/saas/Chart.yaml | 6 ++++ .../charts/saas/templates/saas-ingress.yaml | 27 +++++++++++++++++ .../charts/saas/templates/saas-service.yaml | 14 +++++++++ .../charts/saas/templates/saas.yaml | 29 +++++++++++++++++++ etc/k8s/eshoponabp/charts/saas/values.yaml | 0 etc/k8s/eshoponabp/values.yaml | 2 +- 12 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 etc/k8s/eshoponabp/charts/administration/Chart.yaml create mode 100644 etc/k8s/eshoponabp/charts/administration/templates/administration-ingress.yaml rename etc/k8s/eshoponabp/charts/{identity/templates/admin-api-service.yaml => administration/templates/administration-service.yaml} (100%) create mode 100644 etc/k8s/eshoponabp/charts/administration/templates/administration.yaml create mode 100644 etc/k8s/eshoponabp/charts/administration/values.yaml create mode 100644 etc/k8s/eshoponabp/charts/identity/templates/identity-service.yaml create mode 100644 etc/k8s/eshoponabp/charts/saas/Chart.yaml create mode 100644 etc/k8s/eshoponabp/charts/saas/templates/saas-ingress.yaml create mode 100644 etc/k8s/eshoponabp/charts/saas/templates/saas-service.yaml create mode 100644 etc/k8s/eshoponabp/charts/saas/templates/saas.yaml create mode 100644 etc/k8s/eshoponabp/charts/saas/values.yaml diff --git a/etc/k8s/eshoponabp/charts/administration/Chart.yaml b/etc/k8s/eshoponabp/charts/administration/Chart.yaml new file mode 100644 index 00000000..a3bfe56a --- /dev/null +++ b/etc/k8s/eshoponabp/charts/administration/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: administration +appVersion: "1.0" +description: Administration Microservice +version: 1.0.0 +type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/administration/templates/administration-ingress.yaml b/etc/k8s/eshoponabp/charts/administration/templates/administration-ingress.yaml new file mode 100644 index 00000000..14af3ff2 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/administration/templates/administration-ingress.yaml @@ -0,0 +1,27 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress + annotations: + kubernetes.io/ingress.class: "nginx" + nginx.ingress.kubernetes.io/rewrite-target: / + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ .Values.global.nginxProxyBufferSize }}" + nginx.ingress.kubernetes.io/proxy-buffers-number: "{{ .Values.global.nginxProxyBuffersNumber }}" + cert-manager.io/cluster-issuer: letsencrypt +spec: + tls: + - hosts: + - {{ .Values.global.administrationService.domain }} + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls + rules: + - host: "{{ .Values.global.administrationService.domain }}" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }} + port: + number: 80 \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/identity/templates/admin-api-service.yaml b/etc/k8s/eshoponabp/charts/administration/templates/administration-service.yaml similarity index 100% rename from etc/k8s/eshoponabp/charts/identity/templates/admin-api-service.yaml rename to etc/k8s/eshoponabp/charts/administration/templates/administration-service.yaml diff --git a/etc/k8s/eshoponabp/charts/administration/templates/administration.yaml b/etc/k8s/eshoponabp/charts/administration/templates/administration.yaml new file mode 100644 index 00000000..83b23304 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/administration/templates/administration.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: {{ .Values.global.administrationService.containerImage }}:{{ .Values.global.eventHubImageVersion }} + imagePullPolicy: {{ .Values.global.imagePullPolicy }} + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + env: +{{ include "eshoponabp.global.env" . | indent 8 }} + - name: "ConnectionStrings__AdministrationService" + value: {{ .Values.global.administrationService.connString }} + - name: "ConnectionStrings__SaasService" + value: {{ .Values.global.saasService.connString }} + diff --git a/etc/k8s/eshoponabp/charts/administration/values.yaml b/etc/k8s/eshoponabp/charts/administration/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/etc/k8s/eshoponabp/charts/identity/templates/identity-service.yaml b/etc/k8s/eshoponabp/charts/identity/templates/identity-service.yaml new file mode 100644 index 00000000..ee157c01 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/identity/templates/identity-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + ports: + - name: "80" + port: 80 + - name: "443" + port: 443 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/eshoponabp/charts/saas/Chart.yaml b/etc/k8s/eshoponabp/charts/saas/Chart.yaml new file mode 100644 index 00000000..49bf0902 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/saas/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: saas +appVersion: "1.0" +description: Saas Microservice +version: 1.0.0 +type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/saas/templates/saas-ingress.yaml b/etc/k8s/eshoponabp/charts/saas/templates/saas-ingress.yaml new file mode 100644 index 00000000..3e8002eb --- /dev/null +++ b/etc/k8s/eshoponabp/charts/saas/templates/saas-ingress.yaml @@ -0,0 +1,27 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress + annotations: + kubernetes.io/ingress.class: "nginx" + nginx.ingress.kubernetes.io/rewrite-target: / + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ .Values.global.nginxProxyBufferSize }}" + nginx.ingress.kubernetes.io/proxy-buffers-number: "{{ .Values.global.nginxProxyBuffersNumber }}" + cert-manager.io/cluster-issuer: letsencrypt +spec: + tls: + - hosts: + - {{ .Values.global.identityService.domain }} + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls + rules: + - host: "{{ .Values.global.identityService.domain }}" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }} + port: + number: 80 \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/saas/templates/saas-service.yaml b/etc/k8s/eshoponabp/charts/saas/templates/saas-service.yaml new file mode 100644 index 00000000..ee157c01 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/saas/templates/saas-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + ports: + - name: "80" + port: 80 + - name: "443" + port: 443 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/eshoponabp/charts/saas/templates/saas.yaml b/etc/k8s/eshoponabp/charts/saas/templates/saas.yaml new file mode 100644 index 00000000..e0ee1297 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/saas/templates/saas.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: {{ .Values.global.saasService.containerImage }}:{{ .Values.global.eventHubImageVersion }} + imagePullPolicy: {{ .Values.global.imagePullPolicy }} + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + env: +{{ include "eshoponabp.global.env" . | indent 8 }} + - name: "ConnectionStrings__AdministrationService" + value: {{ .Values.global.administrationService.connString }} + - name: "ConnectionStrings__SaasService" + value: {{ .Values.global.saasService.connString }} + diff --git a/etc/k8s/eshoponabp/charts/saas/values.yaml b/etc/k8s/eshoponabp/charts/saas/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/etc/k8s/eshoponabp/values.yaml b/etc/k8s/eshoponabp/values.yaml index a2dcc6b0..476e049b 100644 --- a/etc/k8s/eshoponabp/values.yaml +++ b/etc/k8s/eshoponabp/values.yaml @@ -93,7 +93,7 @@ global: domain: eshoponabp-identity url: https://eshoponabp-identity containerImage: "eshoponabp/service-identity" - connString: "Server=eshoponabp-sqldb,1433;Database=EShopOnAbp_Identity;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" + connString: "Server=eshoponabp-sqldb,1433;Database=EShopOnAbp_Identity;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=false" administrationService: domain: eshoponabp-administration url: https://eshoponabp-administration From 4e5e865d81abf740b6792867e57977b80740844e Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 14 Oct 2021 12:00:55 +0300 Subject: [PATCH 10/12] removed gateway client creations --- .../appsettings.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json index 11371943..00acbfa9 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json @@ -69,12 +69,6 @@ }, "PaymentService": { "RootUrl": "https://localhost:44357" - }, - "WebGateway": { - "RootUrl": "https://localhost:44372" - }, - "WebPublicGateway": { - "RootUrl": "https://localhost:44373" } } } From efee99c5cc9db3f76f38a6bbf0af2615377ee645 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 14 Oct 2021 14:13:18 +0300 Subject: [PATCH 11/12] added public web app and public web gateway charts --- .../charts/administration/Chart.yaml | 2 +- .../eshoponabp/charts/authserver/Chart.yaml | 2 +- etc/k8s/eshoponabp/charts/identity/Chart.yaml | 2 +- .../eshoponabp/charts/public-web/Chart.yaml | 6 +++ .../templates/public-web-ingress.yaml | 37 +++++++++++++++++++ .../templates/public-web-service.yaml | 14 +++++++ .../public-web/templates/public-web.yaml | 24 ++++++++++++ .../eshoponabp/charts/public-web/values.yaml | 0 .../charts/public-webgateway/Chart.yaml | 6 +++ .../templates/public-webgateway-ingress.yaml | 37 +++++++++++++++++++ .../templates/public-webgateway-service.yaml | 14 +++++++ .../templates/public-webgateway.yaml | 24 ++++++++++++ .../charts/public-webgateway/values.yaml | 0 etc/k8s/eshoponabp/charts/saas/Chart.yaml | 2 +- etc/k8s/eshoponabp/values.yaml | 10 ++++- 15 files changed, 175 insertions(+), 5 deletions(-) create mode 100644 etc/k8s/eshoponabp/charts/public-web/Chart.yaml create mode 100644 etc/k8s/eshoponabp/charts/public-web/templates/public-web-ingress.yaml create mode 100644 etc/k8s/eshoponabp/charts/public-web/templates/public-web-service.yaml create mode 100644 etc/k8s/eshoponabp/charts/public-web/templates/public-web.yaml create mode 100644 etc/k8s/eshoponabp/charts/public-web/values.yaml create mode 100644 etc/k8s/eshoponabp/charts/public-webgateway/Chart.yaml create mode 100644 etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway-ingress.yaml create mode 100644 etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway-service.yaml create mode 100644 etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway.yaml create mode 100644 etc/k8s/eshoponabp/charts/public-webgateway/values.yaml diff --git a/etc/k8s/eshoponabp/charts/administration/Chart.yaml b/etc/k8s/eshoponabp/charts/administration/Chart.yaml index a3bfe56a..914a83f8 100644 --- a/etc/k8s/eshoponabp/charts/administration/Chart.yaml +++ b/etc/k8s/eshoponabp/charts/administration/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: administration appVersion: "1.0" -description: Administration Microservice +description: eShopOnAbp Administration Microservice version: 1.0.0 type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/authserver/Chart.yaml b/etc/k8s/eshoponabp/charts/authserver/Chart.yaml index 361d0a7e..2308e945 100644 --- a/etc/k8s/eshoponabp/charts/authserver/Chart.yaml +++ b/etc/k8s/eshoponabp/charts/authserver/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: authserver appVersion: "1.0" -description: eShop AuthServer Application +description: eShopOnAbp AuthServer Application version: 1.0.0 type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/identity/Chart.yaml b/etc/k8s/eshoponabp/charts/identity/Chart.yaml index 0af4b111..967a2ca0 100644 --- a/etc/k8s/eshoponabp/charts/identity/Chart.yaml +++ b/etc/k8s/eshoponabp/charts/identity/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: identity appVersion: "1.0" -description: Identity Microservice +description: eShopOnAbp Identity Microservice version: 1.0.0 type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/public-web/Chart.yaml b/etc/k8s/eshoponabp/charts/public-web/Chart.yaml new file mode 100644 index 00000000..b4dfae47 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/public-web/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: public-web +appVersion: "1.0" +description: eShopOnAbp Public Web Application +version: 1.0.0 +type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/public-web/templates/public-web-ingress.yaml b/etc/k8s/eshoponabp/charts/public-web/templates/public-web-ingress.yaml new file mode 100644 index 00000000..8211a13b --- /dev/null +++ b/etc/k8s/eshoponabp/charts/public-web/templates/public-web-ingress.yaml @@ -0,0 +1,37 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/rewrite-target: / + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ .Values.global.nginxProxyBufferSize }}" + nginx.ingress.kubernetes.io/proxy-buffers-number: "{{ .Values.global.nginxProxyBuffersNumber }}" +{{- if eq .Release.Name "eh-az" }} + nginx.ingress.kubernetes.io/from-to-www-redirect: "true" +{{- end }} + cert-manager.io/cluster-issuer: letsencrypt +spec: + tls: + - hosts: + - {{ .Values.global.publicWeb.domain }} +{{- if eq .Release.Name "eh-az" }} + - {{ print "www." .Values.global.publicWeb.domain }} +{{- end }} + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls + rules: +{{- if eq .Release.Name "eh-az" }} + - host: "{{ print "www." .Values.global.publicWeb.domain }}" +{{- else }} + - host: "{{ .Values.global.publicWeb.domain }}" +{{- end }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }} + port: + number: 80 \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/public-web/templates/public-web-service.yaml b/etc/k8s/eshoponabp/charts/public-web/templates/public-web-service.yaml new file mode 100644 index 00000000..ee157c01 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/public-web/templates/public-web-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + ports: + - name: "80" + port: 80 + - name: "443" + port: 443 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/eshoponabp/charts/public-web/templates/public-web.yaml b/etc/k8s/eshoponabp/charts/public-web/templates/public-web.yaml new file mode 100644 index 00000000..3766e986 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/public-web/templates/public-web.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: {{ .Values.global.publicWeb.containerImage }}:{{ .Values.global.eshoponabpImageVersion }} + imagePullPolicy: {{ .Values.global.imagePullPolicy }} + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + env: +{{ include "eshoponabp.global.env" . | indent 8 }} diff --git a/etc/k8s/eshoponabp/charts/public-web/values.yaml b/etc/k8s/eshoponabp/charts/public-web/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/etc/k8s/eshoponabp/charts/public-webgateway/Chart.yaml b/etc/k8s/eshoponabp/charts/public-webgateway/Chart.yaml new file mode 100644 index 00000000..b2cd0e01 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/public-webgateway/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: public-webgateway +appVersion: "1.0" +description: eShopOnAbp Public Web Gateway Application +version: 1.0.0 +type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway-ingress.yaml b/etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway-ingress.yaml new file mode 100644 index 00000000..0a24b78c --- /dev/null +++ b/etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway-ingress.yaml @@ -0,0 +1,37 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }}-ingress + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/rewrite-target: / + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/proxy-buffer-size: "{{ .Values.global.nginxProxyBufferSize }}" + nginx.ingress.kubernetes.io/proxy-buffers-number: "{{ .Values.global.nginxProxyBuffersNumber }}" +{{- if eq .Release.Name "eh-az" }} + nginx.ingress.kubernetes.io/from-to-www-redirect: "true" +{{- end }} + cert-manager.io/cluster-issuer: letsencrypt +spec: + tls: + - hosts: + - {{ .Values.global.publicWebGateway.domain }} +{{- if eq .Release.Name "eh-az" }} + - {{ print "www." .Values.global.publicWebGateway.domain }} +{{- end }} + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls + rules: +{{- if eq .Release.Name "eh-az" }} + - host: "{{ print "www." .Values.global.publicWebGateway.domain }}" +{{- else }} + - host: "{{ .Values.global.publicWebGateway.domain }}" +{{- end }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }}-{{ .Chart.Name }} + port: + number: 80 \ No newline at end of file diff --git a/etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway-service.yaml b/etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway-service.yaml new file mode 100644 index 00000000..ee157c01 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + name: {{ .Release.Name }}-{{ .Chart.Name }} + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + ports: + - name: "80" + port: 80 + - name: "443" + port: 443 + selector: + app: {{ .Release.Name }}-{{ .Chart.Name }} diff --git a/etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway.yaml b/etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway.yaml new file mode 100644 index 00000000..470e520d --- /dev/null +++ b/etc/k8s/eshoponabp/charts/public-webgateway/templates/public-webgateway.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-{{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }}-{{ .Chart.Name }} + spec: + containers: + - image: {{ .Values.global.publicWebGateway.containerImage }}:{{ .Values.global.eshoponabpImageVersion }} + imagePullPolicy: {{ .Values.global.imagePullPolicy }} + name: {{ .Release.Name }}-{{ .Chart.Name }} + ports: + - name: http + containerPort: 80 + - name: https + containerPort: 443 + env: +{{ include "eshoponabp.global.env" . | indent 8 }} diff --git a/etc/k8s/eshoponabp/charts/public-webgateway/values.yaml b/etc/k8s/eshoponabp/charts/public-webgateway/values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/etc/k8s/eshoponabp/charts/saas/Chart.yaml b/etc/k8s/eshoponabp/charts/saas/Chart.yaml index 49bf0902..659b4618 100644 --- a/etc/k8s/eshoponabp/charts/saas/Chart.yaml +++ b/etc/k8s/eshoponabp/charts/saas/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: saas appVersion: "1.0" -description: Saas Microservice +description: eShopOnAbp Saas Microservice version: 1.0.0 type: application \ No newline at end of file diff --git a/etc/k8s/eshoponabp/values.yaml b/etc/k8s/eshoponabp/values.yaml index 476e049b..72715015 100644 --- a/etc/k8s/eshoponabp/values.yaml +++ b/etc/k8s/eshoponabp/values.yaml @@ -85,6 +85,10 @@ global: dotnetEnvironment: "Staging" imagePullPolicy: Never eshoponabpImageVersion: latest + publicWeb: + domain: eshoponabp-public-web + url: https://eshoponabp-public-web + containerImage: "eshoponabp/app-publicweb" authServer: domain: eshoponabp-authserver url: https://eshoponabp-authserver @@ -93,7 +97,7 @@ global: domain: eshoponabp-identity url: https://eshoponabp-identity containerImage: "eshoponabp/service-identity" - connString: "Server=eshoponabp-sqldb,1433;Database=EShopOnAbp_Identity;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=false" + connString: "Server=eshoponabp-sqldb,1433;Database=EShopOnAbp_Identity;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" administrationService: domain: eshoponabp-administration url: https://eshoponabp-administration @@ -104,6 +108,10 @@ global: url: https://eshoponabp-saas containerImage: "eshoponabp/service-saas" connString: "Server=eshoponabp-sqldb,1433;Database=EShopOnAbp_Saas;User Id=sa;password=myPassw@rd;MultipleActiveResultSets=true" + publicWebGateway: + domain: eshoponabp-public-webgateway + url: https://eshoponabp-public-webgateway + containerImage: "eshoponabp/gateway-publicweb" redisConfiguration: "eshoponabp-redis" rabbitMqHostName: "eshoponabp-rabbitmq" nginxProxyBufferSize: "32k" From 420b29ad4f18cbe88517e371a2621fbf3411c907 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Thu, 14 Oct 2021 14:15:43 +0300 Subject: [PATCH 12/12] added readme --- etc/k8s/README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 etc/k8s/README.md diff --git a/etc/k8s/README.md b/etc/k8s/README.md new file mode 100644 index 00000000..e34481e5 --- /dev/null +++ b/etc/k8s/README.md @@ -0,0 +1,33 @@ + ### Pre-requirements + +* Docker Desktop with Kubernetes enabled +* Install [NGINX ingress](https://kubernetes.github.io/ingress-nginx/deploy/) for k8s +OR +* Install NGINX ingress using helm +``` +helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx +helm repo update + +helm install ingress-nginx ingress-nginx/ingress-nginx +``` +* Install [Helm](https://helm.sh/docs/intro/install/) for running helm charts + + +### How to run? + +* Add entries to the hosts file (in Windows: `C:\Windows\System32\drivers\etc\hosts`): + +```` +127.0.0.1 eshoponabp-public-web +127.0.0.1 eshoponabp-authserver +127.0.0.1 eshoponabp-identity +127.0.0.1 eshoponabp-administration +127.0.0.1 eshoponabp-saas +127.0.0.1 eshoponabp-public-webgateway +```` + +* Run `build-images.ps1` in the `scripts` directory. +* Run `deploy-staging.ps1` in the `helm-chart` directory. It is deployed with the `eventhub` namespace. +* *You may wait ~30 seconds on first run for preparing the database*. +* Browse https://eshoponabp-public-web and https://eshoponabp-authserver +* Username: `admin`, password: `1q2w3E*`.