From 350350301223de1fdc49174eccff08d84bb175d8 Mon Sep 17 00:00:00 2001 From: Chad Vaughn Date: Tue, 4 Mar 2025 13:20:02 -0600 Subject: [PATCH 1/5] MSP-72 Converted to dns-canary to helm chart --- charts/dns-canary/Chart.yaml | 6 +++ charts/dns-canary/README.md | 9 ++++ charts/dns-canary/templates/dns-canary.yaml | 56 +++++++++++++++++++++ charts/dns-canary/values.yaml | 10 ++++ 4 files changed, 81 insertions(+) create mode 100644 charts/dns-canary/Chart.yaml create mode 100644 charts/dns-canary/README.md create mode 100644 charts/dns-canary/templates/dns-canary.yaml create mode 100644 charts/dns-canary/values.yaml diff --git a/charts/dns-canary/Chart.yaml b/charts/dns-canary/Chart.yaml new file mode 100644 index 0000000..b172434 --- /dev/null +++ b/charts/dns-canary/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: dns-canary +description: A Helm chart to deploy DNS Canary CronJob for Kubernetes clusters +type: application +version: 1.0.0 +appVersion: 1.0.0 \ No newline at end of file diff --git a/charts/dns-canary/README.md b/charts/dns-canary/README.md new file mode 100644 index 0000000..e2d71ff --- /dev/null +++ b/charts/dns-canary/README.md @@ -0,0 +1,9 @@ +# DNS Canary Helm Chart + +This Helm chart deploys a DNS Canary CronJob to your Kubernetes cluster. +The canary continuously tests internal service discovery and optionally pushes logs to CloudWatch and sends alerts via SNS. + +## Installation Example + +```bash +helm install dns-canary ./dns-canary -f values.yaml \ No newline at end of file diff --git a/charts/dns-canary/templates/dns-canary.yaml b/charts/dns-canary/templates/dns-canary.yaml new file mode 100644 index 0000000..f7aef58 --- /dev/null +++ b/charts/dns-canary/templates/dns-canary.yaml @@ -0,0 +1,56 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ .Values.name }} + namespace: {{ .Values.namespace }} + labels: + app: {{ .Values.name }} +spec: + schedule: {{ .Values.schedule | quote }} + concurrencyPolicy: Allow + failedJobsHistoryLimit: 1 + successfulJobsHistoryLimit: 3 + suspend: false + jobTemplate: + spec: + backoffLimit: 6 + completions: 1 + parallelism: 1 + template: + metadata: + labels: + app: {{ .Values.name }} + spec: + restartPolicy: OnFailure + containers: + - name: dns-canary + image: amazon/aws-cli + imagePullPolicy: Always + command: + - /bin/sh + - -c + - | + set -e + TARGET="http://{{ .Values.targetService }}" + + if curl --max-time 3 -sSf $TARGET; then + echo "$(date) DNS Canary check passed for $TARGET" + else + echo "$(date) DNS Canary check failed for $TARGET" >&2 + + if [ -n "{{ .Values.cloudwatchLogGroup }}" ]; then + echo "Sending failure log to CloudWatch" + aws logs put-log-events \ + --log-group-name "{{ .Values.cloudwatchLogGroup }}" \ + --log-stream-name "dns-canary-{{ .Values.name }}" \ + --log-events "timestamp=$(date +%s%3N),message=\"DNS Canary failure: $TARGET\"" + fi + + if [ -n "{{ .Values.alertSnsTopicArn }}" ]; then + echo "Triggering SNS alert" + aws sns publish \ + --topic-arn "{{ .Values.alertSnsTopicArn }}" \ + --message "DNS Canary failure detected for $TARGET in cluster {{ .Values.clusterName }}" + fi + fi + resources: {} \ No newline at end of file diff --git a/charts/dns-canary/values.yaml b/charts/dns-canary/values.yaml new file mode 100644 index 0000000..047bf65 --- /dev/null +++ b/charts/dns-canary/values.yaml @@ -0,0 +1,10 @@ +name: dns-canary +namespace: kube-system + +schedule: "*/1 * * * *" + +targetService: "test-service.kube-system.svc.cluster.local" +clusterName: "dns-canary-test" + +cloudwatchLogGroup: "" +alertSnsTopicArn: "" \ No newline at end of file From 2784d073757a92911064738b3f49000161b76565 Mon Sep 17 00:00:00 2001 From: Chad Vaughn Date: Mon, 10 Mar 2025 14:23:42 -0500 Subject: [PATCH 2/5] MSP-72 Updated Helm chart with best practices --- charts/dns-canary/Chart.yaml | 6 - charts/dns-canary/values.yaml | 10 -- charts/dns_canary/Chart.yaml | 24 ++++ charts/{dns-canary => dns_canary}/README.md | 0 charts/dns_canary/templates/.DS_Store | Bin 0 -> 6148 bytes charts/dns_canary/templates/_helpers.tpl | 62 +++++++++ .../templates/cronjob.yaml} | 49 ++++++- .../dns_canary/templates/serviceaccount.yaml | 13 ++ charts/dns_canary/values.yaml | 123 ++++++++++++++++++ 9 files changed, 266 insertions(+), 21 deletions(-) delete mode 100644 charts/dns-canary/Chart.yaml delete mode 100644 charts/dns-canary/values.yaml create mode 100644 charts/dns_canary/Chart.yaml rename charts/{dns-canary => dns_canary}/README.md (100%) create mode 100644 charts/dns_canary/templates/.DS_Store create mode 100644 charts/dns_canary/templates/_helpers.tpl rename charts/{dns-canary/templates/dns-canary.yaml => dns_canary/templates/cronjob.yaml} (50%) create mode 100644 charts/dns_canary/templates/serviceaccount.yaml create mode 100644 charts/dns_canary/values.yaml diff --git a/charts/dns-canary/Chart.yaml b/charts/dns-canary/Chart.yaml deleted file mode 100644 index b172434..0000000 --- a/charts/dns-canary/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: dns-canary -description: A Helm chart to deploy DNS Canary CronJob for Kubernetes clusters -type: application -version: 1.0.0 -appVersion: 1.0.0 \ No newline at end of file diff --git a/charts/dns-canary/values.yaml b/charts/dns-canary/values.yaml deleted file mode 100644 index 047bf65..0000000 --- a/charts/dns-canary/values.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: dns-canary -namespace: kube-system - -schedule: "*/1 * * * *" - -targetService: "test-service.kube-system.svc.cluster.local" -clusterName: "dns-canary-test" - -cloudwatchLogGroup: "" -alertSnsTopicArn: "" \ No newline at end of file diff --git a/charts/dns_canary/Chart.yaml b/charts/dns_canary/Chart.yaml new file mode 100644 index 0000000..eb0c889 --- /dev/null +++ b/charts/dns_canary/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: dns-canary +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.1.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. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/dns-canary/README.md b/charts/dns_canary/README.md similarity index 100% rename from charts/dns-canary/README.md rename to charts/dns_canary/README.md diff --git a/charts/dns_canary/templates/.DS_Store b/charts/dns_canary/templates/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..002c614ae641c337c6a5e840b55c73e6a8f59a60 GIT binary patch literal 6148 zcmeHK%SyvQ6g@W59<-iyfx#)oT`omVKhQKBmYq!yG*);mm+_?hP{hOk=DkfQ4Oj5?^0lB81eL7=Jc^P+mf@eIkOu6eT4DnRsy)(8~ z;T>Vb(bzv(E5_&SVbR2v(=B$JbDeUWhSB78E53sV_CMxKbDm5+n>%MIA2r^bj2T|Y z&sb~VMdK~rF~_L#hGb`4>GHc(;)1=rRW#zGnJHijm;yhh0CTol`_QA6rhqA63ak~- z??X&iOahi3-KT?vy8;kfY<9-F{wgXb4wwWiJ@O4rJeBCF60R8H>1>ZfToSPK=;@Gf z`H(QOgd2*u(b<3O!Xb%AD@_4YU{irT|Jc?1f7yKh-z3?SDPRixD+Q!AxEb`hq>x){ wi_=^i)9>hN8drK;Q&@4Sn6a9QPw39r9&3e|1S~zWg=RkjP6jJXfnQbN3wj!MrT_o{ literal 0 HcmV?d00001 diff --git a/charts/dns_canary/templates/_helpers.tpl b/charts/dns_canary/templates/_helpers.tpl new file mode 100644 index 0000000..584e736 --- /dev/null +++ b/charts/dns_canary/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "dns-canary.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 "dns-canary.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 "dns-canary.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "dns-canary.labels" -}} +helm.sh/chart: {{ include "dns-canary.chart" . }} +{{ include "dns-canary.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "dns-canary.selectorLabels" -}} +app.kubernetes.io/name: {{ include "dns-canary.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "dns-canary.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "dns-canary.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/dns-canary/templates/dns-canary.yaml b/charts/dns_canary/templates/cronjob.yaml similarity index 50% rename from charts/dns-canary/templates/dns-canary.yaml rename to charts/dns_canary/templates/cronjob.yaml index f7aef58..52c0b28 100644 --- a/charts/dns-canary/templates/dns-canary.yaml +++ b/charts/dns_canary/templates/cronjob.yaml @@ -21,11 +21,19 @@ spec: labels: app: {{ .Values.name }} spec: - restartPolicy: OnFailure + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "dns-canary.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: - - name: dns-canary - image: amazon/aws-cli - imagePullPolicy: Always + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} command: - /bin/sh - -c @@ -53,4 +61,35 @@ spec: --message "DNS Canary failure detected for $TARGET in cluster {{ .Values.clusterName }}" fi fi - resources: {} \ No newline at end of file + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- 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 }} + resources: {} + diff --git a/charts/dns_canary/templates/serviceaccount.yaml b/charts/dns_canary/templates/serviceaccount.yaml new file mode 100644 index 0000000..4db724f --- /dev/null +++ b/charts/dns_canary/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "dns-canary.serviceAccountName" . }} + labels: + {{- include "dns-canary.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/dns_canary/values.yaml b/charts/dns_canary/values.yaml new file mode 100644 index 0000000..348fa13 --- /dev/null +++ b/charts/dns_canary/values.yaml @@ -0,0 +1,123 @@ +# Default values for dns-canary. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +replicaCount: 1 + +# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +image: + repository: nginx + # This sets the pull policy for images. + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +# This is for the secretes for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# This is to override the chart name. +nameOverride: "" +fullnameOverride: "" + +# This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: 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: "" + +# This is for setting Kubernetes Annotations to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} +# This is for setting Kubernetes Labels to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 80 + +# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} From 44db38e5836db65fb9feef554c1054a6c3f3a74b Mon Sep 17 00:00:00 2001 From: Chad Vaughn Date: Tue, 11 Mar 2025 12:04:28 -0500 Subject: [PATCH 3/5] MSP-72 Updated AWS CLI Image version --- charts/dns_canary/templates/cronjob.yaml | 38 +++++++++++------------- charts/dns_canary/values.yaml | 5 ++-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/charts/dns_canary/templates/cronjob.yaml b/charts/dns_canary/templates/cronjob.yaml index 52c0b28..7f92605 100644 --- a/charts/dns_canary/templates/cronjob.yaml +++ b/charts/dns_canary/templates/cronjob.yaml @@ -23,15 +23,15 @@ spec: spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: - {{- toYaml . | nindent 8 }} + {{- toYaml . | nindent 12 }} {{- end }} serviceAccountName: {{ include "dns-canary.serviceAccountName" . }} securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- toYaml .Values.podSecurityContext | nindent 12 }} containers: - name: {{ .Chart.Name }} securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} + {{- toYaml .Values.securityContext | nindent 16 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} command: @@ -46,19 +46,19 @@ spec: else echo "$(date) DNS Canary check failed for $TARGET" >&2 - if [ -n "{{ .Values.cloudwatchLogGroup }}" ]; then + if [ -n "{{`{{ .Values.cloudwatchLogGroup }}`}}" ]; then echo "Sending failure log to CloudWatch" aws logs put-log-events \ - --log-group-name "{{ .Values.cloudwatchLogGroup }}" \ - --log-stream-name "dns-canary-{{ .Values.name }}" \ + --log-group-name "{{`{{ .Values.cloudwatchLogGroup }}`}}" \ + --log-stream-name "dns-canary-{{`{{ .Values.name }}`}}" \ --log-events "timestamp=$(date +%s%3N),message=\"DNS Canary failure: $TARGET\"" fi - if [ -n "{{ .Values.alertSnsTopicArn }}" ]; then + if [ -n "{{`{{ .Values.alertSnsTopicArn }}`}}" ]; then echo "Triggering SNS alert" aws sns publish \ - --topic-arn "{{ .Values.alertSnsTopicArn }}" \ - --message "DNS Canary failure detected for $TARGET in cluster {{ .Values.clusterName }}" + --topic-arn "{{`{{ .Values.alertSnsTopicArn }}`}}" \ + --message "DNS Canary failure detected for $TARGET in cluster {{`{{ .Values.clusterName }}`}}" fi fi ports: @@ -66,30 +66,28 @@ spec: containerPort: {{ .Values.service.port }} protocol: TCP livenessProbe: - {{- toYaml .Values.livenessProbe | nindent 12 }} + {{- toYaml .Values.livenessProbe | nindent 16 }} readinessProbe: - {{- toYaml .Values.readinessProbe | nindent 12 }} + {{- toYaml .Values.readinessProbe | nindent 16 }} resources: - {{- toYaml .Values.resources | nindent 12 }} + {{- toYaml .Values.resources | nindent 16 }} {{- with .Values.volumeMounts }} volumeMounts: - {{- toYaml . | nindent 12 }} + {{- toYaml . | nindent 16 }} {{- end }} {{- with .Values.volumes }} volumes: - {{- toYaml . | nindent 8 }} + {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: - {{- toYaml . | nindent 8 }} + {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.affinity }} affinity: - {{- toYaml . | nindent 8 }} + {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.tolerations }} tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} - resources: {} - + {{- toYaml . | nindent 12 }} + {{- end }} \ No newline at end of file diff --git a/charts/dns_canary/values.yaml b/charts/dns_canary/values.yaml index 348fa13..1afc1c8 100644 --- a/charts/dns_canary/values.yaml +++ b/charts/dns_canary/values.yaml @@ -2,16 +2,17 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. +targetService: kubernetes.default.svc.cluster.local # This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ replicaCount: 1 # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ image: - repository: nginx + repository: amazon/aws-cli # This sets the pull policy for images. pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. - tag: "" + tag: "2.15.3" # This is for the secretes for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ imagePullSecrets: [] From 156fd4500781c816e1c896863f2fd75d445b5a38 Mon Sep 17 00:00:00 2001 From: Chad Vaughn Date: Wed, 12 Mar 2025 17:32:30 -0500 Subject: [PATCH 4/5] MSP-72 Renamed dns_canary to dns-canary and updated helm chart to use nslookup --- .gitignore | 1 + charts/{dns_canary => dns-canary}/Chart.yaml | 0 charts/{dns_canary => dns-canary}/README.md | 0 .../templates/_helpers.tpl | 0 .../templates/cronjob.yaml | 19 +++---- .../templates/serviceaccount.yaml | 0 charts/{dns_canary => dns-canary}/values.yaml | 50 +++--------------- charts/dns_canary/templates/.DS_Store | Bin 6148 -> 0 bytes 8 files changed, 14 insertions(+), 56 deletions(-) rename charts/{dns_canary => dns-canary}/Chart.yaml (100%) rename charts/{dns_canary => dns-canary}/README.md (100%) rename charts/{dns_canary => dns-canary}/templates/_helpers.tpl (100%) rename charts/{dns_canary => dns-canary}/templates/cronjob.yaml (85%) rename charts/{dns_canary => dns-canary}/templates/serviceaccount.yaml (100%) rename charts/{dns_canary => dns-canary}/values.yaml (63%) delete mode 100644 charts/dns_canary/templates/.DS_Store diff --git a/.gitignore b/.gitignore index 68354d5..ef1a88d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /charts/*/charts .idea test.yaml +.DS_Store \ No newline at end of file diff --git a/charts/dns_canary/Chart.yaml b/charts/dns-canary/Chart.yaml similarity index 100% rename from charts/dns_canary/Chart.yaml rename to charts/dns-canary/Chart.yaml diff --git a/charts/dns_canary/README.md b/charts/dns-canary/README.md similarity index 100% rename from charts/dns_canary/README.md rename to charts/dns-canary/README.md diff --git a/charts/dns_canary/templates/_helpers.tpl b/charts/dns-canary/templates/_helpers.tpl similarity index 100% rename from charts/dns_canary/templates/_helpers.tpl rename to charts/dns-canary/templates/_helpers.tpl diff --git a/charts/dns_canary/templates/cronjob.yaml b/charts/dns-canary/templates/cronjob.yaml similarity index 85% rename from charts/dns_canary/templates/cronjob.yaml rename to charts/dns-canary/templates/cronjob.yaml index 7f92605..2d2ba07 100644 --- a/charts/dns_canary/templates/cronjob.yaml +++ b/charts/dns-canary/templates/cronjob.yaml @@ -1,9 +1,9 @@ apiVersion: batch/v1 kind: CronJob metadata: - name: {{ .Values.name }} - namespace: {{ .Values.namespace }} + name: {{ include "dns-canary.fullname" . }} labels: + {{- include "dns-canary.labels" . | nindent 4 }} app: {{ .Values.name }} spec: schedule: {{ .Values.schedule | quote }} @@ -19,8 +19,10 @@ spec: template: metadata: labels: + {{- include "dns-canary.selectorLabels" . | nindent 12 }} app: {{ .Values.name }} spec: + restartPolicy: OnFailure {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 12 }} @@ -39,9 +41,10 @@ spec: - -c - | set -e - TARGET="http://{{ .Values.targetService }}" + TARGET="{{ .Values.targetService }}" + echo "$(date) Checking DNS resolution for $TARGET" - if curl --max-time 3 -sSf $TARGET; then + if nslookup $TARGET; then echo "$(date) DNS Canary check passed for $TARGET" else echo "$(date) DNS Canary check failed for $TARGET" >&2 @@ -61,14 +64,6 @@ spec: --message "DNS Canary failure detected for $TARGET in cluster {{`{{ .Values.clusterName }}`}}" fi fi - ports: - - name: http - containerPort: {{ .Values.service.port }} - protocol: TCP - livenessProbe: - {{- toYaml .Values.livenessProbe | nindent 16 }} - readinessProbe: - {{- toYaml .Values.readinessProbe | nindent 16 }} resources: {{- toYaml .Values.resources | nindent 16 }} {{- with .Values.volumeMounts }} diff --git a/charts/dns_canary/templates/serviceaccount.yaml b/charts/dns-canary/templates/serviceaccount.yaml similarity index 100% rename from charts/dns_canary/templates/serviceaccount.yaml rename to charts/dns-canary/templates/serviceaccount.yaml diff --git a/charts/dns_canary/values.yaml b/charts/dns-canary/values.yaml similarity index 63% rename from charts/dns_canary/values.yaml rename to charts/dns-canary/values.yaml index 1afc1c8..c7890df 100644 --- a/charts/dns_canary/values.yaml +++ b/charts/dns-canary/values.yaml @@ -3,16 +3,20 @@ # Declare variables to be passed into your templates. targetService: kubernetes.default.svc.cluster.local + +# Scheduled to run cronjob every 20 minutes. +schedule: "*/20 * * * *" + # This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ replicaCount: 1 # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ image: - repository: amazon/aws-cli + repository: busybox # This sets the pull policy for images. pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. - tag: "2.15.3" + tag: "1.37" # This is for the secretes for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ imagePullSecrets: [] @@ -50,30 +54,6 @@ securityContext: {} # runAsNonRoot: true # runAsUser: 1000 -# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ -service: - # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types - type: ClusterIP - # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports - port: 80 - -# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ -ingress: - enabled: false - className: "" - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: chart-example.local - paths: - - path: / - pathType: ImplementationSpecific - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little @@ -86,24 +66,6 @@ resources: {} # cpu: 100m # memory: 128Mi -# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ -livenessProbe: - httpGet: - path: / - port: http -readinessProbe: - httpGet: - path: / - port: http - -# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - # Additional volumes on the output Deployment definition. volumes: [] # - name: foo diff --git a/charts/dns_canary/templates/.DS_Store b/charts/dns_canary/templates/.DS_Store deleted file mode 100644 index 002c614ae641c337c6a5e840b55c73e6a8f59a60..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%SyvQ6g@W59<-iyfx#)oT`omVKhQKBmYq!yG*);mm+_?hP{hOk=DkfQ4Oj5?^0lB81eL7=Jc^P+mf@eIkOu6eT4DnRsy)(8~ z;T>Vb(bzv(E5_&SVbR2v(=B$JbDeUWhSB78E53sV_CMxKbDm5+n>%MIA2r^bj2T|Y z&sb~VMdK~rF~_L#hGb`4>GHc(;)1=rRW#zGnJHijm;yhh0CTol`_QA6rhqA63ak~- z??X&iOahi3-KT?vy8;kfY<9-F{wgXb4wwWiJ@O4rJeBCF60R8H>1>ZfToSPK=;@Gf z`H(QOgd2*u(b<3O!Xb%AD@_4YU{irT|Jc?1f7yKh-z3?SDPRixD+Q!AxEb`hq>x){ wi_=^i)9>hN8drK;Q&@4Sn6a9QPw39r9&3e|1S~zWg=RkjP6jJXfnQbN3wj!MrT_o{ From 76b38a3d1434f86fb1f67ab1d26f5e41033a912e Mon Sep 17 00:00:00 2001 From: Chad Vaughn Date: Fri, 14 Mar 2025 09:03:01 -0500 Subject: [PATCH 5/5] MSP-72 Updates to cronjob.yaml --- charts/dns-canary/templates/cronjob.yaml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/charts/dns-canary/templates/cronjob.yaml b/charts/dns-canary/templates/cronjob.yaml index 2d2ba07..be8b4a5 100644 --- a/charts/dns-canary/templates/cronjob.yaml +++ b/charts/dns-canary/templates/cronjob.yaml @@ -4,7 +4,6 @@ metadata: name: {{ include "dns-canary.fullname" . }} labels: {{- include "dns-canary.labels" . | nindent 4 }} - app: {{ .Values.name }} spec: schedule: {{ .Values.schedule | quote }} concurrencyPolicy: Allow @@ -20,7 +19,6 @@ spec: metadata: labels: {{- include "dns-canary.selectorLabels" . | nindent 12 }} - app: {{ .Values.name }} spec: restartPolicy: OnFailure {{- with .Values.imagePullSecrets }} @@ -47,22 +45,7 @@ spec: if nslookup $TARGET; then echo "$(date) DNS Canary check passed for $TARGET" else - echo "$(date) DNS Canary check failed for $TARGET" >&2 - - if [ -n "{{`{{ .Values.cloudwatchLogGroup }}`}}" ]; then - echo "Sending failure log to CloudWatch" - aws logs put-log-events \ - --log-group-name "{{`{{ .Values.cloudwatchLogGroup }}`}}" \ - --log-stream-name "dns-canary-{{`{{ .Values.name }}`}}" \ - --log-events "timestamp=$(date +%s%3N),message=\"DNS Canary failure: $TARGET\"" - fi - - if [ -n "{{`{{ .Values.alertSnsTopicArn }}`}}" ]; then - echo "Triggering SNS alert" - aws sns publish \ - --topic-arn "{{`{{ .Values.alertSnsTopicArn }}`}}" \ - --message "DNS Canary failure detected for $TARGET in cluster {{`{{ .Values.clusterName }}`}}" - fi + echo "[ERROR] $(date) DNS Canary check failed for $TARGET" >&2 fi resources: {{- toYaml .Values.resources | nindent 16 }}