-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4083 from petr-muller/config-cleanup-final
DPTP-360: Config cleanup kick-off
- Loading branch information
Showing
9 changed files
with
200 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
ifeq ($(APPLY),) | ||
APPLY := oc apply | ||
endif | ||
|
||
SERVICES = | ||
|
||
.PHONY: resources admin-resources check | ||
|
||
check: | ||
_hack/validate-core-service.sh _TEMPLATE # keep the template valid | ||
$(foreach service,$(SERVICES),_hack/validate-core-service.sh $(service);) | ||
|
||
resources: | ||
$(foreach service,$(SERVICES),make -C $(service) APPLY="$(APPLY)" resources;) | ||
|
||
admin-resources: | ||
$(foreach service,$(SERVICES),make -C $(service) APPLY="$(APPLY)" admin-resources;) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Core Services and Configuration | ||
|
||
Manifests for important services (like [OpenShift CI cluster](https://api.ci.openshift.org/) | ||
and the CI service components that run on it) are present in this directory. The | ||
services configured here are critical for some part of the OpenShift project | ||
development workflow, must meet basic quality criteria and must be deployed to | ||
the cluster automatically by a postsubmit job. | ||
|
||
## How to add new service | ||
|
||
Create a new directory for your service, containing all [necessary files](#quality-criteria-and-conventions). | ||
You may copy the `_TEMPLATE` directory and start using the files there. Add | ||
manifests and other configuration as needed, and make sure the `Makefile` in | ||
your directory applies all config when its `resources` and `admin-resources` are | ||
built. | ||
|
||
Add the name of the directory to the `SERVICES` list in the [Makefile](./Makefile). | ||
You should not need to modify this or any other Makefile in any way. | ||
|
||
## Quality criteria and conventions | ||
|
||
1. All directories should contain `OWNERS`, `README.md` and `Makefile` files. | ||
This is enforced by `make check` locally and by the `ci/prow/core-valid` | ||
check on pull requests. | ||
2. The `Makefile` should provide `resources` and `admin-resources` targets. | ||
Calling the former should create all resources for which admin permissions | ||
are not necessary. The `config-updater` service account in the `ci` namespace | ||
must have permissions to perform all actions done in the `resources` targets. | ||
Calling `admin-resources` should create all resources for which admin | ||
permissions is necessary. Presence of these targets is enforced by | ||
`make check` locally and by the `ci/prow/core-valid` check on pull requests. | ||
Additionally, `make dry-core{-admin}` runs the appropriate target in dry-run | ||
mode. Passing `make dry-core` is enforced by the `ci/prow/core-dry` check. | ||
3. Makefiles and scripts called by them should use `$(APPLY)` variable instead | ||
of `oc apply`. This allows the universal dry-run to work. | ||
4. Destination namespaces should always be specified within a manifest, never | ||
by a `-n/--namespace` option or by relying on a currently set OpenShift | ||
project. | ||
5. All ConfigMaps need to be set up for automated updates by the | ||
`config-updater` Prow plugin. | ||
|
||
## How to apply | ||
|
||
There are three types of configuration: admin resources, other resources and | ||
ConfigMaps. | ||
|
||
### Automation | ||
|
||
1. Admin resources are not automatically applied to the cluster. | ||
2. Other resources are automatically applied to the cluster by a Prow | ||
[postsubmit](https://prow.svc.ci.openshift.org/?job=branch-ci-openshift-release-master-core-apply) | ||
after each PR is merged, and also [periodically](https://prow.svc.ci.openshift.org/?job=openshift-release-master-core-apply). | ||
3. ConfigMaps are automatically updated by the `config-updater` Prow plugin, | ||
configured in its [config.yaml](../cluster/ci/config/prow/config.yaml) file. | ||
Additionally, they are [periodically](https://prow.svc.ci.openshift.org/?job=openshift-release-master-config-bootstrapper) | ||
synced by a Prow job. | ||
|
||
### Manual | ||
|
||
1. Admin resources can be created by users with `--as=system:admin` rights by | ||
`make core-admin`. | ||
2. Other resources can be created by `make core`, provided the user has rights | ||
to perform all necessary actions | ||
3. ConfigMaps can be manually created by the [config-bootstrapper](https://github.com/kubernetes/test-infra/tree/master/prow/cmd/config-bootstrapper) | ||
tool. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
ifeq ($(APPLY),) | ||
APPLY := oc apply | ||
endif | ||
|
||
export APPLY | ||
|
||
.PHONY: resources admin-resources | ||
|
||
resources: | ||
$(APPLY) -f resource.yaml -n somewhere |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
approvers: | ||
- dptp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# What is this | ||
|
||
Brief information about why this exists, plus any documentation that might be useful. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
# This script validates all core services meet quality criteria | ||
|
||
set -euo pipefail | ||
|
||
function validate_required_files() { | ||
local service_path="$1" | ||
for required in OWNERS README.md Makefile; do | ||
local required_path="$service_path/$required" | ||
if [[ ! -s "$required_path" ]]; then | ||
echo "[ERROR] $required file not found: $required_path" | ||
echo "[ERROR] All core services should have $required file" | ||
return 1 | ||
fi | ||
done | ||
|
||
return 0 | ||
} | ||
|
||
validate_makefile() { | ||
local service_path="$1" | ||
|
||
for target in "resources" "admin-resources"; do | ||
if ! make -C "$service_path" "$target" --dry-run; then | ||
echo "[ERROR] Dry-run of 'make $target' did not succeed, Makefile likely does not provide this required target" | ||
return 1 | ||
fi | ||
done | ||
|
||
return 0 | ||
} | ||
|
||
to_validate="$1" | ||
if [[ ! -d "$to_validate" ]]; then | ||
echo "[ERROR] Directory not found: $to_validate" | ||
echo "Usage: validate-core-service.sh DIRECTORY" | ||
exit 1 | ||
fi | ||
|
||
validate_required_files "$to_validate" && | ||
validate_makefile "$to_validate" |