From 27847751563969026c4e506705f6622c6b827498 Mon Sep 17 00:00:00 2001 From: santhosh-tg <93243580+santhosh-tg@users.noreply.github.com> Date: Thu, 7 Dec 2023 10:31:26 +0530 Subject: [PATCH] [ED-3293]Add VABots helmcharts (#3933) * Add VABots helmcharts * remove reduntant code * Add Jenkinsfile for VABots --- .../helm_charts/VABots/kathaasagar/Chart.yaml | 5 ++ .../kathaasagar/templates/configmap.yaml | 14 +++++ .../kathaasagar/templates/deployment.yaml | 60 +++++++++++++++++++ .../VABots/kathaasagar/templates/hpa.yaml | 31 ++++++++++ .../VABots/kathaasagar/values.yaml | 32 ++++++++++ kubernetes/pipelines/VABots/Jenkinsfile | 31 ++++++++++ 6 files changed, 173 insertions(+) create mode 100644 kubernetes/helm_charts/VABots/kathaasagar/Chart.yaml create mode 100644 kubernetes/helm_charts/VABots/kathaasagar/templates/configmap.yaml create mode 100644 kubernetes/helm_charts/VABots/kathaasagar/templates/deployment.yaml create mode 100644 kubernetes/helm_charts/VABots/kathaasagar/templates/hpa.yaml create mode 100644 kubernetes/helm_charts/VABots/kathaasagar/values.yaml create mode 100644 kubernetes/pipelines/VABots/Jenkinsfile diff --git a/kubernetes/helm_charts/VABots/kathaasagar/Chart.yaml b/kubernetes/helm_charts/VABots/kathaasagar/Chart.yaml new file mode 100644 index 0000000000..9a0796d952 --- /dev/null +++ b/kubernetes/helm_charts/VABots/kathaasagar/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: kathaasaagra +version: 0.1.0 diff --git a/kubernetes/helm_charts/VABots/kathaasagar/templates/configmap.yaml b/kubernetes/helm_charts/VABots/kathaasagar/templates/configmap.yaml new file mode 100644 index 0000000000..e0fd68e133 --- /dev/null +++ b/kubernetes/helm_charts/VABots/kathaasagar/templates/configmap.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Chart.Name }}-config +data: + GOOGLE_APPLICATION_CREDENTIALS: "{{ .Values.ks_gcp_credential_json_path }}" + BUCKET_NAME: "{{ .Values.ks_gcp_bucket_name }}" + DATABASE_NAME: "{{ .Values.ks_postgress_db_name }}" + DATABASE_USERNAME: "{{ .Values.ks_postgres_db_username }}" + DATABASE_PASSWORD: "{{ .Values.ks_postgres_db_password }}" + DATABASE_IP: "{{ .Values.ks_postgres_db_host }}" + DATABASE_PORT: "{{ .Values.ks_postgres_db_port }}" + OPENAI_API_KEY: "{{ .Values.ks_open_api_key }}" + diff --git a/kubernetes/helm_charts/VABots/kathaasagar/templates/deployment.yaml b/kubernetes/helm_charts/VABots/kathaasagar/templates/deployment.yaml new file mode 100644 index 0000000000..bbdff2d90f --- /dev/null +++ b/kubernetes/helm_charts/VABots/kathaasagar/templates/deployment.yaml @@ -0,0 +1,60 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + namespace: {{ .Values.namespace }} + annotations: + reloader.stakater.com/auto: "true" +spec: + replicas: {{ .Values.replicaCount }} + strategy: + rollingUpdate: + maxSurge: {{ .Values.strategy.maxsurge }} + maxUnavailable: {{ .Values.strategy.maxunavailable }} + selector: + matchLabels: + app: {{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Chart.Name }} + spec: +{{- if .Values.imagepullsecrets }} + imagePullSecrets: + - name: {{ .Values.imagepullsecrets }} +{{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.dockerhub }}/{{ .Values.repository }}:{{ .Values.image_tag }}" + imagePullPolicy: Always + envFrom: + - configMapRef: + name: {{ .Chart.Name }}-config + resources: +{{ toYaml .Values.resources | indent 10 }} + ports: + - containerPort: {{ .Values.network.port }} + # {{- if .Values.healthcheck }} + # livenessProbe: +#{{ toYaml .Values.livenessProbe | indent 10 }} + # readinessProbe: +#{{ toYaml .Values.readinessProbe | indent 10 }} + #{{- end }} + +--- + +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }}-service + namespace: {{ .Values.namespace }} + labels: + app: {{ .Chart.Name }} +spec: + ports: + - name: http-{{ .Chart.Name }} + protocol: TCP + port: {{ .Values.network.targetport }} + selector: + app: {{ .Chart.Name }} diff --git a/kubernetes/helm_charts/VABots/kathaasagar/templates/hpa.yaml b/kubernetes/helm_charts/VABots/kathaasagar/templates/hpa.yaml new file mode 100644 index 0000000000..450417d31f --- /dev/null +++ b/kubernetes/helm_charts/VABots/kathaasagar/templates/hpa.yaml @@ -0,0 +1,31 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Chart.Name }} + namespace: {{ .Values.namespace }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Chart.Name }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/kubernetes/helm_charts/VABots/kathaasagar/values.yaml b/kubernetes/helm_charts/VABots/kathaasagar/values.yaml new file mode 100644 index 0000000000..95b4ea9b46 --- /dev/null +++ b/kubernetes/helm_charts/VABots/kathaasagar/values.yaml @@ -0,0 +1,32 @@ +### Default variable file for kathaasaagra-service ### + +namespace: "" +imagepullsecrets: "" +dockerhub: "" + +replicaCount: 1 +repository: "" +image_tag: "" +resources: + requests: + cpu: 100m + memory: 100Mi + limits: + cpu: 1 + memory: 1024Mi +network: + port: 8000 + targetport: 8000 +strategy: + type: RollingUpdate + maxsurge: 25 + maxunavailable: 25 + +#{{ kathaasaagra_liveness_readiness | to_nice_yaml }} + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 2 + targetCPUUtilizationPercentage: 60 + targetMemoryUtilizationPercentage: "" diff --git a/kubernetes/pipelines/VABots/Jenkinsfile b/kubernetes/pipelines/VABots/Jenkinsfile new file mode 100644 index 0000000000..ac9f87041f --- /dev/null +++ b/kubernetes/pipelines/VABots/Jenkinsfile @@ -0,0 +1,31 @@ +pipeline { + agent any + + stages { + stage('Checkout helm chart') { + steps { + checkout scm + } + } + stage('checkout private repo') { + steps { + dir('private_repo') { + git branch: private_repo_branch, credentialsId: private_repo_credentials, url: private_repo_url + } + } + } + stage('Deploy') { + steps { + script { + jobName = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-1].trim().toLowerCase() + currentWs = sh(returnStdout: true, script: 'pwd').trim() + chart_path = "${currentWs}/kubernetes/helm_charts/VABots/$jobName" + values_file = "${currentWs}/private_repo/ansible/inventory/dev/VABots/${jobName}_values.yaml" + sh "helm upgrade --install $jobName $chart_path --namespace $vabots_namespace --kubeconfig $kubeconfig_path -f $values_file" + } + } + } + } + +} +