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

[main] helm-project-operator and helm-locker repo reorg updates #95

Merged
merged 54 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
aebdb7b
Adjust helm-project-operator/helm-locker imports
mallardduck Sep 11, 2024
0b47461
Add improved cross arch compile script from BRO
mallardduck Sep 11, 2024
8572b3c
Add build script verbosity
mallardduck Sep 11, 2024
5ad4f62
Improve docker file consistenty for helm builds
mallardduck Sep 11, 2024
a3733c5
bump chart version
mallardduck Sep 12, 2024
6bf04f6
Update deps to use new upstream chart
mallardduck Sep 12, 2024
34318c0
make charts
mallardduck Sep 12, 2024
406c8e7
Add ability to manually select rancher-project-monitoring chart version
mallardduck Sep 20, 2024
04810b2
Add version output note
mallardduck Sep 23, 2024
c618eda
Ensure docker file can utilize version config method
mallardduck Sep 23, 2024
5b76e33
Update to use new stable helm-project-operator
mallardduck Sep 27, 2024
dba3550
update e2e ci
mallardduck Sep 27, 2024
7c0c92d
remove use of `AbsaOSS/k3d-action` action
mallardduck Oct 2, 2024
a5748d0
fix perms
mallardduck Oct 2, 2024
fc3162b
Set cluster name as env var
mallardduck Oct 2, 2024
c1d47bc
Adjust ci to use new webhook project label method
mallardduck Oct 4, 2024
1356de8
adjust e2e build step
mallardduck Oct 4, 2024
872c950
Remove some drone stuff and adjust dev tags
mallardduck Oct 4, 2024
c1dfbdd
make scripts more verbose
mallardduck Oct 4, 2024
b20571b
expand docker build step args
mallardduck Oct 4, 2024
4ac1458
Add branch tag helper
mallardduck Oct 4, 2024
b2c0e53
Enable more e2e ci tests
mallardduck Oct 4, 2024
1a76741
Rename ci example to more clear names
mallardduck Oct 4, 2024
3dadce3
update project-namespace creation
mallardduck Oct 5, 2024
e4673b5
Enable the rest of the e2e ci steps
mallardduck Oct 5, 2024
b1a8033
pause for deployments
mallardduck Oct 5, 2024
ee0b238
fix log and expand timeout for create projecthelmchart step
mallardduck Oct 5, 2024
f040af9
update artifacts script
mallardduck Oct 5, 2024
36d4b50
fix dirs
mallardduck Oct 5, 2024
a97ae11
capture a list of all helmcharts
mallardduck Oct 5, 2024
77fc8e7
Update helm-project-operator chart sources
mallardduck Oct 7, 2024
b4c08fc
update charts app version
mallardduck Oct 7, 2024
117a97f
Remove unnecessary condition...
mallardduck Oct 7, 2024
8120c5b
Update image version
mallardduck Oct 7, 2024
a4cd2f6
improve ci scripts verbosity
mallardduck Oct 7, 2024
9e081a9
make charts
mallardduck Oct 7, 2024
e1594ef
Ensure rancher-project-monitoring chart is locked to working 0.3.4 ve…
mallardduck Oct 7, 2024
7da230b
Remove unnecessary wait
mallardduck Oct 7, 2024
00170e1
reorg build script steps
mallardduck Oct 7, 2024
ffe1e82
adjust version script
mallardduck Oct 7, 2024
28cb7b6
improve docker file
mallardduck Oct 7, 2024
b3a8fdd
Only target transitional versions for disabling helm controller
mallardduck Oct 7, 2024
d6a8e7f
fix mixing artifact collection dir
mallardduck Oct 7, 2024
1455806
Adjust to use expected CI namespace
mallardduck Oct 7, 2024
4a1494f
Expand CI error
mallardduck Oct 7, 2024
8bd0570
e2e: add sleep step back
mallardduck Oct 7, 2024
9ff0010
correct namespace in ci
mallardduck Oct 7, 2024
2025425
ci: grab services list for artifacts
mallardduck Oct 7, 2024
6d86176
ci: correct e2e namespace issues
mallardduck Oct 7, 2024
e33c055
fix CI
mallardduck Oct 7, 2024
9dabd5b
fix projecthelmchart deletion script
mallardduck Oct 7, 2024
48f69c0
Adjust the method to check for Not Found response
mallardduck Oct 8, 2024
6d4b0ed
Rename build variable to be more clear
mallardduck Oct 8, 2024
a97f78f
Adjust build paths to not overlap
mallardduck Oct 8, 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
55 changes: 55 additions & 0 deletions .github/scripts/branch-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# Exit immediately if a command exits with a non-zero status
set -e

# Function to get the previous tag
getPreviousTag() {
local tagPrefix="$1"
# List all tags and filter ones that start with tagPrefix, sort by creation date
git tag --sort=-creatordate | grep "^${tagPrefix}" | head -n 1
}

# Determine if we're in a GitHub Actions environment
if [ -n "$GITHUB_REF" ] && [ -n "$GITHUB_SHA" ]; then
# Use GHA environment variables
ref="$GITHUB_REF"
commitSha="${GITHUB_SHA:0:7}"
else
# Fallback to local Git repo
if [ ! -d ".git" ]; then
echo "This script must be run from the root of a Git repository or GitHub Actions."
exit 1
fi
ref=$(git symbolic-ref HEAD)
commitSha=$(git rev-parse --short HEAD)
fi

branchTag=""
branchStaticTag=""
prevTag=""

if [ "$ref" == "refs/heads/main" ]; then
branchTag="head"
branchStaticTag="main-${commitSha}"
prevTag=$(getPreviousTag "main-")
elif [[ "$ref" == refs/heads/release/* ]]; then
version="${ref#refs/heads/release/}" # Extract "vX.0"
branchTag="${version}-head"
branchStaticTag="${version}-head-${commitSha}"
prevTag=$(getPreviousTag "${version}-head-")
else
gitTag=$(git tag -l --contains HEAD | head -n 1)
if [[ -n "$gitTag" ]]; then
branchTag="${gitTag}"
branchStaticTag="${gitTag}-${commitSha}"
else
branchTag="dev-${commitSha}"
branchStaticTag="dev-${commitSha}"
fi
fi

# Output the results
echo "branch_tag=${branchTag}"
echo "branch_static_tag=${branchStaticTag}"
echo "prev_static_tag=${prevTag}"
112 changes: 63 additions & 49 deletions .github/workflows/e2e-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,41 @@ env:
YQ_VERSION: v4.25.1
E2E_CI: true
REPO: rancher
TAG: dev
APISERVER_PORT: 8001
DEFAULT_SLEEP_TIMEOUT_SECONDS: 10
KUBECTL_WAIT_TIMEOUT: 300s
DEBUG: ${{ github.event.inputs.debug || false }}
CLUSTER_NAME: 'e2e-ci-prometheus-federator'

permissions:
contents: write

jobs:
prebuild-env:
name: Prebuild needed Env vars
runs-on: ubuntu-latest
steps:
- name: Check out the repository to the runner
uses: actions/checkout@v4
- name: Set Branch Tag and Other Variables
id: set-vars
run: bash ./.github/scripts/branch-tags.sh >> $GITHUB_OUTPUT
outputs:
branch_tag: ${{ steps.set-vars.outputs.branch_tag }}
branch_static_tag: ${{ steps.set-vars.outputs.branch_static_tag }}
prev_tag: ${{ steps.set-vars.outputs.prev_tag }}
e2e-prometheus-federator:
needs: [
prebuild-env,
]
runs-on: ubuntu-latest
env:
TAG: ${{ needs.prebuild-env.outputs.branch_static_tag }}
strategy:
matrix:
k3s_version:
# k3d version list k3s | sed 's/+/-/' | sort -h
- ${{ github.event.inputs.k3s_version || 'v1.28.4-k3s2' }}
- ${{ github.event.inputs.k3s_version || 'v1.28.14-k3s1' }}
steps:
-
uses: actions/checkout@v3
Expand All @@ -66,28 +84,24 @@ jobs:
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
-
name: Perform CI
name: Perform pre-e2e image build
run: |
REPO=${REPO} TAG=${TAG} ./scripts/build;
REPO=${REPO} TAG=${TAG} ./scripts/package;
EMBEDED_CHART_VERSION=0.3.4 REPO=${REPO} TAG=${TAG} make build;
REPO=${REPO} TAG=${TAG} make package;
-
name: Provision k3d Cluster
uses: AbsaOSS/k3d-action@v2
# k3d will automatically create a network named k3d-test-cluster-1 with the range 172.18.0.0/16
with:
cluster-name: "e2e-ci-prometheus-federator"
args: >-
--agents 1
--network "nw01"
--image docker.io/rancher/k3s:${{matrix.k3s_version}}
name : Install k3d
run : ./.github/workflows/e2e/scripts/install-k3d.sh
-
name : Setup k3d cluster
run : K3S_VERSION=${{ matrix.k3s_version }} ./.github/workflows/e2e/scripts/setup-cluster.sh
-
name: Import Images Into k3d
run: |
k3d image import ${REPO}/prometheus-federator:${TAG} -c e2e-ci-prometheus-federator;
k3d image import ${REPO}/prometheus-federator:${TAG} -c $CLUSTER_NAME;
-
name: Setup kubectl context
run: |
kubectl config use-context k3d-e2e-ci-prometheus-federator;
kubectl config use-context "k3d-$CLUSTER_NAME";
-
name: Set Up Tmate Debug Session
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.enable_tmate == 'true' }}
Expand All @@ -110,39 +124,39 @@ jobs:
-
name: Check if Project Registration Namespace is auto-created on namespace detection
run: ./.github/workflows/e2e/scripts/create-project-namespace.sh;

# Commenting out for failure in CI but not locally
# -
# name: Create Project Monitoring Stack via ProjectHelmChart CR
# run: ./.github/workflows/e2e/scripts/create-projecthelmchart.sh;
# -
# name: Check if the Project Prometheus Stack is up
# run: ./.github/workflows/e2e/scripts/validate-project-monitoring.sh;
# -
# name: Wait for 8 minutes for enough scraping to be done to continue
# run: |
# for i in {1..48}; do sleep 10; echo "Waited $((i*10)) seconds for metrics to be populated"...; done;
# -
# name: Validate Project Prometheus Targets
# run: ./.github/workflows/e2e/scripts/validate-project-prometheus-targets.sh;
# -
# name: Validate Project Grafana Datasources
# run: ./.github/workflows/e2e/scripts/validate-project-grafana-datasource.sh;
# -
# name: Validate Project Grafana Dashboards
# run: ./.github/workflows/e2e/scripts/validate-project-grafana-dashboards.sh;
# #-
# #name: Validate Project Grafana Dashboard Data
# #run: ./.github/workflows/e2e/scripts/validate-project-grafana-dashboard-data.sh;
# -
# name: Validate Project Prometheus Alerts
# run: ./.github/workflows/e2e/scripts/validate-project-prometheus-alerts.sh;
# -
# name: Validate Project Alertmanager
# run: ./.github/workflows/e2e/scripts/validate-project-alertmanager.sh;
# -
# name: Delete Project Prometheus Stack
# run: ./.github/workflows/e2e/scripts/delete-projecthelmchart.sh;
-
name: Create Project Monitoring Stack via ProjectHelmChart CR
run: DEFAULT_SLEEP_TIMEOUT_SECONDS=20 ./.github/workflows/e2e/scripts/create-projecthelmchart.sh;
-
name: Check if the Project Prometheus Stack is up
run: ./.github/workflows/e2e/scripts/validate-project-monitoring.sh;
-
name: Wait for 8 minutes for enough scraping to be done to continue
run: |
for i in {1..48}; do sleep 10; echo "Waited $((i*10)) seconds for metrics to be populated"...; done;
-
name: Validate Project Prometheus Targets
run: ./.github/workflows/e2e/scripts/validate-project-prometheus-targets.sh;
-
name: Validate Project Grafana Datasources
run: ./.github/workflows/e2e/scripts/validate-project-grafana-datasource.sh;
-
name: Validate Project Grafana Dashboards
run: ./.github/workflows/e2e/scripts/validate-project-grafana-dashboards.sh;
# Re-disable this as it's been broken since Jun 28, 2023
# More context: https://github.com/rancher/prometheus-federator/pull/73
# -
# name: Validate Project Grafana Dashboard Data
# run: ./.github/workflows/e2e/scripts/validate-project-grafana-dashboard-data.sh;
-
name: Validate Project Prometheus Alerts
run: ./.github/workflows/e2e/scripts/validate-project-prometheus-alerts.sh;
-
name: Validate Project Alertmanager
run: ./.github/workflows/e2e/scripts/validate-project-alertmanager.sh;
-
name: Delete Project Prometheus Stack
run: ./.github/workflows/e2e/scripts/delete-projecthelmchart.sh;
-
name: Uninstall Prometheus Federator
run: ./.github/workflows/e2e/scripts/uninstall-federator.sh;
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/e2e/scripts/create-project-namespace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ source $(dirname $0)/entry

cd $(dirname $0)/../../../..

kubectl create namespace e2e-prometheus-federator || true
kubectl label namespace e2e-prometheus-federator field.cattle.io/projectId=p-example --overwrite
USE_RANCHER=${USE_RANCHER:-"false"}
if [ "$USE_RANCHER" = "true" ]; then
kubectl apply -f ./examples/ci/project.yaml
fi

kubectl apply -f ./examples/ci/namespace.yaml

sleep "${DEFAULT_SLEEP_TIMEOUT_SECONDS}"
if ! kubectl get namespace cattle-project-p-example; then
echo "ERROR: Expected cattle-project-p-example namespace to exist after ${DEFAULT_SLEEP_TIMEOUT_SECONDS} seconds, not found"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/e2e/scripts/create-projecthelmchart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ source $(dirname $0)/entry
cd $(dirname $0)/../../../..

if [[ "${E2E_CI}" == "true" ]]; then
kubectl apply -f ./examples/ci-example.yaml
kubectl apply -f ./examples/ci/project-helm-chart.yaml
else
kubectl apply -f ./examples/example.yaml
kubectl apply -f ./examples/project-helm-chart.yaml
fi
sleep ${DEFAULT_SLEEP_TIMEOUT_SECONDS};

if ! kubectl get -n cattle-monitoring-system job/helm-install-cattle-project-p-example-monitoring; then
echo "ERROR: Helm Install Job for Project Monitoring Stack was never created after ${KUBECTL_WAIT_TIMEOUT} seconds"
echo "ERROR: Helm Install Job for Project Monitoring Stack was never created after ${DEFAULT_SLEEP_TIMEOUT_SECONDS} seconds"
exit 1
fi

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/e2e/scripts/delete-projecthelmchart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ source $(dirname $0)/entry

cd $(dirname $0)/../../../..

kubectl delete -f ./examples/ci-example.yaml
if [[ "${E2E_CI}" == "true" ]]; then
kubectl delete -f ./examples/ci/project-helm-chart.yaml
else
kubectl delete -f ./examples/project-helm-chart.yaml
fi
if kubectl get -n cattle-monitoring-system job/helm-delete-cattle-project-p-example-monitoring --ignore-not-found; then
if ! kubectl wait --for=condition=complete --timeout="${KUBECTL_WAIT_TIMEOUT}" -n cattle-monitoring-system job/helm-delete-cattle-project-p-example-monitoring; then
echo "ERROR: Helm Uninstall Job for Project Monitoring Stack never completed after ${KUBECTL_WAIT_TIMEOUT}"
Expand Down
38 changes: 31 additions & 7 deletions .github/workflows/e2e/scripts/generate-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,41 @@ MANIFEST_DIRECTORY=${ARTIFACT_DIRECTORY}/manifests
LOG_DIRECTORY=${ARTIFACT_DIRECTORY}/logs

# Manifests

mkdir -p ${MANIFEST_DIRECTORY}
kubectl get pods -n cattle-monitoring-system -o yaml > ${MANIFEST_DIRECTORY}/monitoring_pods.yaml || true
kubectl get pods -n cattle-project-p-example -o yaml > ${MANIFEST_DIRECTORY}/project_pods.yaml || true
mkdir -p ${MANIFEST_DIRECTORY}/helmcharts
mkdir -p ${MANIFEST_DIRECTORY}/helmreleases
mkdir -p ${MANIFEST_DIRECTORY}/daemonsets
mkdir -p ${MANIFEST_DIRECTORY}/deployments
mkdir -p ${MANIFEST_DIRECTORY}/jobs
mkdir -p ${MANIFEST_DIRECTORY}/statefulsets
mkdir -p ${MANIFEST_DIRECTORY}/pods
mkdir -p ${MANIFEST_DIRECTORY}/projecthelmcharts

kubectl get namespaces -o yaml > ${MANIFEST_DIRECTORY}/namespaces.yaml || true
kubectl get projecthelmchart -n cattle-project-p-example -o yaml > ${MANIFEST_DIRECTORY}/projecthelmcharts.yaml || true
kubectl get helmcharts -n cattle-monitoring-system -o yaml > ${MANIFEST_DIRECTORY}/helmcharts.yaml || true
kubectl get helmreleases -n cattle-monitoring-system -o yaml > ${MANIFEST_DIRECTORY}/helmreleases.yaml || true
kubectl get helmcharts -A > ${MANIFEST_DIRECTORY}/helmcharts-list.txt || true
kubectl get services -A > ${MANIFEST_DIRECTORY}/services-list.txt || true

# Logs
## cattle-monitoring-system ns manifests
kubectl get helmcharts -n cattle-monitoring-system -o yaml > ${MANIFEST_DIRECTORY}/helmcharts/cattle-monitoring-system.yaml || true
kubectl get helmreleases -n cattle-monitoring-system -o yaml > ${MANIFEST_DIRECTORY}/helmreleases/cattle-monitoring-system.yaml || true
kubectl get daemonset -n cattle-monitoring-system -o yaml > ${MANIFEST_DIRECTORY}/daemonsets/cattle-monitoring-system.yaml || true
kubectl get deployment -n cattle-monitoring-system -o yaml > ${MANIFEST_DIRECTORY}/deployments/cattle-monitoring-system.yaml || true
kubectl get job -n cattle-monitoring-system -o yaml > ${MANIFEST_DIRECTORY}/jobs/cattle-monitoring-system.yaml || true
kubectl get statefulset -n cattle-monitoring-system -o yaml > ${MANIFEST_DIRECTORY}/statefulsets/cattle-monitoring-system.yaml || true
kubectl get pods -n cattle-monitoring-system -o yaml > ${MANIFEST_DIRECTORY}/pods/cattle-monitoring-system.yaml || true

## cattle-project-p-example ns manifests
kubectl get deployment -n cattle-project-p-example -o yaml > ${MANIFEST_DIRECTORY}/deployments/cattle-project-p-example.yaml || true
kubectl get projecthelmchart -n cattle-project-p-example -o yaml > ${MANIFEST_DIRECTORY}/projecthelmcharts/cattle-project-p-example.yaml || true
kubectl get statefulset -n cattle-project-p-example -o yaml > ${MANIFEST_DIRECTORY}/statefulsets/cattle-project-p-example.yaml || true
kubectl get pods -n cattle-project-p-example -o yaml > ${MANIFEST_DIRECTORY}/pods/cattle-project-p-example.yaml || true

## cattle-project-p-example-monitoring ns manifests
kubectl get deployment -n cattle-project-p-example-monitoring -o yaml > ${MANIFEST_DIRECTORY}/deployments/cattle-project-p-example-monitoring.yaml || true
kubectl get statefulset -n cattle-project-p-example-monitoring -o yaml > ${MANIFEST_DIRECTORY}/statefulsets/cattle-project-p-example-monitoring.yaml || true
kubectl get pods -n cattle-project-p-example-monitoring -o yaml > ${MANIFEST_DIRECTORY}/pods/cattle-project-p-example-monitoring.yaml || true

# Logs
mkdir -p ${LOG_DIRECTORY}/rancher-monitoring

## Rancher Monitoring
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e/scripts/install-federator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ case "${KUBERNETES_DISTRIBUTION_TYPE}" in
cluster_args="--set helmProjectOperator.helmController.enabled=false"
fi
;;
*)
v1.25.*)
embedded_helm_controller_fixed_version="v1.25.4"
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
cluster_args="--set helmProjectOperator.helmController.enabled=false"
Expand All @@ -52,7 +52,7 @@ case "${KUBERNETES_DISTRIBUTION_TYPE}" in
cluster_args="--set helmProjectOperator.helmController.enabled=false"
fi
;;
*)
v1.25.*)
embedded_helm_controller_fixed_version="v1.25.4"
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
cluster_args="--set helmProjectOperator.helmController.enabled=false"
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/e2e/scripts/install-k3d.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e
set -x

K3D_URL=https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh
DEFAULT_K3D_VERSION=v5.7.4

install_k3d(){
local k3dVersion=${K3D_VERSION:-${DEFAULT_K3D_VERSION}}
echo -e "Downloading k3d@${k3dVersion} see: ${K3D_URL}"
curl --silent --fail ${K3D_URL} | TAG=${k3dVersion} bash
}

install_k3d

k3d version
3 changes: 3 additions & 0 deletions .github/workflows/e2e/scripts/install-monitoring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ helm version
helm repo add ${HELM_REPO} https://charts.rancher.io
helm repo update

echo "Create required \`cattle-fleet-system\` namespace"
kubectl create namespace cattle-fleet-system

echo "Installing rancher monitoring crd with :\n"

helm search repo ${HELM_REPO}/rancher-monitoring-crd --versions --max-col-width=0 | head -n 2
Expand Down
Loading
Loading