From 8cf1d1781a1e757385c9349625408008b9f9b505 Mon Sep 17 00:00:00 2001 From: Matt Morrison Date: Wed, 27 Nov 2024 10:28:51 +1300 Subject: [PATCH] Add chart-testing workflow --- .github/workflows/chart-testing.yaml | 68 +++++++ charts/kafka/Chart.yaml | 4 +- charts/kafka/cloud-values.yaml | 278 --------------------------- 3 files changed, 70 insertions(+), 280 deletions(-) create mode 100644 .github/workflows/chart-testing.yaml delete mode 100644 charts/kafka/cloud-values.yaml diff --git a/.github/workflows/chart-testing.yaml b/.github/workflows/chart-testing.yaml new file mode 100644 index 0000000..c40406b --- /dev/null +++ b/.github/workflows/chart-testing.yaml @@ -0,0 +1,68 @@ +name: chart-workflow + +on: + workflow_call: + pull_request: + +jobs: + chart-testing: + runs-on: [self-hosted, cloud-infra-ci-runner-small] + container: + image: quay.io/helmpack/chart-testing:v3.11.0 + options: --user 1001 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run Helm Chart Testing + run: | + ct lint > ct-lint-output.txt + + - uses: mshick/add-pr-comment@v2 + with: + preformatted: true + message-id: "${{ github.event.number }}" + message-path: ct-lint-output.txt + + helm-unit-test: + runs-on: [self-hosted, cloud-infra-ci-runner-small] + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Helm + uses: azure/setup-helm@v4.0.0 + + - name: Install dependencies + run: | + helm plugin install https://github.com/helm-unittest/helm-unittest.git + + - name: Assemble list of chart directories to test + run: | + tr ' ' '\n' <<< "${{ inputs.charts }}" | grep -v '^$' > charts-to-test || true + find . -type f -name 'Chart.yaml' -exec dirname {} \; > all-charts + [ -z "${{ inputs.charts }}" ] && mv all-charts charts-to-test || true + shell: bash + + - name: Fetch chart dependencies + run: | + for chart in $(cat charts-to-test); do + helm dependency update "$chart" >/dev/null + done + shell: bash + + - name: Run Helm Unit Test + run: | + helm unittest $(cat charts-to-test) > helm-unittest-output.txt + + - uses: mshick/add-pr-comment@v2 + with: + preformatted: true + message-id: "${{ github.event.number }}" + message-path: helm-unittest-output.txt + + + diff --git a/charts/kafka/Chart.yaml b/charts/kafka/Chart.yaml index 9322550..fa92576 100644 --- a/charts/kafka/Chart.yaml +++ b/charts/kafka/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 -description: Setup a Kafka cluster +description: Setup a Kafka cluster using Strimzi operator name: kafka -version: 0.3.0 +version: 0.3.1 type: application dependencies: [] diff --git a/charts/kafka/cloud-values.yaml b/charts/kafka/cloud-values.yaml deleted file mode 100644 index 3a062ab..0000000 --- a/charts/kafka/cloud-values.yaml +++ /dev/null @@ -1,278 +0,0 @@ -strimzi: - spreadingEnabled: true - replicas: 3 - rackAware: false - logRetentionCheckInterval: 300000 - allowDeleteTopics: false - volumeSize: 20Gi - resources: - requests: - cpu: "1" - memory: "2Gi" - limits: - cpu: "1" - memory: "2Gi" - zookeeper: - replicas: 3 - volumeSize: 10Gi - resources: - requests: - cpu: 250m - memory: 2Gi - limits: - cpu: 250m - memory: 2Gi - entityTopicOperator: - resources: - requests: - cpu: 250m - memory: 500Mi - limits: - cpu: 250m - memory: 500Mi - entityUserOperator: - resources: - requests: - cpu: 250m - memory: 500Mi - limits: - cpu: 250m - memory: 500Mi - cruiseControl: - enabled: true - resources: - requests: - cpu: 250m - memory: 500Mi - limits: - cpu: 250m - memory: 500Mi - kafkaExporter: - enabled: true - resources: - requests: - cpu: 250m - memory: 500Mi - limits: - cpu: 250m - memory: 500Mi - -nodeSelector: - app.ditto.live/tier: "app" - -monitoring: - prometheusRules: - enabled: true - -# Network Policies, Ingress polices are built into strimzi charts, other network policies define the ingress in the template. -networkPolicies: - # This is an ugly hack because of https://github.com/getditto/cloud-infra/issues/107 - # to enable a graceful switch we make this available to be set to true - enableHack: true - - cruiseControl: - enabled: false - egress: - - to: - - podSelector: - matchLabels: - strimzi.io/cluster: '{{ include "kafka.fullname" . }}' - strimzi.io/kind: Kafka - strimzi.io/name: '{{ include "kafka.fullname" . }}-kafka' - ports: - # tcp-replication - - port: 9091 - # Access to DNS - - to: - - namespaceSelector: {} - podSelector: - matchLabels: - k8s-app: kube-dns - ports: - - port: 53 - protocol: UDP - - port: 53 - protocol: TCP - - to: - - namespaceSelector: {} - podSelector: - matchLabels: - k8s-app: node-local-dns - ports: - - port: 53 - protocol: UDP - - port: 53 - protocol: TCP - - kafka: - enabled: false - egress: - - to: - - podSelector: - matchLabels: - strimzi.io/cluster: '{{ include "kafka.fullname" . }}' - strimzi.io/kind: Kafka - strimzi.io/name: '{{ include "kafka.fullname" . }}-kafka' - ports: - # tcp-controlplane - - port: 9090 - # tcp-replication - - port: 9091 - - to: - - podSelector: - matchLabels: - strimzi.io/cluster: '{{ include "kafka.fullname" . }}' - strimzi.io/kind: Kafka - strimzi.io/name: '{{ include "kafka.fullname" . }}-zookeeper' - ports: - # tcp-clustering - - port: 2181 - # Access to DNS - - to: - - namespaceSelector: {} - podSelector: - matchLabels: - k8s-app: kube-dns - ports: - - port: 53 - protocol: UDP - - port: 53 - protocol: TCP - - to: - - namespaceSelector: {} - podSelector: - matchLabels: - k8s-app: node-local-dns - ports: - - port: 53 - protocol: UDP - - port: 53 - protocol: TCP - - zookeeper: - enabled: false - egress: - - to: - - podSelector: - matchLabels: - strimzi.io/cluster: '{{ include "kafka.fullname" . }}' - strimzi.io/kind: Kafka - strimzi.io/name: '{{ include "kafka.fullname" . }}-zookeeper' - ports: - # tcp-clustering - - port: 2888 - # tcp-leader-election - - port: 3888 - # tcp-clients - - port: 2181 - # Access to DNS - - to: - - namespaceSelector: {} - podSelector: - matchLabels: - k8s-app: kube-dns - ports: - - port: 53 - protocol: UDP - - port: 53 - protocol: TCP - - to: - - namespaceSelector: {} - podSelector: - matchLabels: - k8s-app: node-local-dns - ports: - - port: 53 - protocol: UDP - - port: 53 - protocol: TCP - - entityOperator: - enabled: false - kubeApiAccess: - enabled: true - # We include a CNI as some network interfaces have some gotchas around accessing the kube API - cni: "cilium" - # We include an option for setting egress so that we can use services like vcluster to access the kube API. - egress: - - toEntities: - - kube-apiserver - toPorts: - - ports: - - port: '443' - protocol: TCP - - egress: - - to: - - podSelector: - matchLabels: - strimzi.io/cluster: '{{ include "kafka.fullname" . }}' - strimzi.io/kind: Kafka - strimzi.io/name: '{{ include "kafka.fullname" . }}-kafka' - ports: - # tcp-replication - - port: 9091 - - to: - - podSelector: - matchLabels: - strimzi.io/cluster: '{{ include "kafka.fullname" . }}' - strimzi.io/kind: Kafka - strimzi.io/name: '{{ include "kafka.fullname" . }}-zookeeper' - ports: - # tcp-clients - - port: 2181 - # Access to DNS - - to: - - namespaceSelector: {} - podSelector: - matchLabels: - k8s-app: kube-dns - ports: - - port: 53 - protocol: UDP - - port: 53 - protocol: TCP - - to: - - namespaceSelector: {} - podSelector: - matchLabels: - k8s-app: node-local-dns - ports: - - port: 53 - protocol: UDP - - port: 53 - protocol: TCP - - kafkaExporter: - enabled: false - egress: - - to: - - podSelector: - matchLabels: - strimzi.io/cluster: '{{ include "kafka.fullname" . }}' - strimzi.io/kind: Kafka - strimzi.io/name: '{{ include "kafka.fullname" . }}-kafka' - ports: - # tcp-replication - - port: 9091 - # Access to DNS - - to: - - namespaceSelector: {} - podSelector: - matchLabels: - k8s-app: kube-dns - ports: - - port: 53 - protocol: UDP - - port: 53 - protocol: TCP - - to: - - namespaceSelector: {} - podSelector: - matchLabels: - k8s-app: node-local-dns - ports: - - port: 53 - protocol: UDP - - port: 53 - protocol: TCP