diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..308dfcf --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,282 @@ +version: 2.1 + +orbs: + snyk: snyk/snyk@1.4.0 + aws-cli: circleci/aws-cli@4.0.0 + aws-ecr: circleci/aws-ecr@8.2.1 + +_snyk_options: &snyk_options + project: "${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BRANCH}" + organization: "legal-aid-agency" + severity-threshold: "critical" + fail-on-issues: true + monitor-on-build: false + token-variable: SNYK_TOKEN + additional-arguments: --policy-path=.snyk + +# ------------------ +# EXECUTORS +# ------------------ +executors: + cloud-platform-executor: + resource_class: small + docker: + - image: ministryofjustice/cloud-platform-tools + working_directory: ~/laa-crime-application-tracking-service/crime-application-tracking + build-executor: + docker: + - image: cimg/openjdk:21.0.0 + working_directory: ~/laa-crime-application-tracking-service/crime-application-tracking + +# ------------------ +# COMMANDS +# ------------------ +commands: + deploy-to: + description: > + Deploy image to the specified environment + parameters: + environment: + description: Destination environment + type: string + token: + description: CircleCI Service account token + type: string + steps: + - checkout + - run: + name: Decrypt secrets + command: | + echo "${GIT_CRYPT_KEY}" | base64 -d > git-crypt.key + git-crypt unlock git-crypt.key + - run: + name: Authenticate with cluster + command: | + echo -n ${K8S_CLUSTER_CERT} | base64 -d > ./ca.crt + kubectl config set-cluster ${K8S_CLUSTER_NAME} --certificate-authority=./ca.crt --server=https://${K8S_CLUSTER_NAME} + kubectl config set-credentials circleci --token=<< parameters.token >> + kubectl config set-context ${K8S_CLUSTER_NAME} --cluster=${K8S_CLUSTER_NAME} --user=circleci --namespace=laa-crime-application-tracking-service-<< parameters.environment >> + kubectl config use-context ${K8S_CLUSTER_NAME} + kubectl --namespace=laa-crime-application-tracking-service-<< parameters.environment >> get pods + - run: + name: Upgrade helm chart + command: | + helm upgrade laa-crime-application-tracking-service ./helm_deploy/laa-crime-application-tracking-service/. \ + --install --wait \ + --namespace=laa-crime-application-tracking-service-<< parameters.environment >> \ + --values ./helm_deploy/laa-crime-application-tracking-service/values-<< parameters.environment >>.yaml \ + --set image.tag="${CIRCLE_SHA1}" + +# ------------------ +# JOBS +# ------------------ +jobs: + build_and_scan: + executor: build-executor + steps: + - checkout: + path: ~/laa-crime-application-tracking-service + - restore_cache: + key: v1-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }} + - restore_cache: + key: v1-gradle-cache-{{ checksum "build.gradle" }} + - run: + name: Build + command: ./gradlew clean build + - run: + name: Run SonarQube + command: ./gradlew sonarqube -Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.host.url=${SONARQUBE_URL} -Dsonar.organization=${SONAR_ORG} + - save_cache: + paths: + - ~/.gradle/wrapper + key: v1-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }} + - save_cache: + paths: + - ~/.gradle/caches + key: v1-gradle-cache-{{ checksum "build.gradle" }} + - persist_to_workspace: + root: . + paths: + - build + - store_test_results: + path: build/test-results/test + - store_artifacts: + path: build/test-results/test + - store_artifacts: + path: build/reports/jacoco/test/html + - store_artifacts: + path: build/libs + - snyk/scan: + <<: *snyk_options + + build_scan_and_push_image: + executor: build-executor + steps: + - checkout: + path: ~/laa-crime-application-tracking-service + - attach_workspace: + at: . + - setup_remote_docker: + docker_layer_caching: true + - aws-cli/setup: + role_arn: $ECR_ROLE_TO_ASSUME + region: $ECR_REGION + - run: | + aws ecr get-login-password --region $ECR_REGION | docker login --username AWS --password-stdin ${AWS_ECR_REGISTRY_ID}.dkr.ecr.${ECR_REGION}.amazonaws.com + - run: + name: Build docker image + command: | + docker build \ + --build-arg COMMIT_ID=${CIRCLE_SHA1} \ + --build-arg BUILD_TAG=${CIRCLE_SHA1} \ + --build-arg APP_BRANCH=${CIRCLE_BRANCH} \ + --build-arg BUILD_DATE=$(date +%Y-%m-%dT%H:%M:%S%z) \ + -t $AWS_ECR_ACCOUNT_URL/laa-crime-apps-team/laa-crime-application-tracking-service-dev:${CIRCLE_SHA1} . + - snyk/scan: + docker-image-name: "$AWS_ECR_ACCOUNT_URL/laa-crime-apps-team/laa-crime-application-tracking-service-dev:${CIRCLE_SHA1}" + <<: *snyk_options + - run: + name: Push to ECR + command: | + docker push "$AWS_ECR_ACCOUNT_URL/laa-crime-apps-team/laa-crime-application-tracking-service-dev:${CIRCLE_SHA1}" + + deploy-dev: + executor: cloud-platform-executor + steps: + - deploy-to: + environment: dev + token: ${CIRCLE_CI_TOKEN_DEV} + + deploy-test: + executor: cloud-platform-executor + steps: + - deploy-to: + environment: test + token: ${CIRCLE_CI_TOKEN_TEST} + + deploy-uat: + executor: cloud-platform-executor + steps: + - deploy-to: + environment: uat + token: ${CIRCLE_CI_TOKEN_UAT} + + deploy-staging: + executor: cloud-platform-executor + steps: + - deploy-to: + environment: staging + token: ${CIRCLE_CI_TOKEN_STAGING} + + deploy-prod: + executor: cloud-platform-executor + steps: + - deploy-to: + environment: prod + token: ${CIRCLE_CI_TOKEN_PROD} + +# ------------------ +# WORKFLOWS +# ------------------ +workflows: + version: 2 + + build-deploy-master: + jobs: + - build_and_scan: + filters: + branches: + only: + - main + + - build_scan_and_push_image: + requires: + - build_and_scan + + - deploy-dev: + requires: + - build_scan_and_push_image + + - hold_install_on_test: + type: approval + requires: + - build_scan_and_push_image + + - deploy-test: + requires: + - hold_install_on_test + + - hold_install_on_uat: + type: approval + requires: + - build_scan_and_push_image + + - deploy-uat: + requires: + - hold_install_on_uat + + - hold_install_on_staging: + type: approval + requires: + - build_scan_and_push_image + + - deploy-staging: + requires: + - hold_install_on_staging + + - hold_install_on_prod: + type: approval + requires: + - build_scan_and_push_image + + - deploy-prod: + requires: + - hold_install_on_prod + + build-deploy-branch: + jobs: + - build_and_scan: + filters: + branches: + ignore: + - main + + - build_scan_and_push_image: + requires: + - build_and_scan + + - hold_install_on_dev: + type: approval + requires: + - build_scan_and_push_image + + - deploy-dev: + requires: + - hold_install_on_dev + + - hold_install_on_test: + type: approval + requires: + - build_scan_and_push_image + + - deploy-test: + requires: + - hold_install_on_test + + - hold_install_on_uat: + type: approval + requires: + - build_scan_and_push_image + + - deploy-uat: + requires: + - hold_install_on_uat + + - hold_install_on_staging: + type: approval + requires: + - build_scan_and_push_image + + - deploy-staging: + requires: + - hold_install_on_staging diff --git a/helm_deploy/laa-crime-application-tracking-service/.helmignore b/helm_deploy/laa-crime-application-tracking-service/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/.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/helm_deploy/laa-crime-application-tracking-service/Chart.yaml b/helm_deploy/laa-crime-application-tracking-service/Chart.yaml new file mode 100644 index 0000000..84969dd --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: laa-crime-application-tracking-service +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +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.0.1 + +# 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. +# It is recommended to use it with quotes. +appVersion: "0.0.1" diff --git a/helm_deploy/laa-crime-application-tracking-service/templates/NOTES.txt b/helm_deploy/laa-crime-application-tracking-service/templates/NOTES.txt new file mode 100644 index 0000000..9fcb9db --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "laa-crime-application-tracking-service.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 --namespace {{ .Release.Namespace }} svc -w {{ include "laa-crime-application-tracking-service.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "laa-crime-application-tracking-service.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + 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 "laa-crime-application-tracking-service.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm_deploy/laa-crime-application-tracking-service/templates/_environment.tpl b/helm_deploy/laa-crime-application-tracking-service/templates/_environment.tpl new file mode 100644 index 0000000..afd55ef --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/_environment.tpl @@ -0,0 +1,15 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Environment variables for service containers +*/}} +{{- define "laa-crime-application-tracking-service.env-vars" }} +env: + - name: AWS_REGION + value: {{ .Values.aws_region }} + - name: SENTRY_DSN + value: {{ .Values.sentry.dsn }} + - name: SENTRY_ENV + value: {{ .Values.java.host_env }} + - name: SENTRY_SAMPLE_RATE + value: {{ .Values.sentry.sampleRate | quote }} +{{- end -}} diff --git a/helm_deploy/laa-crime-application-tracking-service/templates/_helpers.tpl b/helm_deploy/laa-crime-application-tracking-service/templates/_helpers.tpl new file mode 100644 index 0000000..1fd3950 --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "laa-crime-application-tracking-service.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 "laa-crime-application-tracking-service.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 "laa-crime-application-tracking-service.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "laa-crime-application-tracking-service.labels" -}} +helm.sh/chart: {{ include "laa-crime-application-tracking-service.chart" . }} +{{ include "laa-crime-application-tracking-service.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "laa-crime-application-tracking-service.selectorLabels" -}} +app.kubernetes.io/name: {{ include "laa-crime-application-tracking-service.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "laa-crime-application-tracking-service.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "laa-crime-application-tracking-service.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm_deploy/laa-crime-application-tracking-service/templates/deployment.yaml b/helm_deploy/laa-crime-application-tracking-service/templates/deployment.yaml new file mode 100644 index 0000000..28dac13 --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/deployment.yaml @@ -0,0 +1,83 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "laa-crime-application-tracking-service.fullname" . }} + labels: + {{- include "laa-crime-application-tracking-service.labels" . | nindent 4 }} +spec: +{{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} +{{- end }} + selector: + matchLabels: + {{- include "laa-crime-application-tracking-service.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "laa-crime-application-tracking-service.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "laa-crime-application-tracking-service.serviceAccountName" . }} + 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: {{ .Values.service.port }} + protocol: TCP + {{- if not (eq (toString .Values.actuator.port) "http") }} + - name: actuator + containerPort: {{ .Values.actuator.port }} + protocol: TCP + {{- end }} + livenessProbe: + httpGet: + path: {{ .Values.actuator.health.path }} + {{- if not (eq (toString .Values.actuator.port) "http") }} + port: actuator + {{- else }} + port: http + {{- end }} + initialDelaySeconds: {{ .Values.actuator.liveness.initialDelaySeconds }} + periodSeconds: {{ .Values.actuator.liveness.periodSeconds }} + timeoutSeconds: {{ .Values.actuator.liveness.timeoutSeconds }} + failureThreshold: {{ .Values.actuator.liveness.failureThreshold }} + readinessProbe: + httpGet: + path: {{ .Values.actuator.health.path }} + {{- if not (eq (toString .Values.actuator.port) "http") }} + port: actuator + {{- else }} + port: http + {{- end }} + initialDelaySeconds: {{ .Values.actuator.readiness.initialDelaySeconds }} + periodSeconds: {{ .Values.actuator.readiness.periodSeconds }} + timeoutSeconds: {{ .Values.actuator.readiness.timeoutSeconds }} + failureThreshold: {{ .Values.actuator.readiness.failureThreshold }} + {{ include "laa-crime-application-tracking-service.env-vars" . | nindent 10 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- 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/helm_deploy/laa-crime-application-tracking-service/templates/hpa.yaml b/helm_deploy/laa-crime-application-tracking-service/templates/hpa.yaml new file mode 100644 index 0000000..5d61be5 --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "laa-crime-application-tracking-service.fullname" . }} + labels: + {{- include "laa-crime-application-tracking-service.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "laa-crime-application-tracking-service.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/helm_deploy/laa-crime-application-tracking-service/templates/ingress.yaml b/helm_deploy/laa-crime-application-tracking-service/templates/ingress.yaml new file mode 100644 index 0000000..64862f4 --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/ingress.yaml @@ -0,0 +1,52 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "laa-crime-application-tracking-service.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else -}} +apiVersion: extensions/v1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "laa-crime-application-tracking-service.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ .Values.ingress.className }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + pathType: "Prefix" + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + - path: {{ $.Values.actuator.health.path }} + pathType: "Exact" + backend: + service: + name: {{ $fullName }} + port: + number: {{ $.Values.actuator.port }} + {{- end }} + {{- end }} + {{- end }} diff --git a/helm_deploy/laa-crime-application-tracking-service/templates/networkpolicy.yaml b/helm_deploy/laa-crime-application-tracking-service/templates/networkpolicy.yaml new file mode 100644 index 0000000..e204f8a --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/networkpolicy.yaml @@ -0,0 +1,19 @@ +{{- if .Values.actuator.metrics.enabled }} +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ include "laa-crime-application-tracking-service.fullname" . }}-monitoring + labels: + {{- include "laa-crime-application-tracking-service.labels" . | nindent 4 }} +spec: + podSelector: + matchLabels: + {{- include "laa-crime-application-tracking-service.selectorLabels" . | nindent 6 }} + policyTypes: + - Ingress + ingress: + - from: + - namespaceSelector: + matchLabels: + component: monitoring +{{- end }} \ No newline at end of file diff --git a/helm_deploy/laa-crime-application-tracking-service/templates/service.yaml b/helm_deploy/laa-crime-application-tracking-service/templates/service.yaml new file mode 100644 index 0000000..4c4f775 --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "laa-crime-application-tracking-service.fullname" . }} + labels: + {{- include "laa-crime-application-tracking-service.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + {{- if not (eq (toString .Values.actuator.port) "http") }} + - port: {{ .Values.actuator.port }} + targetPort: actuator + protocol: TCP + name: actuator + {{- end }} + selector: + {{- include "laa-crime-application-tracking-service.selectorLabels" . | nindent 4 }} diff --git a/helm_deploy/laa-crime-application-tracking-service/templates/serviceaccount.yaml b/helm_deploy/laa-crime-application-tracking-service/templates/serviceaccount.yaml new file mode 100644 index 0000000..3e88f99 --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "laa-crime-application-tracking-service.serviceAccountName" . }} + labels: + {{- include "laa-crime-application-tracking-service.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/helm_deploy/laa-crime-application-tracking-service/templates/servicemonitor.yaml b/helm_deploy/laa-crime-application-tracking-service/templates/servicemonitor.yaml new file mode 100644 index 0000000..42bd064 --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/servicemonitor.yaml @@ -0,0 +1,19 @@ +{{- if .Values.actuator.metrics.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "laa-crime-application-tracking-service.fullname" . }}-monitoring + namespace: {{ .Release.Namespace }} +spec: + selector: + matchLabels: + {{- include "laa-crime-application-tracking-service.selectorLabels" . | nindent 6 }} + endpoints: + {{- if not (eq (toString .Values.actuator.port) "http") }} + - port: actuator + {{- else }} + - port: http + {{- end }} + interval: {{ .Values.actuator.metrics.scrapeInterval }} + path: {{ .Values.actuator.metrics.path }} +{{- end }} \ No newline at end of file diff --git a/helm_deploy/laa-crime-application-tracking-service/templates/tests/test-connection.yaml b/helm_deploy/laa-crime-application-tracking-service/templates/tests/test-connection.yaml new file mode 100644 index 0000000..15ee99b --- /dev/null +++ b/helm_deploy/laa-crime-application-tracking-service/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "laa-crime-application-tracking-service.fullname" . }}-test-connection" + labels: + {{- include "laa-crime-application-tracking-service.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "laa-crime-application-tracking-service.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm_deploy/laa-crime-application-tracking-service/values-dev.yaml b/helm_deploy/laa-crime-application-tracking-service/values-dev.yaml new file mode 100644 index 0000000..5e441de Binary files /dev/null and b/helm_deploy/laa-crime-application-tracking-service/values-dev.yaml differ diff --git a/helm_deploy/laa-crime-application-tracking-service/values-prod.yaml b/helm_deploy/laa-crime-application-tracking-service/values-prod.yaml new file mode 100644 index 0000000..048c954 Binary files /dev/null and b/helm_deploy/laa-crime-application-tracking-service/values-prod.yaml differ diff --git a/helm_deploy/laa-crime-application-tracking-service/values-staging.yaml b/helm_deploy/laa-crime-application-tracking-service/values-staging.yaml new file mode 100644 index 0000000..49b256d Binary files /dev/null and b/helm_deploy/laa-crime-application-tracking-service/values-staging.yaml differ diff --git a/helm_deploy/laa-crime-application-tracking-service/values-test.yaml b/helm_deploy/laa-crime-application-tracking-service/values-test.yaml new file mode 100644 index 0000000..6ee444b Binary files /dev/null and b/helm_deploy/laa-crime-application-tracking-service/values-test.yaml differ diff --git a/helm_deploy/laa-crime-application-tracking-service/values-uat.yaml b/helm_deploy/laa-crime-application-tracking-service/values-uat.yaml new file mode 100644 index 0000000..fc94e46 Binary files /dev/null and b/helm_deploy/laa-crime-application-tracking-service/values-uat.yaml differ