Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart: Improve CI. #12003

Merged
merged 26 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0283711
CI: Rename `helm` to `chart`.
Gacko Sep 26, 2024
8fa7160
CI: Rework conditions.
Gacko Sep 26, 2024
0277341
CI: Rework Python.
Gacko Jun 14, 2024
9eb6dc9
CI: Rework Helm.
Gacko Sep 25, 2024
b2e46aa
CI: Rework chart linting.
Gacko Feb 4, 2024
6980e56
CI: Rework docs generation.
Gacko Jan 29, 2024
b80998d
CI: Rework unit testing.
Gacko Feb 4, 2024
222f201
CI: Rework Git.
Gacko Sep 26, 2024
2021539
CI: Rework code checkout.
Gacko Sep 25, 2024
7c249e7
CI: Rework chart release.
Gacko Sep 25, 2024
de76f75
CI: Rework cache loading.
Gacko Feb 4, 2024
77e564d
CI: Rework cluster creation.
Gacko Sep 25, 2024
96a2440
CI: Rework Cert Manager.
Gacko Jan 29, 2024
2b5db6c
CI: Rework chart testing.
Gacko Jan 29, 2024
5c44423
Chart: Rework Controller Deployment/DaemonSet values.
Gacko Sep 27, 2024
b40fae9
Chart: Rework Controller Deployment/DaemonSet Pod Annotations values.
Gacko Sep 27, 2024
db5f293
Chart: Rework Controller Deployment/DaemonSet Metrics values.
Gacko Sep 27, 2024
d615e05
Chart: Rework Controller Deployment/DaemonSet OpenTelemetry values.
Gacko Sep 27, 2024
c273589
Chart: Rework Controller Deployment/DaemonSet Extra Modules values.
Gacko Sep 27, 2024
6920b94
Chart: Rework Controller ConfigMap values.
Gacko Sep 27, 2024
331fb31
Chart: Rework Controller ConfigMap Add/Proxy Headers values.
Gacko Sep 27, 2024
d987703
Chart: Rework Controller IngressClass values.
Gacko Sep 27, 2024
b11f3ed
Chart: Rework Controller HPA values.
Gacko Sep 27, 2024
b4f74c0
Chart: Rework Controller Service values.
Gacko Sep 27, 2024
b68dca9
Chart: Rework Controller Service Internal values.
Gacko Sep 27, 2024
44f81b2
Chart: Rework Admission Webhooks Cert Manager values.
Gacko Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Chart

on:
push:
branches:
- main
- release-*
paths:
- charts/ingress-nginx/Chart.yaml

workflow_dispatch:

permissions:
contents: read

jobs:
release:
name: Release
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: 3.x

- name: Set up Helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0

- name: Set up Helm Chart Testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1

- name: Set up Artifact Hub
run: |
curl --fail --location https://github.com/artifacthub/hub/releases/download/v1.19.0/ah_1.19.0_linux_amd64.tar.gz --output /tmp/ah.tar.gz
echo "0e430493521ce387ca04d79b26646a86f92886dbcceb44985bb71082a9530ca5 /tmp/ah.tar.gz" | shasum --check
sudo tar --extract --file /tmp/ah.tar.gz --directory /usr/local/bin ah

- name: Set up Git
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"

- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

- name: Lint chart
run: |
ct lint --config .ct.yaml
ah lint --path charts/ingress-nginx

- name: Release chart
uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0
env:
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CR_RELEASE_NAME_TEMPLATE: helm-chart-{{ .Version }}
CR_SKIP_EXISTING: true
with:
charts_dir: charts
112 changes: 44 additions & 68 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,112 +208,88 @@ jobs:
path: docker.tar.gz
retention-days: 5

helm-lint:
name: Helm chart lint
chart-lint:
name: Chart / Lint
runs-on: ubuntu-latest
needs:
- changes
if: |
(needs.changes.outputs.charts == 'true') || (needs.changes.outputs.baseimage == 'true') || ${{ github.event.workflow_dispatch.run_e2e == 'true' }}

if: fromJSON(needs.changes.outputs.charts) || fromJSON(needs.changes.outputs.baseimage) || fromJSON(github.event.workflow_dispatch.run_e2e)

steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
fetch-depth: 0
python-version: 3.x

- name: Set up Helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0

- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: '3.x'

- name: Set up chart-testing
- name: Set up Helm Chart Testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1

- name: Install Helm Unit Test Plugin
- name: Set up Artifact Hub
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest
curl --fail --location https://github.com/artifacthub/hub/releases/download/v1.19.0/ah_1.19.0_linux_amd64.tar.gz --output /tmp/ah.tar.gz
echo "0e430493521ce387ca04d79b26646a86f92886dbcceb44985bb71082a9530ca5 /tmp/ah.tar.gz" | shasum --check
sudo tar --extract --file /tmp/ah.tar.gz --directory /usr/local/bin ah

- name: Run Helm Unit Tests
run: |
helm unittest charts/ingress-nginx -d
- name: Set up Helm Docs
uses: gabe565/setup-helm-docs-action@d5c35bdc9133cfbea3b671acadf50a29029e87c2 # v1.0.4

- name: Run chart-testing (lint)
run: ct lint --config ./.ct.yaml
- name: Set up Helm Unit Test
run: helm plugin install https://github.com/helm-unittest/helm-unittest

- name: Run helm-docs
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

- name: Lint chart
run: |
GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/[email protected]
./helm-docs --chart-search-root=${GITHUB_WORKSPACE}/charts
DIFF=$(git diff ${GITHUB_WORKSPACE}/charts/ingress-nginx/README.md)
if [ ! -z "$DIFF" ]; then
echo "Please use helm-docs in your clone, of your fork, of the project, and commit a updated README.md for the chart. https://github.com/kubernetes/ingress-nginx/blob/main/RELEASE.md#d-edit-the-valuesyaml-and-run-helm-docs"
fi
git diff --exit-code
rm -f ./helm-docs

- name: Run Artifact Hub lint
ct lint --config .ct.yaml
ah lint --path charts/ingress-nginx

- name: Check docs
run: |
wget https://github.com/artifacthub/hub/releases/download/v1.5.0/ah_1.5.0_linux_amd64.tar.gz
echo 'ad0e44c6ea058ab6b85dbf582e88bad9fdbc64ded0d1dd4edbac65133e5c87da *ah_1.5.0_linux_amd64.tar.gz' | shasum -c
tar -xzvf ah_1.5.0_linux_amd64.tar.gz ah
./ah lint -p charts/ingress-nginx || exit 1
rm -f ./ah ./ah_1.5.0_linux_amd64.tar.gz

helm-test:
name: Helm chart testing
helm-docs --chart-search-root charts
git diff --exit-code charts/ingress-nginx/README.md

- name: Run tests
run: helm unittest charts/ingress-nginx

chart-test:
name: Chart / Test
runs-on: ubuntu-latest
needs:
- changes
- build
- helm-lint
if: |
(needs.changes.outputs.charts == 'true') || (needs.changes.outputs.baseimage == 'true') || ${{ github.event.workflow_dispatch.run_e2e == 'true' }}
- chart-lint

if: fromJSON(needs.changes.outputs.charts) || fromJSON(needs.changes.outputs.baseimage) || fromJSON(github.event.workflow_dispatch.run_e2e)

strategy:
matrix:
k8s: [v1.28.13, v1.29.8, v1.30.4, v1.31.0]

steps:
- name: Checkout
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ needs.build.outputs.golangversion }}
check-latest: true

- name: cache
- name: Download cache
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: docker.tar.gz

- name: fix permissions
run: |
sudo mkdir -p $HOME/.kube
sudo chmod -R 777 $HOME/.kube

- name: Create Kubernetes ${{ matrix.k8s }} cluster
id: kind
run: |
kind create cluster --image=kindest/node:${{ matrix.k8s }}

- name: Load images from cache
run: |
echo "loading docker images..."
gzip -dc docker.tar.gz | docker load
- name: Load cache
run: gzip --decompress --stdout docker.tar.gz | docker load

- name: Test
- name: Run tests
env:
KIND_CLUSTER_NAME: kind
SKIP_CLUSTER_CREATION: true
K8S_VERSION: ${{ matrix.k8s }}
SKIP_IMAGE_CREATION: true
SKIP_INGRESS_IMAGE_CREATION: true
run: |
kind get kubeconfig > $HOME/.kube/kind-config-kind
sudo mkdir -pm 777 "${HOME}/.kube"
make kind-e2e-chart-tests

kubernetes:
Expand Down
88 changes: 0 additions & 88 deletions .github/workflows/helm.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
helm-docs
# OSX
._*
.DS_Store
Expand Down
11 changes: 5 additions & 6 deletions MANUAL_RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,18 @@ Promoting the images basically means that images, that were pushed to staging co
```

### d. Edit the values.yaml and run helm-docs

- [Fields to edit in values.yaml](https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/values.yaml)

- tag
- digest

- [helm-docs](https://github.com/norwoodj/helm-docs) is a tool that generates the README.md for a helm-chart automatically. In the CI pipeline workflow of github actions (/.github/workflows/ci.yaml), you can see how helm-docs is used. But the CI pipeline is not designed to make commits back into the project. So we need to run helm-docs manually, and check in the resulting autogenerated README.md at the path /charts/ingress-nginx/README.md
- [helm-docs](https://github.com/norwoodj/helm-docs) is a tool that generates the README.md for a Helm chart automatically. In the CI pipeline workflow of GitHub actions (.github/workflows/ci.yaml), you can see how helm-docs is used. The CI pipeline is not designed to make commits back into the project, so we need to run helm-docs manually and commit the resulting generated README.md. You can obtain a recent version of the helm-docs binary here: https://github.com/norwoodj/helm-docs/releases.
```
GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/[email protected]
./helm-docs --chart-search-root=${GITHUB_WORKSPACE}/charts
git diff --exit-code
rm -f ./helm-docs
helm-docs --chart-search-root charts
git diff charts/ingress-nginx/README.md
Gacko marked this conversation as resolved.
Show resolved Hide resolved
```
Watchout for mistakes like leaving the helm-docs executable in your clone workspace or not checking the new README.md manually etc.
Take care of not leaving the helm-docs executable in your clone workspace or not committing the new README.md.

### e. Edit the static manifests

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
controller:
kind: DaemonSet
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null
admissionWebhooks:
enabled: false

service:
type: ClusterIP

admissionWebhooks:
certManager:
enabled: true

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null

service:
type: ClusterIP

addHeaders:
X-Frame-Options: deny
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
controller:
image:
repository: ingress-controller/controller
tag: 1.0.0-dev
digest: null

service:
type: ClusterIP

proxySetHeaders:
X-Forwarded-Proto: https
Loading