diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b7c1bc77d4e4af5292bca99d81821d0113f7e23..8d9495b53d7b5f6c51b10231e65fb0ff81c5a936 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,6 +18,9 @@ variables: AZURE_TEST_SUBDIR: testing/register-test-azure AZURE_SWAGGER_PATH: api/register/v1/swagger-ui/index.html#/ + # FIXME remove when all services are migrated to a single helm + OSDU_GCP_ENABLE_HELM_CONFIG: "false" + include: - project: "osdu/platform/ci-cd-pipelines" file: "standard-setup.yml" diff --git a/devops/gcp/configmap/Chart.yaml b/devops/gcp/configmap/Chart.yaml deleted file mode 100644 index f1bd988ddf7489da00c6a690885b69f1c2fe1ecc..0000000000000000000000000000000000000000 --- a/devops/gcp/configmap/Chart.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: v2 -name: gcp-register-configmap -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/devops/gcp/configmap/README.md b/devops/gcp/configmap/README.md deleted file mode 100644 index 9b020b2bc109f2b637ee5cfd8be90a583803e1d7..0000000000000000000000000000000000000000 --- a/devops/gcp/configmap/README.md +++ /dev/null @@ -1,81 +0,0 @@ -<!--- 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 - -### Google Cloud variables - -| Name | Description | Type | Default |Required | -|------|-------------|------|---------|---------| -**googleCloudProject** | your Google Cloud cloud project | string | -| yes -**googleAudiences** | your Google Cloud client ID | string | - | yes -**entitlementsHost** | Entitlements host | string | "http://entitlements" | yes -**partitionHost** | Partition host | string | "http://partition" | yes -**recordsChangedPubsubEndpoint** | Endpoint to PubSub topic | string | - | yes -**storageHost** | Storage host | string | "http://storage" | yes -**serviceIdentity** | Service account in Google Cloud fo PubSub | string | "register-pubsub-identity" | yes -**keyRing** | Type of keys | string | "csqp" | yes -**kmsKey** | Key management service key (must be replaced during installation) | string | "registerService" | yes -**subscriberPrivateKeyId** | Subscriber test private key id (must be replaced during installation) | string | "testkey" | yes - -### Config variables - -| Name | Description | Type | Default |Required | -|------|-------------|------|---------|---------| -**configmap** | configmap to be used | string | register-config | yes -**appName** | name of the app | string | register | yes -**onPremEnabled** | whether on-prem is enabled | boolean | false | yes - -### Install the helm chart - -Run this command from within this directory: - -```console -helm install gcp-register-configmap . -``` - -## Uninstalling the Chart - -To uninstall the helm deployment: - -```console -helm uninstall gcp-register-configmap -``` - -To delete secrets and PVCs: - -```console -kubectl delete secret --all; kubectl delete pvc --all -``` - -[Move-to-Top](#configmap-helm-chart) diff --git a/devops/gcp/configmap/templates/register-variables.yml b/devops/gcp/configmap/templates/register-variables.yml deleted file mode 100644 index 110321dca7e404f20b29981c61c33e9fe5397080..0000000000000000000000000000000000000000 --- a/devops/gcp/configmap/templates/register-variables.yml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - labels: - app: "{{ .Values.conf.appName }}" - name: "{{ .Values.conf.configmap }}" - namespace: "{{ .Release.Namespace }}" -data: - LOG_LEVEL: "{{ .Values.data.logLevel }}" - SPRING_PROFILES_ACTIVE: "{{ .Values.data.springProfilesActive }}" - SUBSCRIBER_PRIVATE_KEY_ID: "{{ .Values.data.subscriberPrivateKeyId }}" - {{- if .Values.conf.cicdEnabled }} - INTEGRATION_TEST_AUDIENCES: "{{.Values.data.googleAudiences}}" - {{- end }} - {{- if not .Values.conf.onPremEnabled }} - GOOGLE_CLOUD_PROJECT: "{{ .Values.data.googleCloudProject }}" - GOOGLE_AUDIENCES: "{{ .Values.data.googleAudiences }}" - ENTITLEMENTS_HOST: "{{ .Values.data.entitlementsHost }}" - RECORDS_CHANGE_PUBSUB_ENDPOINT: "{{ .Values.data.recordsChangePubsubEndpoint }}" - PARTITION_HOST: "{{ .Values.data.partitionHost }}" - STORAGE_HOST: "{{ .Values.data.storageHost }}" - SERVICE_IDENTITY: "{{ .Values.data.serviceIdentity }}" - KEY_RING: "{{ .Values.data.keyRing }}" - KMS_KEY: "{{ .Values.data.kmsKey }}" - {{- end }} diff --git a/devops/gcp/configmap/values.yaml b/devops/gcp/configmap/values.yaml deleted file mode 100644 index 3e5f5c578ec464ffd3cb2725b38db5c4f757d1df..0000000000000000000000000000000000000000 --- a/devops/gcp/configmap/values.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Default values for register-configmap. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -data: - # common - logLevel: "ERROR" - springProfilesActive: "gcp" - # gcp - googleCloudProject: "" - googleAudiences: "" - entitlementsHost: "http://entitlements" - partitionHost: "http://partition" - recordsChangedPubsubEndpoint: "" - storageHost: "http://storage" - serviceIdentity: "register-pubsub-identity" - keyRing: "csqp" - kmsKey: "registerService" - subscriberPrivateKeyId: "testkey" - -conf: - configmap: "register-config" - appName: "register" - onPremEnabled: false - cicdEnabled: false diff --git a/devops/gcp/deploy/README.md b/devops/gcp/deploy/README.md index 44bb77bc77e27acbd15224988050a64513d19ec4..ebc9e8ebf1cce6eaa6dcd3dcb0e08378cb02ab09 100644 --- a/devops/gcp/deploy/README.md +++ b/devops/gcp/deploy/README.md @@ -27,30 +27,56 @@ Packages are only needed for installation from a local computer. 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 +### Configmap variables | Name | Description | Type | Default |Required | |------|-------------|------|---------|---------| -**image** | your image name | string | - | yes -**requestsCpu** | amount of requests CPU | string | 0.1 | yes -**requestsMemory** | amount of requests memory| string | 384M | yes -**limitsCpu** | CPU limit | string | 1 | yes -**limitsMemory** | memory limit | string | 1G | yes -**serviceAccountName** | name of your service account | string | register | yes -**imagePullPolicy** | when to pull image | string | IfNotPresent | yes +**data.logLevel** | logging level | string | INFO | yes +**data.springProfilesActive** | active spring profile | string | gcp | yes +**data.googleCloudProject** | your Google Cloud cloud project | string | -| yes +**data.googleAudiences** | your Google Cloud client ID | string | - | yes +**data.entitlementsHost** | Entitlements host | string | "http://entitlements" | yes +**data.partitionHost** | Partition host | string | "http://partition" | yes +**data.recordsChangedPubsubEndpoint** | Endpoint to PubSub topic | string | - | yes +**data.storageHost** | Storage host | string | "http://storage" | yes +**data.serviceIdentity** | Service account in Google Cloud fo PubSub | string | "register-pubsub-identity" | yes +**data.keyRing** | Type of keys | string | "csqp" | yes +**data.kmsKey** | Key management service key (must be replaced during installation) | string | "registerService" | yes +**data.subscriberPrivateKeyId** | Subscriber test private key id (must be replaced during installation) | string | "testkey" | yes + +### Deployment variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**data.image** | your image name | string | - | yes +**data.requestsCpu** | amount of requests CPU | string | 0.1 | yes +**data.requestsMemory** | amount of requests memory| string | 384M | yes +**data.limitsCpu** | CPU limit | string | 1 | yes +**data.limitsMemory** | memory limit | string | 1G | yes +**data.serviceAccountName** | name of your service account | string | register | yes +**data.imagePullPolicy** | when to pull image | string | IfNotPresent | yes ### Config variables | Name | Description | Type | Default |Required | |------|-------------|------|---------|---------| -**appName** | name of the app | string | register | yes -**configmap** | configmap to be used | string | register-config | yes -**registerPostgresSecretName** | secret for postgres | string | register-postgres-secret | yes -**registerKeycloakSecretName** | secret for keycloak | string | register-keycloak-secret | yes -**registerKmsSecretName** | secret for kms | string | "register-kms-secret" | yes -**rabbitmqSecretName** | secret for rabbitmq | string | rabbitmq-secret | yes -**onPremEnabled** | whether on-prem is enabled | boolean | false | yes -**domain** | your domain | string | - | yes +**conf.appName** | name of the app | string | register | yes +**conf.configmap** | configmap to be used | string | register-config | yes +**conf.registerPostgresSecretName** | secret for postgres | string | register-postgres-secret | yes +**conf.registerKeycloakSecretName** | secret for keycloak | string | register-keycloak-secret | yes +**conf.registerKmsSecretName** | secret for kms | string | "register-kms-secret" | yes +**conf.rabbitmqSecretName** | secret for rabbitmq | string | rabbitmq-secret | yes +**conf.onPremEnabled** | whether on-prem is enabled | boolean | false | yes +**conf.domain** | your domain | string | - | yes + +### ISTIO variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**istio.proxyCPU** | CPU request for Envoy sidecars | string | 50m | yes +**istio.proxyCPULimit** | CPU limit for Envoy sidecars | string | 500m | yes +**istio.proxyMemory** | memory request for Envoy sidecars | string | 64Mi | yes +**istio.proxyMemoryLimit** | memory limit for Envoy sidecars | string | 512Mi | yes ### Install the helm chart diff --git a/devops/gcp/deploy/templates/register-deploy.yml b/devops/gcp/deploy/templates/register-deploy.yml index 28aee193c1df35332d15e3f0f6a1a3803342dc3b..7d8363484739cf96d3841a8134ae30899ca6847c 100644 --- a/devops/gcp/deploy/templates/register-deploy.yml +++ b/devops/gcp/deploy/templates/register-deploy.yml @@ -2,18 +2,18 @@ apiVersion: apps/v1 kind: Deployment metadata: labels: - app: "{{ .Values.conf.appName }}" - name: "{{ .Values.conf.appName }}" - namespace: "{{ .Release.Namespace }}" + app: {{ .Values.conf.appName | quote }} + name: {{ .Values.conf.appName | quote }} + namespace: {{ .Release.Namespace | quote }} spec: selector: matchLabels: - app: "{{ .Values.conf.appName }}" + app: {{ .Values.conf.appName | quote }} replicas: 1 template: metadata: labels: - app: "{{ .Values.conf.appName }}" + app: {{ .Values.conf.appName | quote }} annotations: rollme: {{ randAlphaNum 5 | quote }} sidecar.istio.io/proxyCPU: {{ .Values.istio.proxyCPU | quote }} @@ -22,21 +22,21 @@ spec: sidecar.istio.io/proxyMemoryLimit: {{ .Values.istio.proxyMemoryLimit | quote }} spec: containers: - - name: "{{ .Values.conf.appName }}" - image: "{{ .Values.data.image }}" - imagePullPolicy: "{{ .Values.data.imagePullPolicy }}" + - name: {{ .Values.conf.appName | quote }} + image: {{ .Values.data.image | quote }} + imagePullPolicy: {{ .Values.data.imagePullPolicy | quote }} envFrom: - configMapRef: - name: "{{ .Values.conf.configmap }}" + name: {{ .Values.conf.configmap | quote }} {{- if .Values.conf.onPremEnabled }} - secretRef: - name: "{{ .Values.conf.rabbitmqSecretName }}" + name: {{ .Values.conf.rabbitmqSecretName | quote }} - secretRef: - name: "{{ .Values.conf.registerPostgresSecretName }}" + name: {{ .Values.conf.registerPostgresSecretName | quote }} - secretRef: - name: "{{ .Values.conf.registerKeycloakSecretName }}" + name: {{ .Values.conf.registerKeycloakSecretName | quote }} - secretRef: - name: "{{ .Values.conf.registerKmsSecretName }}" + name: {{ .Values.conf.registerKmsSecretName | quote }} {{- end }} securityContext: allowPrivilegeEscalation: false @@ -45,9 +45,9 @@ spec: - containerPort: 8080 resources: requests: - cpu: "{{ .Values.data.requestsCpu }}" - memory: "{{ .Values.data.requestsMemory }}" + cpu: {{ .Values.data.requestsCpu | quote }} + memory: {{ .Values.data.requestsMemory | quote }} limits: - cpu: "{{ .Values.data.limitsCpu }}" - memory: "{{ .Values.data.limitsMemory }}" - serviceAccountName: "{{ .Values.data.serviceAccountName }}" + cpu: {{ .Values.data.limitsCpu | quote }} + memory: {{ .Values.data.limitsMemory | quote }} + serviceAccountName: {{ .Values.data.serviceAccountName | quote }} diff --git a/devops/gcp/deploy/templates/register-service-account.yml b/devops/gcp/deploy/templates/register-service-account.yml index 25fd74efbfca059f541af82d98b676cfcb930d64..f0771985cd5da9db77781dc3ab635e52378b3fb6 100644 --- a/devops/gcp/deploy/templates/register-service-account.yml +++ b/devops/gcp/deploy/templates/register-service-account.yml @@ -2,6 +2,6 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: "{{ .Values.data.serviceAccountName }}" - namespace: "{{ .Release.Namespace }}" + name: {{ .Values.data.serviceAccountName | quote }} + namespace: {{ .Release.Namespace | quote }} {{- end }} diff --git a/devops/gcp/deploy/templates/register-service.yml b/devops/gcp/deploy/templates/register-service.yml index 2f158ffe0442ebbad426da677867721c9e6e0047..6535489d6863b0310002119bd4d29b6e2202af76 100644 --- a/devops/gcp/deploy/templates/register-service.yml +++ b/devops/gcp/deploy/templates/register-service.yml @@ -1,15 +1,15 @@ apiVersion: v1 kind: Service metadata: - name: "{{ .Values.conf.appName }}" + name: {{ .Values.conf.appName | quote }} annotations: {{- if not .Values.conf.onPremEnabled }} cloud.google.com/neg: '{"ingress": true}' {{- end }} - namespace: "{{ .Release.Namespace }}" + namespace: {{ .Release.Namespace | quote }} labels: - app: "{{ .Values.conf.appName }}" - service: "{{ .Values.conf.appName }}" + app: {{ .Values.conf.appName | quote }} + service: {{ .Values.conf.appName | quote }} spec: ports: - protocol: TCP @@ -17,4 +17,4 @@ spec: targetPort: 8080 name: http selector: - app: "{{ .Values.conf.appName }}" + app: {{ .Values.conf.appName | quote }} diff --git a/devops/gcp/deploy/templates/register-variables.yml b/devops/gcp/deploy/templates/register-variables.yml new file mode 100644 index 0000000000000000000000000000000000000000..a948126ec0a9c46d5e70b359fedc5a44459df394 --- /dev/null +++ b/devops/gcp/deploy/templates/register-variables.yml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + app: {{ .Values.conf.appName | quote }} + name: {{ .Values.conf.configmap | quote }} + namespace: {{ .Release.Namespace | quote }} +data: + LOG_LEVEL: {{ .Values.data.logLevel | quote }} + SPRING_PROFILES_ACTIVE: {{ .Values.data.springProfilesActive | quote }} + SUBSCRIBER_PRIVATE_KEY_ID: {{ .Values.data.subscriberPrivateKeyId | quote }} + {{- if .Values.conf.cicdEnabled }} + INTEGRATION_TEST_AUDIENCES: {{.Values.data.googleAudiences | quote }} + {{- end }} + {{- if not .Values.conf.onPremEnabled }} + GOOGLE_CLOUD_PROJECT: {{ .Values.data.googleCloudProject | quote }} + GOOGLE_AUDIENCES: {{ .Values.data.googleAudiences | quote }} + ENTITLEMENTS_HOST: {{ .Values.data.entitlementsHost | quote }} + RECORDS_CHANGE_PUBSUB_ENDPOINT: "{{ .Values.data.recordsChangePubsubEndpoint}}" + PARTITION_HOST: {{ .Values.data.partitionHost | quote }} + STORAGE_HOST: {{ .Values.data.storageHost | quote }} + SERVICE_IDENTITY: {{ .Values.data.serviceIdentity | quote }} + KEY_RING: {{ .Values.data.keyRing | quote}} + KMS_KEY: {{ .Values.data.kmsKey | quote }} + {{- end }} diff --git a/devops/gcp/deploy/templates/register-virtual-service.yml b/devops/gcp/deploy/templates/register-virtual-service.yml index 56d685621545b89a40d7058a1e156f8478f1edb6..6b6167201d3a7b313ebb47de180b371e7ae03e69 100644 --- a/devops/gcp/deploy/templates/register-virtual-service.yml +++ b/devops/gcp/deploy/templates/register-virtual-service.yml @@ -1,8 +1,8 @@ apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: - name: "{{ .Values.conf.appName }}" - namespace: "{{ .Release.Namespace }}" + name: {{ .Values.conf.appName | quote }} + namespace: {{ .Release.Namespace | quote }} spec: hosts: {{- if and .Values.conf.domain .Values.conf.onPremEnabled }} @@ -22,4 +22,4 @@ spec: - destination: port: number: 80 - host: "{{ .Values.conf.appName }}.{{ .Release.Namespace }}.svc.cluster.local" + host: {{printf "%s.%s.svc.cluster.local" .Values.conf.appName .Release.Namespace | quote }} diff --git a/devops/gcp/deploy/values.yaml b/devops/gcp/deploy/values.yaml index 2058aecce5e87138a1d79d809c2aa92b3e659121..3820d40fdeb75b54e1bf124f886b538701e3ac31 100644 --- a/devops/gcp/deploy/values.yaml +++ b/devops/gcp/deploy/values.yaml @@ -3,6 +3,20 @@ # Declare variables to be passed into your templates. data: + #Configmap + logLevel: "ERROR" + springProfilesActive: "gcp" + googleCloudProject: "" + googleAudiences: "" + entitlementsHost: "http://entitlements" + partitionHost: "http://partition" + recordsChangedPubsubEndpoint: "" + storageHost: "http://storage" + serviceIdentity: "register-pubsub-identity" + keyRing: "csqp" + kmsKey: "registerService" + subscriberPrivateKeyId: "testkey" + # Deployment requestsCpu: "0.1" requestsMemory: "384M" limitsCpu: "1" @@ -20,6 +34,7 @@ conf: appName: "register" onPremEnabled: false domain: "" + cicdEnabled: false istio: proxyCPU: "50m"