Skip to content

Commit 3868522

Browse files
authored
Merge branch 'master' into usr/akhil/GITOPS-8591
2 parents 6ae0a4d + 7a5cfe6 commit 3868522

File tree

4 files changed

+309
-15
lines changed

4 files changed

+309
-15
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,28 @@ An operator that gets you an Argo CD for cluster configuration out-of-the-box on
1212
apiVersion: operators.coreos.com/v1alpha1
1313
kind: CatalogSource
1414
metadata:
15-
name: gitops-service-source
15+
name: devel-gitops-service-source
1616
namespace: openshift-marketplace
1717
spec:
18-
displayName: 'Gitops Service by Red Hat'
19-
image: 'quay.io/<quay-username>/gitops-operator-index:v0.0.1'
20-
publisher: 'Red Hat Developer'
18+
displayName: "!!! GITOPS DEVEL !!!"
19+
image: quay.io/<QUAY_USERNAME>/gitops-operator-catalog:v<VERSION>
20+
publisher: "!!! GITOPS DEVEL !!!"
2121
sourceType: grpc
2222
```
23+
(Remember to replace the placeholders)
2324

24-
2. Go to the OperatorHub on OpenShift Webconsole and look for the "OpenShift GitOps" operator.
25-
25+
- This only works _after_ you have built and pushed the bundle and the catalog (see below).
26+
- To verify the source is correctly configured, `oc y CatalogSource gitops-service-source -n openshift-marketplace | yq '.status.connectionState.lastObservedState'` should report `READY`.
27+
- If not, consult `oc get events -n openshift-marketplace`.
2628

29+
2. Go to the OperatorHub on OpenShift Webconsole and look for the "OpenShift GitOps" operator from `!!! GITOPS DEVEL !!!` source.
2730

2831
![a relative link](docs/assets/operatorhub-listing.png)
2932

30-
3. Install the operator in the `openshift-gitops-operator` namespace using the defaults in the wizard, and optionally, select the checkbox to enable cluster monitoring on the namespace. Wait for it to show up in the list of "Installed Operators". If it doesn't install properly, you can check on its status in the "Installed Operators" tab in the `openshift-gitops-operator` namespace.
33+
3. Install the operator in the `openshift-gitops-operator` namespace using the defaults in the wizard, and optionally, select the checkbox to enable cluster monitoring on the namespace.
34+
Wait for it to show up in the list of "Installed Operators".
35+
If it doesn't install properly, you can check on its status in the "Installed Operators" tab in the `openshift-gitops-operator` namespace, or `oc get jobs -n openshift-marketplace`.
36+
To rerun the operator install, make sure to remove the Subscription and the InstallPlan (if exists).
3137

3238
![a relative link](docs/assets/installed-operator.png)
3339

@@ -74,14 +80,16 @@ Set the base image and version for building operator, bundle and index images.
7480
export IMAGE=quay.io/<quay-username>/gitops-operator VERSION=1.8.0
7581
```
7682

83+
Note quey.io will auto-create the repositories if they do not exist.
84+
Make sure to change their visibility to public in Quay UI, so OpenShift can access them.
85+
7786
1. Build and push the operator image.
7887

7988
```
8089
make docker-build docker-push
8190
```
8291

83-
84-
2. Build and push the Bundle image ( operator + OLM manifests )
92+
2. Build and push the Bundle image (operator + OLM manifests)
8593

8694
```
8795
make bundle
@@ -90,12 +98,6 @@ make bundle-build bundle-push
9098

9199
3. Build and push the Index image
92100

93-
Install `opm` binary which is required to build index images
94-
95-
```
96-
make opm
97-
```
98-
99101
```
100102
make catalog-build catalog-push
101103
```
Lines changed: 90 additions & 0 deletions
Loading
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
This script may be used to audit the namespace-scoped Roles/RoleBindings that are created by the GitOps operator's 'applications in any namespace/applicationsets in any namespace' features.
2+
(The 'apps/applications in any namespace' features are not enabled by default. They are enabled via `ArgoCD` CR `.spec.sourceNamespaces` and `.spec.applicationSet.sourceNamespaces`.)
3+
4+
This is a simple script that will look for Roles/RoleBindings across ALL namespaces that meet ALL of the following criteria:
5+
- A) The Role allows access to `argoproj.io/Application` resource
6+
- B) The Role has label `app.kubernetes.io/part-of: argocd`
7+
- C) The RoleBinding references a service-account in another namespace (cross-namespace access)
8+
9+
This criteria ensures that the Role/RoleBinding was likely created by GitOps operator, and that an Argo CD instance on the cluster has (or had) access to that namespace.
10+
11+
## Procedure:
12+
1) Ensure that `jq` and `oc` executables are installed and on path.
13+
2) Ensure that you are logged into cluster via `oc` or `kubectl` CLI.
14+
3) Execute `./audit-operator-roles.sh`
15+
4) Examine the output list of Roles/RoleBindings.
16+
17+
For each Role/RoleBinding that is listed:
18+
- If a Role/RoleBinding is listed, that means another namespace on the cluster has access to the namespace containing the Role/RoleBinding
19+
- Verify that it is correct for the namespace containing the Role/RoleBinding to be accessed by the namespace listed in subject field of the RoleBinding.
20+
- For example, it is correct if you need an Argo CD instance (installed in the namespace listed in subject field of the RoleBinding) to deploy to the namespace containing the RoleBinding.
21+
- In contrast, it is likely not correct if there exist Roles/RoleBindings in namespaces that Argo CD is not explicitly deploying to.
22+
- If a Role/RoleBinding exists that is not required, delete them.
23+
- NOTE: They will be recreated by the operator if there exists an `ArgoCD` CR that references the namespace via the `.spec.sourceNamespaces` or `.spec.applicationSet.sourceNamespaces`.
24+
- If this is the case, first remove the namespace from these fields, then delete the Role/RoleBinding.
25+
26+
27+
Example:
28+
29+
In this example, the script indicates that the `my-argocd` namespace has access to the `app-ns` namespaces via multiple GitOps-operator-created Roles/RoleBindings:
30+
31+
```
32+
=========================================================
33+
SEARCH CRITERIA (Must match ALL):
34+
1. API/Resource: argoproj.io / applications
35+
2. Label: app.kubernetes.io/part-of=argocd
36+
3. Scope: Cross-namespace only
37+
=========================================================
38+
39+
Scanning Cluster (this may take a moment)...
40+
41+
Roles with cross-namespace access:
42+
• Role: app-ns/example-my-argocd-applicationset
43+
• Role: app-ns/example_app-ns
44+
45+
Cross-namespace bindings detail:
46+
--------------------------------------------------
47+
BINDING: app-ns / example-my-argocd-applicationset
48+
ROLE REF: example-my-argocd-applicationset
49+
SUBJECTS (cross-namespace only):
50+
• ServiceAccount: example-applicationset-controller (ns: my-argocd)
51+
52+
• Namespace my-argocd has access to app-ns
53+
54+
--------------------------------------------------
55+
BINDING: app-ns / example_app-ns
56+
ROLE REF: example_app-ns
57+
SUBJECTS (cross-namespace only):
58+
• ServiceAccount: example-argocd-server (ns: my-argocd)
59+
• ServiceAccount: example-argocd-application-controller (ns: my-argocd)
60+
61+
• Namespace my-argocd has access to app-ns
62+
```

0 commit comments

Comments
 (0)