Skip to content

Commit 41ccdd3

Browse files
committed
Adapt config applying jobs & docs for applyconfig
1 parent 7ee9768 commit 41ccdd3

File tree

9 files changed

+44
-109
lines changed

9 files changed

+44
-109
lines changed

Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
APPLY := oc apply
2-
31
.PHONY: check check-core dry-core-admin core-admin dry-core core
42

53
check: check-core
64
@echo "Service config check: PASS"
75

86
check-core:
9-
make -C core-services check
7+
core-services/_hack/validate-core-services.sh core-services
108
@echo "Core service config check: PASS"
119

1210
dry-core-admin:
13-
make core-admin APPLY="$(APPLY) --dry-run=true"
11+
go run ./tools/applyconfig --config-dir core-services --level=admin
1412

1513
core-admin:
16-
make -C core-services admin-resources APPLY="$(APPLY) --as=system:admin"
14+
go run ./tools/applyconfig --config-dir core-services --level=admin --confirm=true
1715

1816
dry-core:
19-
make core APPLY="$(APPLY) --dry-run=true"
17+
go run ./tools/applyconfig --config-dir core-services
2018

2119
core:
22-
make -C core-services resources APPLY="$(APPLY)"
20+
go run ./tools/applyconfig --config-dir core-services --confirm=true
2321

2422
# LEGACY TARGETS
2523
# You should not need to add new targets here.
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
build_root:
22
image_stream_tag:
3-
name: "origin-release"
4-
namespace: ci
5-
tag: cli
3+
name: release
4+
namespace: openshift
5+
tag: golang-1.12
66
resources:
77
'*':
88
limits:
@@ -15,8 +15,3 @@ tests:
1515
commands: make check
1616
container:
1717
from: src
18-
- as: core-dry
19-
commands: |
20-
go run ./tools/applyconfig/... --config-dir core-services
21-
container:
22-
from: src

ci-operator/jobs/openshift/release/openshift-release-master-presubmits.yaml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -77,42 +77,21 @@ presubmits:
7777
- master
7878
context: ci/prow/core-dry
7979
decorate: true
80-
decoration_config:
81-
skip_cloning: true
82-
labels:
83-
ci-operator.openshift.io/prowgen-controlled: "true"
8480
name: pull-ci-openshift-release-master-core-dry
8581
rerun_command: /test core-dry
8682
spec:
8783
containers:
8884
- args:
89-
- --artifact-dir=$(ARTIFACTS)
90-
- --give-pr-author-access-to-namespace=true
91-
- --sentry-dsn-path=/etc/sentry-dsn/ci-operator
92-
- --target=core-dry
85+
- core-dry
9386
command:
94-
- ci-operator
95-
env:
96-
- name: CONFIG_SPEC
97-
valueFrom:
98-
configMapKeyRef:
99-
key: openshift-release-master.yaml
100-
name: ci-operator-master-configs
101-
image: ci-operator:latest
87+
- make
88+
image: registry.svc.ci.openshift.org/ci/origin-release:cli
10289
imagePullPolicy: Always
10390
name: ""
10491
resources:
10592
requests:
10693
cpu: 10m
107-
volumeMounts:
108-
- mountPath: /etc/sentry-dsn
109-
name: sentry-dsn
110-
readOnly: true
111-
serviceAccountName: ci-operator
112-
volumes:
113-
- name: sentry-dsn
114-
secret:
115-
secretName: sentry-dsn
94+
serviceAccountName: config-updater
11695
trigger: (?m)^/test( | .* )core-dry,?($|\s.*)
11796
- agent: kubernetes
11897
always_run: true

core-services/Makefile

Lines changed: 0 additions & 17 deletions
This file was deleted.

core-services/README.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,29 @@ the cluster automatically by a postsubmit job.
1010

1111
Create a new directory for your service, containing all [necessary files](#quality-criteria-and-conventions).
1212
You may copy the `_TEMPLATE` directory and start using the files there. Add
13-
manifests and other configuration as needed, and make sure the `Makefile` in
14-
your directory applies all config when its `resources` and `admin-resources` are
15-
built.
16-
17-
Add the name of the directory to the `SERVICES` list in the [Makefile](./Makefile).
18-
You should not need to modify this or any other Makefile in any way.
13+
manifests and other configuration as needed.
1914

2015
## Quality criteria and conventions
2116

22-
1. All directories should contain `OWNERS`, `README.md` and `Makefile` files.
23-
This is enforced by `make check` locally and by the `ci/prow/core-valid`
24-
check on pull requests.
25-
2. The `Makefile` should provide `resources` and `admin-resources` targets.
26-
Calling the former should create all resources for which admin permissions
27-
are not necessary. The `config-updater` service account in the `ci` namespace
28-
must have permissions to perform all actions done in the `resources` targets.
29-
Calling `admin-resources` should create all resources for which admin
30-
permissions is necessary. Presence of these targets is enforced by
31-
`make check` locally and by the `ci/prow/core-valid` check on pull requests.
32-
Additionally, `make dry-core{-admin}` runs the appropriate target in dry-run
33-
mode. Passing `make dry-core` is enforced by the `ci/prow/core-dry` check.
34-
3. Makefiles and scripts called by them should use `$(APPLY)` variable instead
35-
of `oc apply`. This allows the universal dry-run to work.
36-
4. Destination namespaces should always be specified within a manifest, never
37-
by a `-n/--namespace` option or by relying on a currently set OpenShift
38-
project.
39-
5. All ConfigMaps need to be set up for automated updates by the
40-
`config-updater` Prow plugin.
17+
1. All directories should contain `OWNERS` and `README.md` files. This is
18+
enforced by `make check` locally and by the `ci/prow/core-valid` check on
19+
pull requests.
20+
2. Config is applied to the cluster using the [`applyconfig`](../tools/applyconfig)
21+
tool. The tool applies all YAML files under your service subdirectory. All
22+
YAML filenames should follow the following convention:
23+
- All admin resources should be in `admin_*.yaml` files
24+
- Names of YAML files that should not be applied to the cluster should start
25+
with `_`.
26+
- The remaining YAML files are considered "standard" resources.
27+
3. `applyconfig` applies files in lexicographical order. In the case when some
28+
resources need to be created before others, this needs to be reflected by the
29+
naming of the files (e.g. by including a numerical component).
30+
4. The `config-updater` service account in the `ci` namespace must have
31+
permissions to apply all standard resources.
32+
5. Destination namespaces should always be specified within a manifest, never
33+
rely on a currently set OpenShift project.
34+
6. All ConfigMaps need to be set up for automated updates by the
35+
`config-updater` Prow plugin.
4136

4237
## How to apply
4338

@@ -63,3 +58,6 @@ ConfigMaps.
6358
to perform all necessary actions
6459
3. ConfigMaps can be manually created by the [config-bootstrapper](https://github.com/kubernetes/test-infra/tree/master/prow/cmd/config-bootstrapper)
6560
tool.
61+
62+
Additionally, the [`applyconfig`](../tools/applyconfig) can be used directly.
63+
See its [README.md](../tools/applyconfig/README.md) for more details.

core-services/_TEMPLATE/Makefile

Lines changed: 0 additions & 10 deletions
This file was deleted.

core-services/_TEMPLATE/_ignored.yaml

Whitespace-only changes.

core-services/_TEMPLATE/admin_resource.yaml

Whitespace-only changes.

core-services/_hack/validate-core-service.sh renamed to core-services/_hack/validate-core-services.sh

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -euo pipefail
55

66
function validate_required_files() {
77
local service_path="$1"
8-
for required in OWNERS README.md Makefile; do
8+
for required in OWNERS README.md; do
99
local required_path="$service_path/$required"
1010
if [[ ! -s "$required_path" ]]; then
1111
echo "[ERROR] $required file not found: $required_path"
@@ -17,25 +17,17 @@ function validate_required_files() {
1717
return 0
1818
}
1919

20-
validate_makefile() {
21-
local service_path="$1"
22-
23-
for target in "resources" "admin-resources"; do
24-
if ! make -C "$service_path" "$target" --dry-run; then
25-
echo "[ERROR] Dry-run of 'make $target' did not succeed, Makefile likely does not provide this required target"
26-
return 1
27-
fi
28-
done
29-
30-
return 0
31-
}
32-
3320
to_validate="$1"
3421
if [[ ! -d "$to_validate" ]]; then
3522
echo "[ERROR] Directory not found: $to_validate"
36-
echo "Usage: validate-core-service.sh DIRECTORY"
23+
echo "Usage: validate-core-services.sh DIRECTORY"
3724
exit 1
3825
fi
3926

40-
validate_required_files "$to_validate" &&
41-
validate_makefile "$to_validate"
27+
for subdir in $1/*/
28+
do
29+
base="$(basename "$subdir")"
30+
if [[ "$base" != _* ]]; then
31+
validate_required_files "$subdir"
32+
fi
33+
done

0 commit comments

Comments
 (0)