diff --git a/devops/gcp/configmap/README.md b/devops/gcp/configmap/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9b04a30ea853da446cbdb088fdcc4c62b9ebe5fa --- /dev/null +++ b/devops/gcp/configmap/README.md @@ -0,0 +1,62 @@ +<!--- 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 + +### GCP variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**entitlementsHost** | entitlements service host address | string | `http://entitlements` | yes + +### Config variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| +**appName** | name of the app | string | unit | yes +**configmap** | configmap name | string | unit-config | yes + +### Install the helm chart + +Run this command from within this directory: + +```bash +helm install gcp-unit-configmap . +``` + +## Uninstalling the Chart + +To uninstall the helm deployment: + +```bash +helm uninstall gcp-unit-configmap +``` + +[Move-to-Top](#configmap-helm-chart) diff --git a/devops/gcp/configmap/templates/unit-variables.yml b/devops/gcp/configmap/templates/unit-variables.yml index 41bde0e805f17ad6e0e7ab2444700a36145fc919..278ca97665fa1925e765a92e43a6b7bc5398d5ab 100644 --- a/devops/gcp/configmap/templates/unit-variables.yml +++ b/devops/gcp/configmap/templates/unit-variables.yml @@ -2,9 +2,9 @@ apiVersion: v1 kind: ConfigMap metadata: labels: - app: "{{ .Values.conf.app_name }}" + app: "{{ .Values.conf.appName }}" name: "{{ .Values.conf.configmap }}" namespace: "{{ .Release.Namespace }}" data: - LOG_LEVEL: "{{ .Values.data.log_level }}" - ENTITLEMENT_URL: "{{ .Values.data.entitlement_url }}" + LOG_LEVEL: "{{ .Values.data.logLevel }}" + ENTITLEMENTS_HOST: "{{ .Values.data.entitlementsHost }}" diff --git a/devops/gcp/configmap/values.yaml b/devops/gcp/configmap/values.yaml index cb5c3b63d74c19f77d6769dd8253d0d1181c759b..d82948cbe5f48d53a27dec38e0bc3baf75bee65f 100644 --- a/devops/gcp/configmap/values.yaml +++ b/devops/gcp/configmap/values.yaml @@ -3,9 +3,9 @@ # Declare variables to be passed into your templates. data: - log_level: "INFO" - entitlement_url: "http://entitlements/api/entitlements/v2/" + logLevel: "INFO" + entitlementsHost: "http://entitlements" conf: + appName: "unit" configmap: "unit-config" - app_name: "unit" diff --git a/devops/gcp/deploy/README.md b/devops/gcp/deploy/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7d3ad345d4f5aa3b994747f6570d1a981544d65a --- /dev/null +++ b/devops/gcp/deploy/README.md @@ -0,0 +1,67 @@ +<!--- 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 + +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.1 | yes +**requestsMemory** | amount of requested memory| string | 256M | yes +**limitsCpu** | CPU limit | string | 1 | yes +**limitsMemory** | memory limit | string | 1G | yes +**serviceAccountName** | name of your service account | string | unit | yes +**imagePullPolicy** | when to pull image | string | IfNotPresent | yes +**image** | service image | string | - | yes + +### Config variables + +| Name | Description | Type | Default |Required | +|------|-------------|------|---------|---------| + +**appName** | name of the app | string | `unit` | yes +**configmap** | configmap to be used | string | `unit-config` | 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-unit-deploy . +``` + +## Uninstalling the Chart + +To uninstall the helm deployment: + +```console +helm uninstall gcp-unit-deploy +``` + +[Move-to-Top](#deploy-helm-chart) diff --git a/devops/gcp/deploy/templates/unit-deploy.yml b/devops/gcp/deploy/templates/unit-deploy.yml index ad733ffeffcae14ae6e095a7afeb436f379974cf..f93dc2efe09de60a222abc64a28a2c1bcb20f662 100644 --- a/devops/gcp/deploy/templates/unit-deploy.yml +++ b/devops/gcp/deploy/templates/unit-deploy.yml @@ -2,23 +2,23 @@ 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: 1 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: @@ -31,10 +31,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/unit-service.yml b/devops/gcp/deploy/templates/unit-service.yml index 7f88561aad2b46006251e90dc3758e3a7cd0fbc0..49dc28423f0f65a54b786d74eefec4a81f81ea60 100644 --- a/devops/gcp/deploy/templates/unit-service.yml +++ b/devops/gcp/deploy/templates/unit-service.yml @@ -1,15 +1,15 @@ apiVersion: v1 kind: Service metadata: - name: "{{ .Values.conf.app_name }}" + name: "{{ .Values.conf.appName }}" annotations: - {{- if not .Values.conf.on_prem_enabled }} + {{- if not .Values.conf.onPremEnabled }} cloud.google.com/neg: '{"ingress": true}' {{- end }} namespace: "{{ .Release.Namespace }}" labels: - app: "{{ .Values.conf.app_name }}" - service: "{{ .Values.conf.app_name }}" + app: "{{ .Values.conf.appName }}" + service: "{{ .Values.conf.appName }}" spec: ports: - protocol: TCP @@ -17,4 +17,4 @@ spec: targetPort: 8080 name: http selector: - app: "{{ .Values.conf.app_name }}" + app: "{{ .Values.conf.appName }}" diff --git a/devops/gcp/deploy/templates/unit-serviceaccount.yaml b/devops/gcp/deploy/templates/unit-serviceaccount.yaml index 3fede170cb014a4cfdf8cc99d745a32eb66aeed0..25fd74efbfca059f541af82d98b676cfcb930d64 100644 --- a/devops/gcp/deploy/templates/unit-serviceaccount.yaml +++ b/devops/gcp/deploy/templates/unit-serviceaccount.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/unit-virtual-service.yml b/devops/gcp/deploy/templates/unit-virtual-service.yml index 37e426b456ac4c1de938d016a95f167cac543fe3..63540a2d22abdfaf8742c70de25993f1c0054647 100644 --- a/devops/gcp/deploy/templates/unit-virtual-service.yml +++ b/devops/gcp/deploy/templates/unit-virtual-service.yml @@ -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 7bfd3756c3aa6017df8e55a2bd179ea3c924622f..fce74d3195045665974fc294a75e0588372f0bbe 100644 --- a/devops/gcp/deploy/values.yaml +++ b/devops/gcp/deploy/values.yaml @@ -3,16 +3,16 @@ # Declare variables to be passed into your templates. data: - requests_cpu: "0.1" - requests_memory: "256M" - limits_cpu: "1" - limits_memory: "1G" - serviceAccountName: "" + requestsCpu: "0.1" + requestsMemory: "256M" + limitsCpu: "1" + limitsMemory: "1G" + serviceAccountName: "unit" imagePullPolicy: "IfNotPresent" image: "" conf: + appName: "unit" configmap: "unit-config" - app_name: "unit" - on_prem_enabled: false + onPremEnabled: false domain: "" diff --git a/provider/unit-gcp/unit-gke/src/main/resources/application.properties b/provider/unit-gcp/unit-gke/src/main/resources/application.properties index 3f2fcbf565cbc1eada8f26fdf019f0c367380160..237a87e10a24acdd8a73db644fb7c8edc57caa0c 100644 --- a/provider/unit-gcp/unit-gke/src/main/resources/application.properties +++ b/provider/unit-gcp/unit-gke/src/main/resources/application.properties @@ -7,5 +7,9 @@ spring.main.allow-bean-definition-overriding=true osdu.entitlement.url=${ENTITLEMENT_URL} +ENTITLEMENTS_HOST=http://entitlements +ENTITLEMENTS_PATH=/api/entitlements/v2 +ENTITLEMENT_URL=${ENTITLEMENTS_HOST}${ENTITLEMENTS_PATH} + # [Optional] [AKS] [GKE] File location of the unit catalog -osdu.unit.catalog.filename=${UNIT_CATALOG_FILENAME:/mnt/unit_catalogs/unit_catalog_v2.json} \ No newline at end of file +osdu.unit.catalog.filename=${UNIT_CATALOG_FILENAME:/mnt/unit_catalogs/unit_catalog_v2.json}