diff --git a/devops/gcp/configmap/README.md b/devops/gcp/configmap/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a3d5365d97cae32139c611fa38fa5c2aaf393fd2 --- /dev/null +++ b/devops/gcp/configmap/README.md @@ -0,0 +1,78 @@ +<!--- Configmap --> + +# Configmap helm chart + +## Introduction + +This chart bootstraps a configmap deployment on a [Kubernetes](https://kubernetes.io) cluster using [Helm](https://helm.sh) package manager. + +## Prerequisites + +The code was tested on **Kubernetes cluster** (v1.21.11) with **Istio** (1.12.6) +> It is possible to use other versions, but it hasn't been tested + +### Operation system + +The code works in Debian-based Linux (Debian 10 and Ubuntu 20.04) and Windows WSL 2. Also, it works but is not guaranteed in Google Cloud Shell. All other operating systems, including macOS, are not verified and supported. + +### Packages + +Packages are only needed for installation from a local computer. + +- **HELM** (version: v3.7.1 or higher) [helm](https://helm.sh/docs/intro/install/) +- **Kubectl** (version: v1.21.0 or higher) [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) +## Installation +First you need to set variables in **values.yaml** file using any code editor. Some of the values are prefilled, but you need to specify some values as well. You can find more information about them below. + +### Common variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**logLevel** | logging level | string | INFO | yes +**springProfilesActive** | active spring profile | string | gcp | yes +**defaultDataCountry** | Data storage region | string | US | yes +**storageServiceAccountEmail** | Storage service account email, used during OQM events processing | string | storage@service.local | yes + +### GCP variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**entitlementsHost** | entitlements service host address | string | `http://entitlements` | yes +**partitionHost** | partition service host address | string | `http://partition` | yes +**crsConverterHost** | CRS Converter service host address | string | `http://crs-conversion` | yes +**legalHost** | Legal service host address | string | `http://legal` | yes +**redisGroupHost** | Redis host for groups | string | `redis-group-master` | yes +**redisStorageHost** | Redis host for storage | string | `redis-storage-master` | yes +**googleAudiences** | your GCP client ID | string | - | yes + +> googleAudiences: If you are connected to GCP console with `gcloud auth application-default login --no-browser` from your terminal, you can get your client_id using the command: + +```console +cat ~/.config/gcloud/application_default_credentials.json | grep client_id +``` + +### Config variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**appName** | name of the app | string | storage | yes +**configmap** | configmap name | string | storage-config | yes +**onPremEnabled** | whether on-prem is enabled | boolean | false | yes + +### Install the helm chart + +Run this command from within this directory: + +```bash +helm install gcp-storage-configmap . +``` + +## Uninstalling the Chart + +To uninstall the helm deployment: + +```bash +helm uninstall gcp-storage-configmap +``` + +[Move-to-Top](#configmap-helm-chart) diff --git a/devops/gcp/configmap/templates/variables.yaml b/devops/gcp/configmap/templates/variables.yaml index f4b7fa8d881b54fa6ca93cdb46326264884260ca..6216ba0e7a26d77f5001de79cae4f56cc5b2da9e 100644 --- a/devops/gcp/configmap/templates/variables.yaml +++ b/devops/gcp/configmap/templates/variables.yaml @@ -2,20 +2,20 @@ apiVersion: v1 kind: ConfigMap metadata: labels: - app: "{{ .Values.conf.app_name }}" + app: "{{ .Values.conf.appName }}" name: "{{ .Values.conf.configmap }}" namespace: "{{ .Release.Namespace }}" data: - CRS_CONVERTER_HOST: "{{ .Values.data.crs_converter_host }}" - DEFAULT_DATA_COUNTRY: "{{ .Values.data.default_data_country }}" - ENTITLEMENTS_HOST: "{{ .Values.data.entitlements_host }}" - LEGALTAG_HOST: "{{ .Values.data.legaltag_host }}" - LOG_LEVEL: "{{ .Values.data.log_level }}" - PARTITION_HOST: "{{ .Values.data.partition_host }}" - REDIS_GROUP_HOST: "{{ .Values.data.redis_group_host }}" - REDIS_STORAGE_HOST: "{{ .Values.data.redis_storage_host }}" - STORAGE_SERVICE_ACCOUNT_EMAIL: "{{ .Values.data.storage_service_account_email }}" - SPRING_PROFILES_ACTIVE: "{{ .Values.data.spring_profiles_active }}" - {{- if not .Values.conf.on_prem_enabled }} - GOOGLE_AUDIENCES: "{{ .Values.data.google_audiences }}" + CRS_CONVERTER_HOST: "{{ .Values.data.crsConverterHost }}" + DEFAULT_DATA_COUNTRY: "{{ .Values.data.defaultDataCountry }}" + ENTITLEMENTS_HOST: "{{ .Values.data.entitlementsHost }}" + LEGAL_HOST: "{{ .Values.data.legalHost }}" + LOG_LEVEL: "{{ .Values.data.logLevel }}" + PARTITION_HOST: "{{ .Values.data.partitionHost }}" + REDIS_GROUP_HOST: "{{ .Values.data.redisGroupHost }}" + REDIS_STORAGE_HOST: "{{ .Values.data.redisStorageHost }}" + STORAGE_SERVICE_ACCOUNT_EMAIL: "{{ .Values.data.storageServiceAccountEmail }}" + SPRING_PROFILES_ACTIVE: "{{ .Values.data.springProfilesActive }}" + {{- if not .Values.conf.onPremEnabled }} + GOOGLE_AUDIENCES: "{{ .Values.data.googleAudiences }}" {{- end }} diff --git a/devops/gcp/configmap/values.yaml b/devops/gcp/configmap/values.yaml index c9e3b3b64a50f85256bb2be7aac0846ad1cbc4f9..62b83709aa03b1df50f466c34af6f6b3b4684db4 100644 --- a/devops/gcp/configmap/values.yaml +++ b/devops/gcp/configmap/values.yaml @@ -4,19 +4,20 @@ data: # common - crs_converter_host: "http://crs-conversion" - default_data_country: "US" - entitlements_host: "http://entitlements" - legaltag_host: "http://legal" - log_level: "INFO" - partition_host: "http://partition" - redis_group_host: "redis-group-master" - redis_storage_host: "redis-storage-master" - storage_service_account_email: "storage@service.local" - spring_profiles_active: "gcp" + logLevel: "INFO" + springProfilesActive: "gcp" + defaultDataCountry: "US" + storageServiceAccountEmail: "storage@service.local" + entitlementsHost: "http://entitlements" + partitionHost: "http://partition" + crsConverterHost: "http://crs-conversion" + legalHost: "http://legal" + redisGroupHost: "redis-group-master" + redisStorageHost: "redis-storage-master" + # gcp - google_audiences: "" + googleAudiences: "" conf: - app_name: "storage" + appName: "storage" configmap: "storage-config" - on_prem_enabled: false + onPremEnabled: false diff --git a/devops/gcp/deploy/README.md b/devops/gcp/deploy/README.md new file mode 100644 index 0000000000000000000000000000000000000000..87cca04d78aaa69d93ad2f01122d0ed8ce3ca782 --- /dev/null +++ b/devops/gcp/deploy/README.md @@ -0,0 +1,73 @@ +<!--- Deploy --> + +# Deploy helm chart + +## Introduction + +This chart bootstraps a deployment on a [Kubernetes](https://kubernetes.io) cluster using [Helm](https://helm.sh) package manager. + +## Prerequisites + +The code was tested on **Kubernetes cluster** (v1.21.11) with **Istio** (1.12.6) +> It is possible to use other versions, but it hasn't been tested + +### Operation system + +The code works in Debian-based Linux (Debian 10 and Ubuntu 20.04) and Windows WSL 2. Also, it works but is not guaranteed in Google Cloud Shell. All other operating systems, including macOS, are not verified and supported. + +### Packages + +Packages are only needed for installation from a local computer. + +- **HELM** (version: v3.7.1 or higher) [helm](https://helm.sh/docs/intro/install/) +- **Kubectl** (version: v1.21.0 or higher) [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) + +## Installation + +Before installing deploy Helm chart you need to install [configmap Helm chart](../configmap). +First you need to set variables in **values.yaml** file using any code editor. Some of the values are prefilled, but you need to specify some values as well. You can find more information about them below. + +### Common variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**requestsCpu** | amount of requested CPU | string | 0.25 | yes +**requestsMemory** | amount of requested memory| string | 2048M | yes +**limitsCpu** | CPU limit | string | 1 | yes +**limitsMemory** | memory limit | string | 3G | yes +**image** | service image | string | - | yes +**imagePullPolicy** | when to pull image | string | IfNotPresent | yes +**serviceAccountName** | name of your service account | string | storage | yes + +### Config variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| + +**appName** | name of the app | string | `storage` | yes +**configmap** | configmap to be used | string | `storage-config` | yes +**keycloakSecretName** | secret for keycloak | string | `storage-keycloak-secret` | yes +**minioSecretName** | secret for minio | string | `storage-minio-secret` | yes +**postgresSecretName** | secret for postgres | string | `storage-postgres-secret` | yes +**rabbitmqSecretName** | secret for rabbitmq | string | `rabbitmq-secret` | yes +**replicas** | Number of replicas | integer | 3 | yes +**onPremEnabled** | whether on-prem is enabled | boolean | false | yes +**domain** | your domain | string | - | yes + +### Install the helm chart + +Run this command from within this directory: + +```console +helm install gcp-storage-deploy . +``` + +## Uninstalling the Chart + +To uninstall the helm deployment: + +```console +helm uninstall gcp-storage-deploy +``` + +[Move-to-Top](#deploy-helm-chart) diff --git a/devops/gcp/deploy/templates/deployment.yaml b/devops/gcp/deploy/templates/deployment.yaml index 4cc8192c6b15969030888f486868f51f7cd80580..c54713f1919fba115b7400ecf00f7057d7051ba9 100644 --- a/devops/gcp/deploy/templates/deployment.yaml +++ b/devops/gcp/deploy/templates/deployment.yaml @@ -2,37 +2,37 @@ apiVersion: apps/v1 kind: Deployment metadata: labels: - app: "{{ .Values.conf.app_name }}" - name: "{{ .Values.conf.app_name }}" + app: "{{ .Values.conf.appName }}" + name: "{{ .Values.conf.appName }}" namespace: "{{ .Release.Namespace }}" spec: selector: matchLabels: - app: "{{ .Values.conf.app_name }}" + app: "{{ .Values.conf.appName }}" replicas: {{ .Values.conf.replicas }} template: metadata: labels: - app: "{{ .Values.conf.app_name }}" + app: "{{ .Values.conf.appName }}" annotations: rollme: {{ randAlphaNum 5 | quote }} spec: containers: - - name: "{{ .Values.conf.app_name }}" + - name: "{{ .Values.conf.appName }}" image: "{{ .Values.data.image }}" imagePullPolicy: "{{ .Values.data.imagePullPolicy }}" envFrom: - configMapRef: name: "{{ .Values.conf.configmap }}" - {{- if .Values.conf.on_prem_enabled }} + {{- if .Values.conf.onPremEnabled }} - secretRef: - name: "{{ .Values.conf.keycloak_secret_name }}" + name: "{{ .Values.conf.keycloakSecretName }}" - secretRef: - name: "{{ .Values.conf.minio_secret_name }}" + name: "{{ .Values.conf.minioSecretName }}" - secretRef: - name: "{{ .Values.conf.postgres_secret_name }}" + name: "{{ .Values.conf.postgresSecretName }}" - secretRef: - name: "{{ .Values.conf.rabbitmq_secret_name }}" + name: "{{ .Values.conf.rabbitmqSecretName }}" {{- end }} securityContext: allowPrivilegeEscalation: false @@ -41,9 +41,9 @@ spec: - containerPort: 8080 resources: requests: - cpu: "{{ .Values.data.requests_cpu }}" - memory: "{{ .Values.data.requests_memory }}" + cpu: "{{ .Values.data.requestsCpu }}" + memory: "{{ .Values.data.requestsMemory }}" limits: - cpu: "{{ .Values.data.limits_cpu }}" - memory: "{{ .Values.data.limits_memory }}" + cpu: "{{ .Values.data.limitsCpu }}" + memory: "{{ .Values.data.limitsMemory }}" serviceAccountName: "{{ .Values.data.serviceAccountName }}" diff --git a/devops/gcp/deploy/templates/service-account.yaml b/devops/gcp/deploy/templates/service-account.yaml index 3fede170cb014a4cfdf8cc99d745a32eb66aeed0..25fd74efbfca059f541af82d98b676cfcb930d64 100644 --- a/devops/gcp/deploy/templates/service-account.yaml +++ b/devops/gcp/deploy/templates/service-account.yaml @@ -1,4 +1,4 @@ -{{- if .Values.conf.on_prem_enabled }} +{{- if .Values.conf.onPremEnabled }} apiVersion: v1 kind: ServiceAccount metadata: diff --git a/devops/gcp/deploy/templates/service.yaml b/devops/gcp/deploy/templates/service.yaml index 86a62664207433e99140a462d942c0dc80f5a68f..b7e02b2ed551ad16a96b9894dad08399ddc4d02e 100644 --- a/devops/gcp/deploy/templates/service.yaml +++ b/devops/gcp/deploy/templates/service.yaml @@ -1,11 +1,11 @@ apiVersion: v1 kind: Service metadata: - {{- if not .Values.conf.on_prem_enabled }} + {{- if not .Values.conf.onPremEnabled }} annotations: cloud.google.com/neg: '{"ingress": true}' {{- end }} - name: "{{ .Values.conf.app_name }}" + name: "{{ .Values.conf.appName }}" namespace: "{{ .Release.Namespace }}" spec: ports: @@ -14,4 +14,4 @@ spec: targetPort: 8080 name: http selector: - app: "{{ .Values.conf.app_name }}" + app: "{{ .Values.conf.appName }}" diff --git a/devops/gcp/deploy/templates/virtual-service.yaml b/devops/gcp/deploy/templates/virtual-service.yaml index 87dc2a3bd19c717958453eb00429aa1ec6733519..50c783ac81efe547862e62968b8eb47b1101056a 100644 --- a/devops/gcp/deploy/templates/virtual-service.yaml +++ b/devops/gcp/deploy/templates/virtual-service.yaml @@ -1,12 +1,14 @@ apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: - name: "{{ .Values.conf.app_name }}" + name: "{{ .Values.conf.appName }}" namespace: "{{ .Release.Namespace }}" spec: hosts: - {{- if .Values.conf.domain }} + {{- if and .Values.conf.domain .Values.conf.onPremEnabled }} - {{ printf "osdu.%s" .Values.conf.domain | quote }} + {{- else if .Values.conf.domain }} + - {{ .Values.conf.domain | quote }} {{- else }} - "*" {{- end }} @@ -20,4 +22,4 @@ spec: - destination: port: number: 80 - host: "{{ .Values.conf.app_name }}.{{ .Release.Namespace }}.svc.cluster.local" + host: "{{ .Values.conf.appName }}.{{ .Release.Namespace }}.svc.cluster.local" diff --git a/devops/gcp/deploy/values.yaml b/devops/gcp/deploy/values.yaml index 3b582d020437f9aa7892dfc09c4a0ae35c50a808..9071744f44e052834f088e585e50c8328c1b4fe6 100644 --- a/devops/gcp/deploy/values.yaml +++ b/devops/gcp/deploy/values.yaml @@ -4,20 +4,20 @@ # common data: - requests_cpu: "0.25" - requests_memory: "2048M" - limits_cpu: "1" - limits_memory: "3G" + requestsCpu: "0.25" + requestsMemory: "2048M" + limitsCpu: "1" + limitsMemory: "3G" image: "" imagePullPolicy: "IfNotPresent" serviceAccountName: "storage" conf: - app_name: "storage" + appName: "storage" configmap: "storage-config" - keycloak_secret_name: "storage-keycloak-secret" - minio_secret_name: "storage-minio-secret" - on_prem_enabled: false - postgres_secret_name: "storage-postgres-secret" - rabbitmq_secret_name: "rabbitmq-secret" + keycloakSecretName: "storage-keycloak-secret" + minioSecretName: "storage-minio-secret" + postgresSecretName: "storage-postgres-secret" + rabbitmqSecretName: "rabbitmq-secret" replicas: 3 + onPremEnabled: false domain: ""