From 4c1843669883fb66007a274aa08633ab1eba02a5 Mon Sep 17 00:00:00 2001 From: Tamas Molnar Date: Thu, 10 Aug 2017 14:36:06 +0300 Subject: [PATCH 1/2] Helm and Jenkins integration --- .gitignore | 2 +- Jenkinsfile | 3 + helm/content-rw-elasticsearch/.helmignore | 21 ++++++ helm/content-rw-elasticsearch/Chart.yaml | 4 ++ .../content-rw-elasticsearch_delivery.yaml | 7 ++ .../templates/_helpers.tpl | 16 +++++ .../templates/deployment.yaml | 65 +++++++++++++++++++ .../templates/service.yaml | 16 +++++ helm/content-rw-elasticsearch/values.yaml | 16 +++++ 9 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 Jenkinsfile create mode 100644 helm/content-rw-elasticsearch/.helmignore create mode 100644 helm/content-rw-elasticsearch/Chart.yaml create mode 100644 helm/content-rw-elasticsearch/app-configs/content-rw-elasticsearch_delivery.yaml create mode 100644 helm/content-rw-elasticsearch/templates/_helpers.tpl create mode 100644 helm/content-rw-elasticsearch/templates/deployment.yaml create mode 100644 helm/content-rw-elasticsearch/templates/service.yaml create mode 100644 helm/content-rw-elasticsearch/values.yaml diff --git a/.gitignore b/.gitignore index 9a8f7dc..d02fa12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.iml *.exe .idea -content-rw-elasticsearch +/content-rw-elasticsearch vendor/*/ \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..6b4ba77 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,3 @@ +@Library('k8s-pipeline-lib') _ + +entryPointForReleaseAndDev() diff --git a/helm/content-rw-elasticsearch/.helmignore b/helm/content-rw-elasticsearch/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/helm/content-rw-elasticsearch/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/helm/content-rw-elasticsearch/Chart.yaml b/helm/content-rw-elasticsearch/Chart.yaml new file mode 100644 index 0000000..5e77301 --- /dev/null +++ b/helm/content-rw-elasticsearch/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: content-rw-elasticsearch Helm chart for Kubernetes +name: content-rw-elasticsearch +version: 0.0.0 # this entry can be left untouched as it is automatically handled by Jenkins pipeline diff --git a/helm/content-rw-elasticsearch/app-configs/content-rw-elasticsearch_delivery.yaml b/helm/content-rw-elasticsearch/app-configs/content-rw-elasticsearch_delivery.yaml new file mode 100644 index 0000000..be430cf --- /dev/null +++ b/helm/content-rw-elasticsearch/app-configs/content-rw-elasticsearch_delivery.yaml @@ -0,0 +1,7 @@ +# Values used for the deployed application. +replicaCount: 2 +service: + name: content-rw-elasticsearch +env: + KAFKA_TOPIC: CombinedPostPublicationEvents + KAFKA_CONCURRENT_PROCESSING: true diff --git a/helm/content-rw-elasticsearch/templates/_helpers.tpl b/helm/content-rw-elasticsearch/templates/_helpers.tpl new file mode 100644 index 0000000..f7877c3 --- /dev/null +++ b/helm/content-rw-elasticsearch/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 24 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 24 | trimSuffix "-" -}} +{{- end -}} diff --git a/helm/content-rw-elasticsearch/templates/deployment.yaml b/helm/content-rw-elasticsearch/templates/deployment.yaml new file mode 100644 index 0000000..8c8e491 --- /dev/null +++ b/helm/content-rw-elasticsearch/templates/deployment.yaml @@ -0,0 +1,65 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Values.service.name }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + visualize: "true" + app: {{ .Values.service.name }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ .Values.service.name }} + template: + metadata: + labels: + app: {{ .Values.service.name }} + visualize: "true" + spec: + containers: + - name: {{ .Values.service.name }} + image: "{{ .Values.image.repository }}:{{ .Chart.Version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: ELASTICSEARCH_SAPI_ENDPOINT + valueFrom: + configMapKeyRef: + name: global-config + key: aws.content.elasticsearch.endpoint + - name: KAFKA_CONSUMER_GROUP + value: "k8s-{{ .Values.service.name }}" + - name: KAFKA_TOPIC + value: {{ .Values.env.KAFKA_TOPIC }} + - name: KAFKA_CONCURRENT_PROCESSING + value: "{{ .Values.env.KAFKA_CONCURRENT_PROCESSING }}" + - name: KAFKA_PROXY_ADDR + valueFrom: + configMapKeyRef: + name: global-config + key: kafka.proxy.url.with.protocol + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: global-secrets + key: aws.access_key_id + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: global-secrets + key: aws.secret_access_key + ports: + - containerPort: 8080 + livenessProbe: + tcpSocket: + port: 8080 + initialDelaySeconds: 10 + readinessProbe: + httpGet: + path: "/__gtg" + port: 8080 + initialDelaySeconds: 15 + periodSeconds: 30 + resources: +{{ toYaml .Values.resources | indent 12 }} + diff --git a/helm/content-rw-elasticsearch/templates/service.yaml b/helm/content-rw-elasticsearch/templates/service.yaml new file mode 100644 index 0000000..d5ed575 --- /dev/null +++ b/helm/content-rw-elasticsearch/templates/service.yaml @@ -0,0 +1,16 @@ +kind: Service +apiVersion: v1 +metadata: + name: {{.Values.service.name}} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + app: {{.Values.service.name}} + visualize: "true" + hasHealthcheck: "{{ .Values.service.hasHealthcheck }}" +spec: + ports: + - port: 8080 +# name: # The name of this port within the service. Optional if only one port is defined on this service + targetPort: 8080 + selector: + app: {{ .Values.service.name }} diff --git a/helm/content-rw-elasticsearch/values.yaml b/helm/content-rw-elasticsearch/values.yaml new file mode 100644 index 0000000..659c1a1 --- /dev/null +++ b/helm/content-rw-elasticsearch/values.yaml @@ -0,0 +1,16 @@ +# Default values for content-rw-elasticsearch. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +service: + name: "" # The name of the service, should be defined in the specific app-configs folder. + hasHealthcheck: "true" +replicaCount: 2 +image: + repository: coco/content-rw-elasticsearch + pullPolicy: IfNotPresent +resources: + limits: + memory: 256Mi +env: + KAFKA_TOPIC: "" + KAFKA_CONCURRENT_PROCESSING: "" From 0fcf331cf005f4e5046573245d3716a7b430f8a3 Mon Sep 17 00:00:00 2001 From: Sorin Buliarca Date: Thu, 17 Aug 2017 10:53:50 +0300 Subject: [PATCH 2/2] Renamed UPP entry point for Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6b4ba77..7f06238 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,3 @@ @Library('k8s-pipeline-lib') _ -entryPointForReleaseAndDev() +uppEntryPointForJenkinsfile()