Skip to content
Snippets Groups Projects
Commit 5af50ff7 authored by Danylo Vanin (EPAM)'s avatar Danylo Vanin (EPAM) Committed by Oleksandr Kosse (EPAM)
Browse files

[GONRG-5111] Refactor Helm

parent 33342fb8
No related branches found
No related tags found
2 merge requests!232Update os-core-lib-azure,!225[GONRG-5111] Refactor Helm
<!--- 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
This Helm chart should be installed before [deploy Helm Chart](../deploy)
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
### GCP variables
| Name | Description | Type | Default |Required |
|------|-------------|------|---------|---------|
**entitlementsHost** | entitlements service host address | string | `http://entitlements` | yes
**registerHost** | register service host address | string | `http://register` | yes
**partitionHost** | partition service host address | string | `http://partition` | 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 |
|------|-------------|------|---------|---------|
**configmap** | configmap name | string | notification-config | yes
**appName** | name of the app | string | notification | 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-notification-configmap .
```
## Uninstalling the Chart
To uninstall the helm deployment:
```bash
helm uninstall gcp-notification-configmap
```
[Move-to-Top](#configmap-helm-chart)
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 }}"
ENTITLEMENTS_HOST: "{{ .Values.data.entitlementsHost }}"
REGISTER_HOST: "{{ .Values.data.registerHost }}"
PARTITION_HOST: "{{ .Values.data.partitionHost }}"
{{- if not $.Values.conf.onPremEnabled }}
GOOGLE_AUDIENCES: "{{ .Values.data.googleAudiences }}"
{{- end }}
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: "{{ .Values.conf.app_name }}"
name: "{{ .Values.conf.configmap }}"
namespace: "{{ .Release.Namespace }}"
data:
LOG_LEVEL: "{{ .Values.data.log_level }}"
SPRING_PROFILES_ACTIVE: "{{ .Values.data.spring_profiles_active }}"
APP_ENTITLEMENTS: "{{ .Values.data.app_entitlements }}"
APP_REGISTER: "{{ .Values.data.app_register }}"
PARTITION_API: "{{ .Values.data.partition_api }}"
{{- if not .Values.conf.on_prem_enabled }}
GOOGLE_AUDIENCES: "{{ .Values.data.google_audiences }}"
{{- end }}
data: data:
# common # common
log_level: "INFO" logLevel: "INFO"
spring_profiles_active: "gcp" springProfilesActive: "gcp"
app_entitlements: "http://entitlements/api/entitlements/v2/" entitlementsHost: "http://entitlements"
app_register: "http://register/api/register/v1" registerHost: "http://register"
partition_api: "http://partition/api/partition/v1/" partitionHost: "http://partition"
# gcp # gcp
google_audiences: "" googleAudiences: ""
conf: conf:
configmap: "notification-config" configmap: "notification-config"
app_name: "notification" appName: "notification"
on_prem_enabled: false onPremEnabled: false
<!--- 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 |
|------|-------------|------|---------|---------|
**image** | your image name | string | - | yes
**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 | notification | yes
**imagePullPolicy** | when to pull image | string | IfNotPresent | yes
**image** | service image | string | - | yes
### Config variables
| Name | Description | Type | Default |Required |
|------|-------------|------|---------|---------|
**domain** | your domain | string | - | yes
**appName** | name of the app | string | `notification` | yes
**configmap** | configmap to be used | string | `notification-config` | yes
**onPremEnabled** | whether on-prem is enabled | boolean | false | yes
**rabbitmqSecretName** | secret for rabbitmq | string | `rabbitmq-secret` | yes
**openidSecretName** | secret for openid client | string | `notification-keycloak-secret` | yes
### Install the helm chart
Run this command from within this directory:
```console
helm install gcp-notification-deploy .
```
## Uninstalling the Chart
To uninstall the helm deployment:
```console
helm uninstall gcp-notification-deploy
```
[Move-to-Top](#deploy-helm-chart)
...@@ -2,33 +2,33 @@ apiVersion: apps/v1 ...@@ -2,33 +2,33 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
labels: labels:
app: "{{ .Values.conf.app_name }}" app: "{{ .Values.conf.appName }}"
name: "{{ .Values.conf.app_name }}" name: "{{ .Values.conf.appName }}"
namespace: "{{ .Release.Namespace }}" namespace: "{{ .Release.Namespace }}"
spec: spec:
selector: selector:
matchLabels: matchLabels:
app: "{{ .Values.conf.app_name }}" app: "{{ .Values.conf.appName }}"
replicas: 1 replicas: 1
template: template:
metadata: metadata:
labels: labels:
app: "{{ .Values.conf.app_name }}" app: "{{ .Values.conf.appName }}"
annotations: annotations:
rollme: {{ randAlphaNum 5 | quote }} rollme: {{ randAlphaNum 5 | quote }}
spec: spec:
containers: containers:
- name: "{{ .Values.conf.app_name }}" - name: "{{ .Values.conf.appName }}"
image: "{{ .Values.data.image }}" image: "{{ .Values.data.image }}"
imagePullPolicy: "{{ .Values.data.imagePullPolicy }}" imagePullPolicy: "{{ .Values.data.imagePullPolicy }}"
envFrom: envFrom:
- configMapRef: - configMapRef:
name: "{{ .Values.conf.configmap }}" name: "{{ .Values.conf.configmap }}"
{{- if .Values.conf.on_prem_enabled }} {{- if .Values.conf.onPremEnabled }}
- secretRef: - secretRef:
name: "{{ .Values.conf.rabbitmq_secret_name }}" name: "{{ .Values.conf.rabbitmqSecretName }}"
- secretRef: - secretRef:
name: "{{ .Values.conf.openid_secret_name }}" name: "{{ .Values.conf.openidSecretName }}"
{{- end }} {{- end }}
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
...@@ -37,9 +37,9 @@ spec: ...@@ -37,9 +37,9 @@ spec:
- containerPort: 8080 - containerPort: 8080
resources: resources:
requests: requests:
cpu: "{{ .Values.data.requests_cpu }}" cpu: "{{ .Values.data.requestsCpu }}"
memory: "{{ .Values.data.requests_memory }}" memory: "{{ .Values.data.requestsMemory }}"
limits: limits:
cpu: "{{ .Values.data.limits_cpu }}" cpu: "{{ .Values.data.limitsCpu }}"
memory: "{{ .Values.data.limits_memory }}" memory: "{{ .Values.data.limitsMemory }}"
serviceAccountName: "{{ .Values.data.serviceAccountName }}" serviceAccountName: "{{ .Values.data.serviceAccountName }}"
{{- if .Values.conf.on_prem_enabled }} {{- if .Values.conf.onPremEnabled }}
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
......
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: "{{ .Values.conf.app_name }}" name: "{{ .Values.conf.appName }}"
annotations: annotations:
{{- if not .Values.conf.on_prem_enabled }} {{- if not .Values.conf.onPremEnabled }}
cloud.google.com/neg: '{"ingress": true}' cloud.google.com/neg: '{"ingress": true}'
{{- end }} {{- end }}
namespace: "{{ .Release.Namespace }}" namespace: "{{ .Release.Namespace }}"
labels: labels:
app: "{{ .Values.conf.app_name }}" app: "{{ .Values.conf.appName }}"
service: "{{ .Values.conf.app_name }}" service: "{{ .Values.conf.appName }}"
spec: spec:
ports: ports:
- protocol: TCP - protocol: TCP
...@@ -17,4 +17,4 @@ spec: ...@@ -17,4 +17,4 @@ spec:
targetPort: 8080 targetPort: 8080
name: http name: http
selector: selector:
app: "{{ .Values.conf.app_name }}" app: "{{ .Values.conf.appName }}"
apiVersion: networking.istio.io/v1alpha3 apiVersion: networking.istio.io/v1alpha3
kind: VirtualService kind: VirtualService
metadata: metadata:
name: "{{ .Values.conf.app_name }}" name: "{{ .Values.conf.appName }}"
namespace: "{{ .Release.Namespace }}" namespace: "{{ .Release.Namespace }}"
spec: spec:
hosts: hosts:
{{- if .Values.conf.domain }} {{- if and .Values.conf.domain .Values.conf.onPremEnabled }}
- {{ printf "osdu.%s" .Values.conf.domain | quote }} - {{ printf "osdu.%s" .Values.conf.domain | quote }}
{{- else if .Values.conf.domain }}
- {{ .Values.conf.domain | quote }}
{{- else }} {{- else }}
- "*" - "*"
{{- end }} {{- end }}
...@@ -20,4 +22,4 @@ spec: ...@@ -20,4 +22,4 @@ spec:
- destination: - destination:
port: port:
number: 80 number: 80
host: "{{ .Values.conf.app_name }}.{{ .Release.Namespace }}.svc.cluster.local" host: "{{ .Values.conf.appName }}.{{ .Release.Namespace }}.svc.cluster.local"
data: data:
requests_cpu: "0.1" requestsCpu: "0.1"
requests_memory: "256M" requestsMemory: "256M"
limits_cpu: "1" limitsCpu: "1"
limits_memory: "1.5G" limitsMemory: "1.5G"
serviceAccountName: "notification" serviceAccountName: "notification"
imagePullPolicy: "IfNotPresent" imagePullPolicy: "IfNotPresent"
image: "" image: ""
conf: conf:
configmap: "notification-config" configmap: "notification-config"
app_name: "notification" appName: "notification"
rabbitmq_secret_name: "rabbitmq-secret" rabbitmqSecretName: "rabbitmq-secret"
openid_secret_name: "notification-keycloak-secret" openidSecretName: "notification-keycloak-secret"
on_prem_enabled: false onPremEnabled: false
domain: "" domain: ""
...@@ -24,11 +24,20 @@ app.maxCacheSize=10 ...@@ -24,11 +24,20 @@ app.maxCacheSize=10
server.error.whitelabel.enabled=false server.error.whitelabel.enabled=false
# External services # External services
app.entitlements=http://entitlements/api/entitlements/v2/ ENTITLEMENTS_PATH=/api/entitlements/v2/
app.register=http://register/api/register/v1 ENTITLEMENTS_HOST=http://entitlements
partition.api=http://partition/api/partition/v1/ app.entitlements=${ENTITLEMENTS_HOST}${ENTITLEMENTS_PATH}
REGISTER_PATH=/api/register/v1
REGISTER_HOST=http://register
app.register=${REGISTER_HOST}${REGISTER_PATH}
PARTITION_PATH=/api/partition/v1/
PARTITION_HOST=http://partition
PARTITION_API=${PARTITION_HOST}${PARTITION_PATH}
partition.api=${PARTITION_API}
# No profile defaults # No profile defaults
service.token.provider=GCP service.token.provider=GCP
partition-auth-enabled=true partition-auth-enabled=true
oqmDriver=pubsub oqmDriver=pubsub
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment