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*`. diff --git a/etc/k8s/deploy-staging.ps1 b/etc/k8s/deploy-staging.ps1 new file mode 100644 index 00000000..458642a7 --- /dev/null +++ b/etc/k8s/deploy-staging.ps1 @@ -0,0 +1,3 @@ +param ($version='latest') + +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/.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/charts/administration/Chart.yaml b/etc/k8s/eshoponabp/charts/administration/Chart.yaml new file mode 100644 index 00000000..914a83f8 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/administration/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: administration +appVersion: "1.0" +description: eShopOnAbp 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/administration/templates/administration-service.yaml b/etc/k8s/eshoponabp/charts/administration/templates/administration-service.yaml new file mode 100644 index 00000000..ee157c01 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/administration/templates/administration-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/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/authserver/Chart.yaml b/etc/k8s/eshoponabp/charts/authserver/Chart.yaml new file mode 100644 index 00000000..2308e945 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/authserver/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: authserver +appVersion: "1.0" +description: eShopOnAbp 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..a09b9cc5 --- /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.authServer.domain }} + secretName: {{ .Release.Name }}-{{ .Chart.Name }}-tls + rules: + - host: "{{ .Values.global.authServer.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/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..e59d1c5a --- /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.global.authServer.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.identityService.connString }} + - name: "ConnectionStrings__AdministrationService" + value: {{ .Values.global.administrationService.connString }} + - name: "ConnectionStrings__SaasService" + value: {{ .Values.global.saasService.connString }} \ No newline at end of file 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/identity/Chart.yaml b/etc/k8s/eshoponabp/charts/identity/Chart.yaml new file mode 100644 index 00000000..967a2ca0 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/identity/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: identity +appVersion: "1.0" +description: eShopOnAbp Identity Microservice +version: 1.0.0 +type: application \ No newline at end of file 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-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/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/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/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/saas/Chart.yaml b/etc/k8s/eshoponabp/charts/saas/Chart.yaml new file mode 100644 index 00000000..659b4618 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/saas/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: saas +appVersion: "1.0" +description: eShopOnAbp 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/charts/sqlserver/Chart.yaml b/etc/k8s/eshoponabp/charts/sqlserver/Chart.yaml new file mode 100644 index 00000000..647c03d2 --- /dev/null +++ b/etc/k8s/eshoponabp/charts/sqlserver/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: sqldb +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..653493f7 --- /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: 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 new file mode 100644 index 00000000..57a5bcac --- /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: 1433 + env: + - name: SA_PASSWORD + value: "myPassw@rd" + - 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: 32Gi +{{- 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 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..80649639 --- /dev/null +++ b/etc/k8s/eshoponabp/templates/_helpers.tpl @@ -0,0 +1,79 @@ +{{/* +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 }} + +{{- define "eshoponabp.global.env" -}} +- name: "DOTNET_ENVIRONMENT" + value: "{{ .Values.global.dotnetEnvironment }}" +- name: "AppUrls__ApiInternal" + value: "{{ .Values.global.apiUrlInternal }}" +- 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 }}" +- name: "RabbitMQ__Connections__Default__HostName" + value: "{{ .Values.global.rabbitMqHostName }}" +{{- 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..72715015 --- /dev/null +++ b/etc/k8s/eshoponabp/values.yaml @@ -0,0 +1,121 @@ +# 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: {} + +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 + containerImage: "eshoponabp/app-authserver" + identityService: + 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" + administrationService: + domain: eshoponabp-administration + url: https://eshoponabp-administration + containerImage: "eshoponabp/service-administration" + 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,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" + nginxProxyBuffersNumber: "8" + internalAuthServerAuthority: "http://eshoponabp-authserver" + internalAuthServerRequireHttpsMetadata: "false" + stringEncryptionDefaultPassPhrase: "gsKnGZ041HLL4IM8" \ No newline at end of file diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json index 74ea613f..f6ddc93a 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/appsettings.json @@ -74,12 +74,6 @@ }, "PaymentService": { "RootUrl": "https://localhost:44357" - }, - "WebGateway": { - "RootUrl": "https://localhost:44372" - }, - "WebPublicGateway": { - "RootUrl": "https://localhost:44373" } } }