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][1/2] Repo reorg Preparation #96

Merged
merged 20 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
34 changes: 30 additions & 4 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
{
"extends": ["github>rancher/renovate-config#release"],
"baseBranches": ["main"],
"prHourlyLimit": 2
}
"extends": [
"github>rancher/renovate-config#release",
"group:allNonMajor"
],
"baseBranches": [
"main"
],
"enabledManagers": [
"dockerfile",
"github-actions",
"helm-values",
"regex"
],
"packageRules": [
{
"groupName": "GitHub Workflow Actions",
"groupSlug": "gha-deps",
"matchManagers": [
"github-actions"
]
},
{
"groupName": "Docker File Deps",
"groupSlug": "docker-bumps",
"matchManagers": [
"dockerfile"
]
}
]
}
4 changes: 2 additions & 2 deletions .github/workflows/e2e/scripts/create-project-namespace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ cd $(dirname $0)/../../../..

USE_RANCHER=${USE_RANCHER:-"false"}
if [ "$USE_RANCHER" = "true" ]; then
kubectl apply -f ./examples/ci/project.yaml
kubectl apply -f ./examples/prometheus-federator/ci/project.yaml
fi

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

sleep "${DEFAULT_SLEEP_TIMEOUT_SECONDS}"
if ! kubectl get namespace cattle-project-p-example; then
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e/scripts/create-projecthelmchart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ source $(dirname $0)/entry
cd $(dirname $0)/../../../..

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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e/scripts/delete-projecthelmchart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ source $(dirname $0)/entry
cd $(dirname $0)/../../../..

if [[ "${E2E_CI}" == "true" ]]; then
kubectl delete -f ./examples/ci/project-helm-chart.yaml
kubectl delete -f ./examples/prometheus-federator/ci/project-helm-chart.yaml
else
kubectl delete -f ./examples/project-helm-chart.yaml
kubectl delete -f ./examples/prometheus-federator/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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: ci
name: "[prom-fed] ci"

on:
workflow_call:
pull_request:
paths-ignore:
- 'docs/**'
Expand All @@ -11,14 +12,22 @@ on:
- 'CODEOWNERS'
- 'LICENSE'
- 'Makefile'
push:
branches:
- main

env:
YQ_VERSION : v4.25.1
CGO_ENABLED : 0

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- x64
- arm64
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
steps:
- uses: actions/checkout@v4
- name : Set up Go
Expand All @@ -27,13 +36,8 @@ jobs:
go-version: '1.22'
- name : Install YQ
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;
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${{ matrix.arch == 'x64' && 'amd64' || matrix.arch }} -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
- name : Install helm
run : |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
rm get_helm.sh
helm version
uses: azure/setup-helm@v3
- name: Run CI
run: make ci
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: E2E Prometheus Federator
name: "[prom-fed] E2E CI"

on:
workflow_dispatch:
Expand All @@ -24,6 +24,14 @@ on:
- 'CODEOWNERS'
- 'LICENSE'
- 'Makefile'
push:
branches:
- main
paths-ignore:
- 'docs/**'
- '*.md'
- 'CODEOWNERS'
- 'LICENSE'

env:
GOARCH: amd64
Expand All @@ -44,7 +52,12 @@ permissions:
jobs:
prebuild-env:
name: Prebuild needed Env vars
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- x64
- arm64
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
steps:
- name: Check out the repository to the runner
uses: actions/checkout@v4
Expand All @@ -59,14 +72,17 @@ jobs:
needs: [
prebuild-env,
]
runs-on: ubuntu-latest
env:
TAG: ${{ needs.prebuild-env.outputs.branch_static_tag }}
strategy:
matrix:
arch:
- x64
- arm64
k3s_version:
# k3d version list k3s | sed 's/+/-/' | sort -h
- ${{ github.event.inputs.k3s_version || 'v1.28.14-k3s1' }}
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
env:
TAG: ${{ needs.prebuild-env.outputs.branch_static_tag }}
steps:
-
uses: actions/checkout@v3
Expand All @@ -82,7 +98,7 @@ jobs:
-
name: Install mikefarah/yq
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;
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${{ matrix.arch == 'x64' && 'amd64' || matrix.arch }} -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
-
name: Perform pre-e2e image build
run: |
Expand Down Expand Up @@ -167,7 +183,7 @@ jobs:
if: failure()
uses: actions/upload-artifact@v3
with:
name: artifacts
name: artifacts-${{ matrix.arch }}-${{ matrix.k3s_version }}
path: artifacts/
retention-days: 1
-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./package/Dockerfile
file: ./package/Dockerfile-prometheus-federator
push: true
tags: ${{ env.IMAGE }}
platforms: linux/amd64,linux/arm64
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/.cache
/bin
/build
!/cmd/prometheus-federator/fs/.gitkeep
/cmd/prometheus-federator/fs/*
/dist
*.swp
.idea
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Scan through our [existing issues](https://github.com/rancher/helm-project-opera
- Using the command line:
- [Fork the repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#fork-an-example-repository) so that you can make your changes without affecting the original project until you're ready to merge them.

3. Install or update to **Go 1.17**. For more information, see [the development guide](docs/developing.md).
3. Install or update to **Go 1.17**. For more information, see [the development guide](docs/prometheus-federator/developing.md).

4. Create a working branch and start with your changes!

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TARGETS := $(shell ls scripts)
TARGETS := $(shell ls scripts|grep -ve "^util-\|entry\|^pull-scripts")

$(TARGETS):
./scripts/$@
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ For more information on how to configure the underlying Project Monitoring Stack

## Getting Started

For more information, see the [Getting Started guide](docs/gettingstarted.md).
For more information, see the [Getting Started guide](docs/prometheus-federator/gettingstarted.md).

## Developing

### Which branch do I make changes on?

Prometheus Federator is built and released off the contents of the `main` branch. To make a contribution, open up a PR to the `main` branch.

For more information, see the [Developing guide](docs/developing.md).
For more information, see the [Developing guide](docs/prometheus-federator/developing.md).

## Building

`make`

> **Note:** For a more in-depth explanation of how Prometheus Federator is built (intended for anyone who would like to fork this repo to create a new Project Operator!), see the [Build guide](docs/build.md).
> **Note:** For a more in-depth explanation of how Prometheus Federator is built (intended for anyone who would like to fork this repo to create a new Project Operator!), see the [Build guide](docs/prometheus-federator/build.md).

## Running

Expand All @@ -45,7 +45,7 @@ While this repository does maintain a standalone Helm repository for vanilla Hel

**The chart in rancher/charts is generally the version that is intended for use in production since that is the chart that will be tested by Rancher's QA team.** Generally, these charts will match stable versions of charts available in this repository, so non-Rancher users **should** be able to safely use those versions in this repository for production use cases (at their own risk).

For more information on the process maintainers of this repository use to mirror these charts over to [`rancher/charts`](https://github.com/rancher/charts), see the [Rancher release guide](docs/rancher_release.md).
For more information on the process maintainers of this repository use to mirror these charts over to [`rancher/charts`](https://github.com/rancher/charts), see the [Rancher release guide](docs/prometheus-federator/rancher_release.md).

## License
Copyright (c) 2020 [Rancher Labs, Inc.](http://rancher.com)
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion main.go → cmd/prometheus-federator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
// SystemNamespaces is the system namespaces scoped for the embedded monitoring chart (rancher-project-monitoring)
SystemNamespaces = []string{"kube-system", "cattle-monitoring-system", "cattle-dashboards"}

//go:embed build/chart/rancher-project-monitoring.tgz.base64
//go:embed fs/rancher-project-monitoring.tgz.base64
base64TgzChart string

debugConfig command.DebugConfig
Expand Down
9 changes: 9 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# prometheus-federator collective

The information in this top level docs folder should be relevant to all packages in this repo.
For package specific information each sub-package should have an equivalent directory.

The packages maintained from this repo are:
- `prometheus-federator`,
- `helm-project-operator`,
- `helm-locker`
12 changes: 6 additions & 6 deletions docs/build.md → docs/prometheus-federator/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The underlying Helm Chart whose releases are deployed on behalf of every registe

While the source of this chart is found in the `packages/` directory, which is a construct of any [rancher/charts-build-scripts](https://github.com/rancher/charts-build-scripts) repository (see [the docs on Packages](https://github.com/rancher/charts-build-scripts/blob/master/templates/template/docs/packages.md) for more information), it is expected that a developer who files a PR with changes will run the `make charts` command to ensure that the package is read by the `rancher/charts-build-scripts` binary to **produce / auto-generate** the Helm Charts and manage the `assets/`+`charts/` directories as well as the `index.yaml` entries to introduce this package in a standard Helm repository fashion.

Once `make charts` has been run and the chart is built from `packages/rancher-project-monitoring/` -> `charts/rancher-project-monitoring/${VERSION}` (part of the `make charts` command), the built chart is then converted into a `.tgz.base64` version of itself in [scripts/build-chart](../scripts/build-chart) and left in `bin/rancher-project-monitoring/rancher-project-monitoring.tgz.base64`.
Once `make charts` has been run and the chart is built from `packages/rancher-project-monitoring/` -> `charts/rancher-project-monitoring/${VERSION}` (part of the `make charts` command), the built chart is then converted into a `.tgz.base64` version of itself in [scripts/build-chart](../../scripts/build-chart) and left in `bin/rancher-project-monitoring/rancher-project-monitoring.tgz.base64`.

```bash
helm package charts/${CHART}/${VERSION} --destination bin/${CHART}
Expand All @@ -21,7 +21,7 @@ rm bin/${CHART}/${CHART}-${VERSION}.tgz

## The Project Operator Image

To implement a Project Operator, Helm Project Operator expects a user to run the `operator.Init` command, which appears in Prometheus Federator's [`main.go`](../main.go) as follows:
To implement a Project Operator, Helm Project Operator expects a user to run the `operator.Init` command, which appears in Prometheus Federator's [`main.go`](../../main.go) as follows:

```go
operator.Init(ctx, f.Namespace, cfg, common.Options{
Expand All @@ -36,7 +36,7 @@ operator.Init(ctx, f.Namespace, cfg, common.Options{
})
```

While the `HelmAPIVersion`, `ReleaseName`, and `SystemNamespaces` supplied are hard-coded into the [`main.go`](../main.go) and the `RuntimeOptions` are taken from the CLI arguments provided, the only additional value that is needed to build this chart is the `.tgz.base64` version of the chart that is passed in as a string to the operator.
While the `HelmAPIVersion`, `ReleaseName`, and `SystemNamespaces` supplied are hard-coded into the [`main.go`](../../main.go) and the `RuntimeOptions` are taken from the CLI arguments provided, the only additional value that is needed to build this chart is the `.tgz.base64` version of the chart that is passed in as a string to the operator.

This is precisely what we build in the prior step at `bin/rancher-project-monitoring/rancher-project-monitoring.tgz.base64`, which is why that path is found as a `go embed` directive on building the `main.go`:

Expand All @@ -45,9 +45,9 @@ This is precisely what we build in the prior step at `bin/rancher-project-monito
base64TgzChart string
```

Once your [`main.go`](../main.go) is ready to be built, you can run `./scripts/build`, which will run the underlying `go build` command and place the created binary in `bin/prometheus-federator`.
Once your [`main.go`](../../main.go) is ready to be built, you can run `./scripts/build`, which will run the underlying `go build` command and place the created binary in `bin/prometheus-federator`.

Once the binary has been created, it is then packaged into a container image in the [`scripts/package`](../scripts/package) step, where we build the Dockerfile found in `packages/Dockerfile` to produce the final image.
Once the binary has been created, it is then packaged into a container image in the [`scripts/package`](../../scripts/package) step, where we build the Dockerfile found in `packages/Dockerfile` to produce the final image.

## The Project Operator Helm Chart

Expand All @@ -62,7 +62,7 @@ Once `make charts` has been run and the chart is built from `packages/prometheus
Therefore, as a whole, the build process of Underlying Helm Chart looks as follows:
- By a developer on making a PR to change the Underlying Helm Chart:
- Run `make charts` to produce the Underlying Helm Chart in `charts/rancher-project-monitoring/${VERSION}` from `packages/rancher-project-monitoring/`
- By running `make` (which runs [rancher/dapper](https://github.com/rancher/dapper) on the `Dockerfile.dapper`, which in turn runs [`./scripts/ci`](../scripts/ci) that runs the following commands in an container image):
- By running `make` (which runs [rancher/dapper](https://github.com/rancher/dapper) on the `Dockerfile.dapper`, which in turn runs [`./scripts/ci`](../../scripts/ci) that runs the following commands in an container image):
- Run `./scripts/build-chart` to produce `bin/rancher-project-monitoring/rancher-project-monitoring.tgz.base64` from the Underlying Helm Chart
- Run `./scripts/build` to produce the Project Operator Binary `bin/prometheus-federator`; **this will work since `bin/rancher-project-monitoring/rancher-project-monitoring.tgz.base64` exists from the previous step**
- Run `./scripts/package` to produce the Project Operator Image
Expand Down
File renamed without changes.
Loading
Loading