From 5489eb2a6924ef6180fa50ca141743ef5db1c904 Mon Sep 17 00:00:00 2001 From: Fabio Rauber Date: Tue, 13 Oct 2020 16:25:07 -0300 Subject: [PATCH] First version of SAPL chart --- charts/sapl/.helmignore | 23 ++++ charts/sapl/v0.2.0/Chart.yaml | 24 ++++ charts/sapl/v0.2.0/templates/NOTES.txt | 19 +++ charts/sapl/v0.2.0/templates/_helpers.tpl | 58 +++++++++ charts/sapl/v0.2.0/templates/deployment.yaml | 121 +++++++++++++++++++ charts/sapl/v0.2.0/templates/hpa.yaml | 28 +++++ charts/sapl/v0.2.0/templates/ingress.yaml | 39 ++++++ charts/sapl/v0.2.0/templates/pvc-data.yaml | 19 +++ charts/sapl/v0.2.0/templates/pvc-media.yaml | 19 +++ charts/sapl/v0.2.0/templates/service.yaml | 15 +++ charts/sapl/v0.2.0/values.yaml | 117 ++++++++++++++++++ 11 files changed, 482 insertions(+) create mode 100644 charts/sapl/.helmignore create mode 100644 charts/sapl/v0.2.0/Chart.yaml create mode 100644 charts/sapl/v0.2.0/templates/NOTES.txt create mode 100644 charts/sapl/v0.2.0/templates/_helpers.tpl create mode 100644 charts/sapl/v0.2.0/templates/deployment.yaml create mode 100644 charts/sapl/v0.2.0/templates/hpa.yaml create mode 100644 charts/sapl/v0.2.0/templates/ingress.yaml create mode 100644 charts/sapl/v0.2.0/templates/pvc-data.yaml create mode 100644 charts/sapl/v0.2.0/templates/pvc-media.yaml create mode 100644 charts/sapl/v0.2.0/templates/service.yaml create mode 100644 charts/sapl/v0.2.0/values.yaml diff --git a/charts/sapl/.helmignore b/charts/sapl/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/sapl/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/sapl/v0.2.0/Chart.yaml b/charts/sapl/v0.2.0/Chart.yaml new file mode 100644 index 0000000..2bc75ec --- /dev/null +++ b/charts/sapl/v0.2.0/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: sapl +description: Sistema de Apoio ao Processo Legislativo (SAPL) + +# A chart can be either an 'application' or a 'library' chart. +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.2.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. +appVersion: 3.1.161 + +icon: https://git.interlegis.leg.br/SEIT/rancher-charts/raw/master/images/sapl.png + +dependencies: +- name: postgresql + version: 9.8.4 + repository: https://charts.bitnami.com/bitnami + condition: postgresql.internal diff --git a/charts/sapl/v0.2.0/templates/NOTES.txt b/charts/sapl/v0.2.0/templates/NOTES.txt new file mode 100644 index 0000000..883e2e5 --- /dev/null +++ b/charts/sapl/v0.2.0/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "sapl.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ include "sapl.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "sapl.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "sapl.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/sapl/v0.2.0/templates/_helpers.tpl b/charts/sapl/v0.2.0/templates/_helpers.tpl new file mode 100644 index 0000000..79bd5ae --- /dev/null +++ b/charts/sapl/v0.2.0/templates/_helpers.tpl @@ -0,0 +1,58 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "sapl.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "sapl.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "sapl.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "sapl.labels" -}} +helm.sh/chart: {{ include "sapl.chart" . }} +{{ include "sapl.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "sapl.selectorLabels" -}} +app.kubernetes.io/name: {{ include "sapl.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create a default fully qualified app name for postgresql. +*/}} +{{- define "postgresql.fullname" -}} +{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/charts/sapl/v0.2.0/templates/deployment.yaml b/charts/sapl/v0.2.0/templates/deployment.yaml new file mode 100644 index 0000000..46864cc --- /dev/null +++ b/charts/sapl/v0.2.0/templates/deployment.yaml @@ -0,0 +1,121 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "sapl.fullname" . }} + labels: + {{- include "sapl.labels" . | nindent 4 }} +spec: +{{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} +{{- end }} + selector: + matchLabels: + {{- include "sapl.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "sapl.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + env: + - name: DATABASE_URL + value: {{ printf "postgresql://%s:%s@%s:5432/%s" .Values.postgresql.postgresqlUsername .Values.postgresql.postgresqlPassword (include "postgresql.fullname" .) .Values.postgresql.postgresqlDatabase| quote }} + - name: ADMIN_PASSWORD + value: "{{ .Values.sapl.adminPassword }}" + - name: ADMIN_EMAIL + value: "{{ .Values.sapl.adminEmail }}" + - name: EMAIL_SEND_USER + value: "{{ .Values.sapl.emailSendUser }}" + - name: DEBUG + value: "{{ .Values.sapl.debug }}" + - name: USE_TLS + value: "{{ .Values.sapl.useTls }}" + - name: EMAIL_PORT + value: "{{ .Values.sapl.emailPort }}" + - name: EMAIL_HOST + value: "{{ .Values.sapl.emailHost }}" + - name: TZ + value: "{{ .Values.sapl.timeZone }}" + - name: USE_SOLR + value: "{{ .Values.sapl.useSolr }}" + - name: SOLR_COLLECTION + value: "{{ .Values.sapl.solrCollection }}" + - name: SOLR_URL + value: "{{ .Values.sapl.solrUrl }}" + - name: NUM_SHARDS + value: "{{ .Values.sapl.solrNumShards }}" + - name: RF + value: "{{ .Values.sapl.solrReplFactor }}" + - name: MAX_SHARDS_PER_NODE + value: "{{ .Values.sapl.solrMaxShardsPerNode }}" + volumeMounts: + - mountPath: /var/interlegis/sapl/data + name: data + - mountPath: /var/interlegis/sapl/media + name: media + livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 60 + failureThreshold: 3 + periodSeconds: 60 + successThreshold: 1 + timeoutSeconds: 5 + readinessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 60 + failureThreshold: 3 + periodSeconds: 30 + successThreshold: 1 + timeoutSeconds: 5 + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumes: + - name: data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: data + {{- else }} + emptyDir: {} + {{- end }} + - name: media + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: media + {{- else }} + emptyDir: {} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/sapl/v0.2.0/templates/hpa.yaml b/charts/sapl/v0.2.0/templates/hpa.yaml new file mode 100644 index 0000000..d940dcd --- /dev/null +++ b/charts/sapl/v0.2.0/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "sapl.fullname" . }} + labels: + {{- include "sapl.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "sapl.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/sapl/v0.2.0/templates/ingress.yaml b/charts/sapl/v0.2.0/templates/ingress.yaml new file mode 100644 index 0000000..6ac1cbd --- /dev/null +++ b/charts/sapl/v0.2.0/templates/ingress.yaml @@ -0,0 +1,39 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "sapl.fullname" . -}} +{{- $ingressPath := .Values.ingress.path -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "sapl.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . | quote }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} + {{- end }} diff --git a/charts/sapl/v0.2.0/templates/pvc-data.yaml b/charts/sapl/v0.2.0/templates/pvc-data.yaml new file mode 100644 index 0000000..b1e7306 --- /dev/null +++ b/charts/sapl/v0.2.0/templates/pvc-data.yaml @@ -0,0 +1,19 @@ +{{- if .Values.persistence.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: data +spec: + accessModes: + - {{ .Values.persistence.accessMode }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/sapl/v0.2.0/templates/pvc-media.yaml b/charts/sapl/v0.2.0/templates/pvc-media.yaml new file mode 100644 index 0000000..b8d8a70 --- /dev/null +++ b/charts/sapl/v0.2.0/templates/pvc-media.yaml @@ -0,0 +1,19 @@ +{{- if .Values.persistence.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: media +spec: + accessModes: + - {{ .Values.persistence.accessMode }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/sapl/v0.2.0/templates/service.yaml b/charts/sapl/v0.2.0/templates/service.yaml new file mode 100644 index 0000000..a74ceca --- /dev/null +++ b/charts/sapl/v0.2.0/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "sapl.fullname" . }} + labels: + {{- include "sapl.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "sapl.selectorLabels" . | nindent 4 }} diff --git a/charts/sapl/v0.2.0/values.yaml b/charts/sapl/v0.2.0/values.yaml new file mode 100644 index 0000000..f9e7de6 --- /dev/null +++ b/charts/sapl/v0.2.0/values.yaml @@ -0,0 +1,117 @@ +# Default values for sapl. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: interlegis/sapl + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +persistence: + enabled: true + #storageClass: "" + accessMode: ReadWriteOnce + size: 500Mi + +sapl: + adminPassword: altereme + adminEmail: contato@tecnico.net + emailSendUser: no-reply@domain.net + debug: 'False' + useTls: 'False' + emailPort: 25 + emailHost: smtp.domain.net + timeZone: 'America/Sao_Paulo' + useSolr: 'True' + solrCollection: 'sapl' + solrUrl: 'http://localhost:8983' + solrNumShards: 1 + solrReplFactor: 2 + solrMaxShardsPerNode: 1 + +ingress: + enabled: true + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: / + hosts: + - chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +postgresql: + internal: true + image: + tag: 9.6.12-r66 + pullPolicy: IfNotPresent + service: + type: ClusterIP + port: 5432 + persistence: + enabled: true + size: 10Gi + postgresqlPassword: altereme + postgresqlUsername: sapl + postgresqlDatabase: sapl + resources: + requests: + cpu: 50m + memory: 64Mi + + +resources: + # limits: + # cpu: 100m + # memory: 128Mi + requests: + cpu: 100m + memory: 330Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}