├── LICENSE ├── README.md ├── aggregates ├── local-cluster-cluster-config │ └── kustomization.yaml ├── local-cluster-deploy-mycluster │ └── kustomization.yaml └── mycluster-cluster-config │ └── kustomization.yaml ├── applications ├── kustomization.yaml ├── local-cluster │ ├── kustomization.yaml │ ├── local-cluster-appproj.yaml │ ├── local-cluster-cluster-config-app.yaml │ └── local-cluster-deploy-mycluster-app.yaml └── mycluster │ ├── kustomization.yaml │ ├── mycluster-appproj.yaml │ └── mycluster-cluster-config-app.yaml ├── bootstrap ├── argocd-apps │ ├── argocd-apps-app.yaml │ ├── argocd-apps-appsub.yaml │ ├── argocd-apps-channel.yaml │ ├── argocd-apps-placementrule.yaml │ └── kustomization.yaml ├── external-secrets │ ├── custom-kubernetes-token-deployable.yaml │ ├── external-secrets-app.yaml │ ├── external-secrets-deployable-ns.yaml │ ├── external-secrets-helm-appsub.yaml │ ├── external-secrets-helm-channel-ns.yaml │ ├── external-secrets-helm-channel.yaml │ ├── external-secrets-ns-appsub.yaml │ ├── external-secrets-ns-channel-ns.yaml │ ├── external-secrets-ns-channel.yaml │ ├── external-secrets-ns.yaml │ ├── external-secrets-placementrule.yaml │ ├── external-secrets-test-deployable.yaml │ └── kustomization.yaml ├── gitops-namespace │ ├── kustomization.yaml │ └── openshift-gitops-ns.yaml └── gitops-operator │ ├── gitops-operator-app.yaml │ ├── gitops-operator-appsub.yaml │ ├── gitops-operator-channel.yaml │ ├── gitops-operator-placementrule.yaml │ └── kustomization.yaml ├── check.sh ├── docs ├── diagrams │ ├── multi_cluster_management_1.svg │ ├── multi_cluster_management_2.svg │ ├── multi_cluster_management_3.svg │ ├── multi_cluster_management_in_action.svg │ ├── multi_cluster_management_secrets_management_bootstrap.svg │ └── multi_cluster_management_secrets_management_in_action.svg └── external-secrets │ ├── Dockerfile │ ├── README.md │ └── custom_kubernetes_token_path.diff └── manifests ├── apiserver ├── cluster-apiserver.yaml └── kustomization.yaml ├── auth ├── cluster-oauth.yaml └── kustomization.yaml ├── gitops-operator ├── kustomization.yaml └── openshift-gitops-sub.yaml ├── ingress ├── default-ingresscontroller.yaml └── kustomization.yaml ├── managed-clusters └── mycluster │ ├── kustomization.yaml │ ├── mycluster-clusterdeployment.yaml │ ├── mycluster-infra-machinepool.yaml │ ├── mycluster-klusterletaddonconfig.yaml │ ├── mycluster-managedcluster.yaml │ ├── mycluster-managedclusterinfo.yaml │ ├── mycluster-worker-machinepool.yaml │ └── secrets │ ├── mycluster-aws-creds-externalsecret.yaml │ ├── mycluster-install-config-externalsecret.yaml │ ├── mycluster-pull-secret-externalsecret.yaml │ └── mycluster-ssh-private-key-externalsecret.yaml ├── monitoring ├── base │ ├── cluster-monitoring-config-configmap.yaml │ └── kustomization.yaml └── overlays │ └── infra-nodes │ ├── cluster-monitoring-config-configmap.yaml │ └── kustomization.yaml ├── registry ├── base │ ├── cluster-config.yaml │ └── kustomization.yaml └── overlays │ └── rwo │ ├── cluster-config.yaml │ ├── kustomization.yaml │ └── registry-pvc.yaml └── users ├── cluster-viewers-group-clusterrolebinding.yaml ├── cluster-viewers-group.yaml └── kustomization.yaml /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Managing multiple OpenShift/Kubernetes clusters using RHACM and Argo CD 2 | 3 | ## Overview 4 | 5 | Components used: 6 | * [Kubernetes External Secrets](https://github.com/external-secrets/kubernetes-external-secrets) (formerly known as GoDaddy External Secrets) 7 | * Fetches the secret data from HashiCorp Vault or possibly other sources and using this secret data it creates Kubernetes Secrets on the cluster. 8 | * [Red Hat Advanced Cluster Management](https://www.redhat.com/en/technologies/management/advanced-cluster-management) (RHACM) 9 | * Deploys new OpenShift clusters 10 | * Deploys External Secrets on the Hub cluster and managed clusters 11 | * Deploys Argo CD on the Hub cluster 12 | * Deploys AppProject and Application objects that instruct Argo CD how to configure clusters 13 | * [Argo CD](https://argoproj.github.io/argo-cd/) 14 | * Manages clusters using the GitOps approach 15 | 16 | ## Deploying 17 | 18 | The `boostrap` directory contains a set of Kubernetes manifests that need to be deployed to the Hub cluster. 19 | 20 | First, find the values in those manifests that have to be replaced: 21 | 22 | ``` 23 | $ grep -rn REPLACE * 24 | ``` 25 | 26 | Edit the manifests and replace the values with your custom configuration. 27 | 28 | Second, apply the manifests to the Hub cluster: 29 | 30 | ``` 31 | $ oc apply --kustomize bootstrap/external-secrets 32 | ``` 33 | 34 | ``` 35 | $ oc apply --kustomize bootstrap/gitops-namespace 36 | ``` 37 | 38 | ``` 39 | $ oc apply --kustomize bootstrap/gitops-operator 40 | ``` 41 | 42 | ``` 43 | $ oc apply --kustomize bootstrap/argocd-apps 44 | ``` 45 | 46 | ## Directory structure 47 | 48 | The repository consists of several top-level directories: 49 | 50 | * *bootstrap* directory contains manifests that should be deployed first. This deployment can be automated using Ansible. Bootstrap manifests deploy Kubernetes External Secrets operator to the managed clusters. They also deploy Argo CD on the Hub cluster plus all Argo CD application manifests. 51 | * *applications* directory contains Argo CD application manifests. These manifests are deployed by RHACM after the manifests from the *boostrap* directory have been applied. The *applications* directory contains Argo CD application configuration for all managed clusters. 52 | * *aggregates* directory contains kustomizations that combine the kustomizations from the *manifests* directory. After applying a kustomization from the *aggregates* directory, an arbitrary number of kustomizations from the *manifests* directory are applied in one shot. Note that the *aggregates* directory is meant only for combining the kustomizations. There is no overlay configuration in this directory. Overlays are defined in the *manifests* directory. Aggregates are deployed by the Argo CD applications. 53 | * *manifests* directory contains individual configurations applied to the clusters. They are typically grouped into aggregates so that they can be applied at once. This directory also contains overlays which allow to specify configuration differences between individual clusters/environments. 54 | 55 | ## Object management 56 | 57 | Kubernetes objects can be divided into two categories: 58 | 59 | 1. Objects that are owned by the GitOps management. These objects are created and deleted by GitOps. Argo CD assumes by default that it owns all objects under its management. After the object has been deleted in the git repository and the object is allowed to be pruned, Argo CD will delete this object on the cluster during the next sync-up. In RHACM, we annotate the Subscription with `apps.open-cluster-management.io/reconcile-option: replace` to achieve a similar behaviour. 60 | 61 | 2. Objects that are modified by the GitOps management. These objects were created on the cluster by other means. GitOps is supposed to modify these objects but should never try to delete them. In Argo CD, we apply the following annotation to these objects: `argocd.argoproj.io/sync-options: Prune=false`. This prevents Argo CD from deleting these ojects (Prune=false) after they have been removed from the git repository even when the sync operation was executed with `prune=true`. Note that Argo CD will still try to delete the object if you for example delete your application using `argocd app delete --cascade` or if you click Delete in the Web UI. In RHACM, annotate the Subscription with `apps.open-cluster-management.io/reconcile-option: merge` to prevent RHACM from ever trying to delete the object. 62 | 63 | ### Why is Argo CD's auto prune disabled in this repo? 64 | 65 | In this repo, the automated prune of Argo CD applications is disabled by setting `spec.syncPolicy.automated.prune: false` like this: 66 | 67 | ``` 68 | apiVersion: argoproj.io/v1alpha1 69 | kind: Application 70 | metadata: 71 | name: example 72 | spec: 73 | syncPolicy: 74 | automated: 75 | prune: false 76 | ``` 77 | 78 | If the Argo CD's auto prune was enabled for an application named `example`, then Argo CD would delete all objects that belong to this application and do not exist in git anymore. How does Argo CD discover these objects when they are not represented in git? Argo CD looks at the `app.kubernetes.io/instance` label and matches its value against the application name. So, why can automated prune be a problem? Some cluster operators may create objects with this label set. If that happens, Argo CD will delete these objects as they don't exist in the git repository. An example of such object is ManagedClusterInfo created by RHACM. Also, deleting cluster objects feels safer when they need to be removed from git first and then pruned before they get deleted for real. 79 | 80 | ### Why is Argo CD's self-heal enabled in this repo? 81 | 82 | * If the cluster's state has been changed (for example manually by the user) and it now differs from the state in git, Argo CD should restore the cluster state to match the configuration in git. 83 | * If the reconciliation of objects on the cluster fails, we would like Argo CD to keep trying. This is what other OpenShift operators typically do, they keep trying until the object is reconciled successfully. 84 | 85 | ## Video 86 | 87 | [![How to Manage Multiple Clusters Using RHACM and Argo CD](https://img.youtube.com/vi/b7Q3KvgA48Q/0.jpg)](http://www.youtube.com/watch?v=b7Q3KvgA48Q) 88 | 89 | ## TODO 90 | 91 | * Shortcomings: Cannot make Argo CD forget a resource (Prune=false) that was removed from git, need to remove the label. 92 | * Non-Git channels cannot be created in the same namespace 93 | * Add my kustomizations to the content list below. 94 | 95 | ## References 96 | 97 | To create this repo, I drew ideas and inspiration from: 98 | 99 | * https://github.com/PixelJonas/cluster-gitops 100 | * https://github.com/gnunn-gitops/cluster-config 101 | * https://github.com/christianh814/openshift-cluster-config 102 | * https://github.com/kasuboski/k8s-gitops 103 | * https://github.com/dgoodwin/openshift4-gitops 104 | * https://github.com/siamaksade/openshift-gitops-getting-started 105 | * https://github.com/sabre1041/rhacm-argocd 106 | * https://github.com/christianh814/gitops-examples 107 | * https://github.com/redhat-edge-computing/blueprint-management-hub 108 | 109 | Content that can be installed on the cluster via Argo CD: 110 | 111 | * https://github.com/redhat-canada-gitops/catalog 112 | * https://github.com/AlyIbrahim/openshift-add-ons 113 | * https://github.com/hornjason/argocd-lab 114 | -------------------------------------------------------------------------------- /aggregates/local-cluster-cluster-config/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | bases: 5 | - ../../manifests/apiserver 6 | - ../../manifests/auth 7 | - ../../manifests/ingress 8 | - ../../manifests/monitoring/base 9 | - ../../manifests/users 10 | -------------------------------------------------------------------------------- /aggregates/local-cluster-deploy-mycluster/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | bases: 5 | - ../../manifests/managed-clusters/mycluster 6 | -------------------------------------------------------------------------------- /aggregates/mycluster-cluster-config/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | bases: 5 | - ../../manifests/apiserver 6 | - ../../manifests/auth 7 | - ../../manifests/ingress 8 | - ../../manifests/monitoring/overlays/infra-nodes 9 | - ../../manifests/users 10 | -------------------------------------------------------------------------------- /applications/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | bases: 5 | - local-cluster 6 | - mycluster 7 | -------------------------------------------------------------------------------- /applications/local-cluster/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | namespace: openshift-gitops 5 | 6 | resources: 7 | - local-cluster-appproj.yaml 8 | - local-cluster-cluster-config-app.yaml 9 | - local-cluster-deploy-mycluster-app.yaml 10 | -------------------------------------------------------------------------------- /applications/local-cluster/local-cluster-appproj.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: AppProject 3 | metadata: 4 | name: local-cluster 5 | spec: 6 | clusterResourceWhitelist: 7 | - group: '*' 8 | kind: '*' 9 | destinations: 10 | - namespace: '*' 11 | name: local-cluster 12 | server: '*' 13 | sourceRepos: 14 | - '*' 15 | -------------------------------------------------------------------------------- /applications/local-cluster/local-cluster-cluster-config-app.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: Application 3 | metadata: 4 | name: local-cluster-cluster-config 5 | spec: 6 | destination: 7 | name: local-cluster 8 | project: local-cluster 9 | source: 10 | path: aggregates/local-cluster-cluster-config 11 | repoURL: https://github.com/noseka1/multicluster-management-rhacm-argocd 12 | targetRevision: master 13 | syncPolicy: 14 | automated: 15 | prune: false 16 | selfHeal: true 17 | -------------------------------------------------------------------------------- /applications/local-cluster/local-cluster-deploy-mycluster-app.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: Application 3 | metadata: 4 | name: local-cluster-deploy-mycluster 5 | spec: 6 | destination: 7 | name: local-cluster 8 | project: local-cluster 9 | source: 10 | path: aggregates/local-cluster-deploy-mycluster 11 | repoURL: https://github.com/noseka1/multicluster-management-rhacm-argocd 12 | targetRevision: master 13 | syncPolicy: 14 | automated: 15 | prune: false 16 | selfHeal: true 17 | -------------------------------------------------------------------------------- /applications/mycluster/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | namespace: openshift-gitops 5 | 6 | resources: 7 | - mycluster-appproj.yaml 8 | - mycluster-cluster-config-app.yaml 9 | -------------------------------------------------------------------------------- /applications/mycluster/mycluster-appproj.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: AppProject 3 | metadata: 4 | name: mycluster 5 | spec: 6 | clusterResourceWhitelist: 7 | - group: '*' 8 | kind: '*' 9 | destinations: 10 | - namespace: '*' 11 | name: mycluster 12 | server: '*' 13 | sourceRepos: 14 | - '*' 15 | -------------------------------------------------------------------------------- /applications/mycluster/mycluster-cluster-config-app.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: Application 3 | metadata: 4 | name: mycluster-cluster-config 5 | spec: 6 | destination: 7 | name: mycluster 8 | project: mycluster 9 | source: 10 | path: aggregates/mycluster-cluster-config 11 | repoURL: https://github.com/noseka1/multicluster-management-rhacm-argocd 12 | targetRevision: master 13 | syncPolicy: 14 | automated: 15 | prune: false 16 | selfHeal: true 17 | -------------------------------------------------------------------------------- /bootstrap/argocd-apps/argocd-apps-app.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: app.k8s.io/v1beta1 2 | kind: Application 3 | metadata: 4 | name: argocd-apps 5 | spec: {} 6 | -------------------------------------------------------------------------------- /bootstrap/argocd-apps/argocd-apps-appsub.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | annotations: 5 | apps.open-cluster-management.io/github-path: applications 6 | apps.open-cluster-management.io/reconcile-option: replace 7 | name: argocd-apps 8 | spec: 9 | channel: openshift-gitops/argocd-apps 10 | placement: 11 | placementRef: 12 | name: argocd-apps 13 | kind: PlacementRule 14 | -------------------------------------------------------------------------------- /bootstrap/argocd-apps/argocd-apps-channel.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Channel 3 | metadata: 4 | name: argocd-apps 5 | spec: 6 | type: Git 7 | pathname: https://github.com/noseka1/multicluster-management-rhacm-argocd 8 | -------------------------------------------------------------------------------- /bootstrap/argocd-apps/argocd-apps-placementrule.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: argocd-apps 5 | spec: 6 | clusters: 7 | - name: local-cluster 8 | -------------------------------------------------------------------------------- /bootstrap/argocd-apps/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | namespace: openshift-gitops 5 | 6 | resources: 7 | - argocd-apps-appsub.yaml 8 | - argocd-apps-app.yaml 9 | - argocd-apps-channel.yaml 10 | - argocd-apps-placementrule.yaml 11 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/custom-kubernetes-token-deployable.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Deployable 3 | metadata: 4 | name: custom-kubernetes-token 5 | namespace: external-secrets-deployable 6 | spec: 7 | channels: 8 | - external-secrets-ns 9 | template: 10 | apiVersion: v1 11 | kind: Secret 12 | metadata: 13 | name: custom-kubernetes-token 14 | data: 15 | # REPLACE this serviceaccount token with a token that can authenticate against HashiCorp Vault. 16 | # You can get this token by running this command against the RHACM Hub cluster (remember to replace 17 | # the serviceaccount namespace and name values with the serviceaccount that was granted persmissions 18 | # to retrieve secrets from Vault): 19 | # oc sa get-token -n | base64 -w 0 20 | token: ZXlKaGJHY2lPaUpTVXpJMU5pSXNJbXRwWkNJNklrMXNabEJSY2kxMU5sSjRhVzlYTFd4M2EyWlViMVJEYW5OQldXaFNZbFJRTUY5QlFVczNRbkZWUzAwaWZRLmV5SnBjM01pT2lKcmRXSmxjbTVsZEdWekwzTmxjblpwWTJWaFkyTnZkVzUwSWl3aWEzVmlaWEp1WlhSbGN5NXBieTl6WlhKMmFXTmxZV05qYjNWdWRDOXVZVzFsYzNCaFkyVWlPaUpsZUhSbGNtNWhiQzF6WldOeVpYUnpJaXdpYTNWaVpYSnVaWFJsY3k1cGJ5OXpaWEoyYVdObFlXTmpiM1Z1ZEM5elpXTnlaWFF1Ym1GdFpTSTZJbVY0ZEdWeWJtRnNMWE5sWTNKbGRITXRhM1ZpWlhKdVpYUmxjeTFsZUhSbGNtNWhiQzF6WldOeVpYUnpMWFJ2YTJWdUxYcHNjblJ0SWl3aWEzVmlaWEp1WlhSbGN5NXBieTl6WlhKMmFXTmxZV05qYjNWdWRDOXpaWEoyYVdObExXRmpZMjkxYm5RdWJtRnRaU0k2SW1WNGRHVnlibUZzTFhObFkzSmxkSE10YTNWaVpYSnVaWFJsY3kxbGVIUmxjbTVoYkMxelpXTnlaWFJ6SWl3aWEzVmlaWEp1WlhSbGN5NXBieTl6WlhKMmFXTmxZV05qYjNWdWRDOXpaWEoyYVdObExXRmpZMjkxYm5RdWRXbGtJam9pWkdRMVlUSm1aamN0WmpFM1ppMDBZVGt6TFdKaFl6TXRNelUwWkRabFpUWmlOV1ZoSWl3aWMzVmlJam9pYzNsemRHVnRPbk5sY25acFkyVmhZMk52ZFc1ME9tVjRkR1Z5Ym1Gc0xYTmxZM0psZEhNNlpYaDBaWEp1WVd3dGMyVmpjbVYwY3kxcmRXSmxjbTVsZEdWekxXVjRkR1Z5Ym1Gc0xYTmxZM0psZEhNaWZRLm1GeGFTUWFxLUJfWUFPUXhSd2twOWZpc0t2QUVSSWhRQUFTUDc4Qmp2ZGtmVmZXUTlWYlJJNUNXZ3E2VFdMT0pMZnBBTVAtcHFSdnlEWVJTWVAyYkNFUkk1R1dBMjY4NEFTX1o5OVlyMWlBamNrb2E0WHRJSUF0QmlIRkR3RU1OVDBhVV85dV92eEktNlpxOXhxa19zeko5cjN0SDhHS0kwVzNZTWs4OVgzdFlBclFjUXYwSnZJa25WcnpTc0ZCdjJ5Wm82XzJ4MFRhTnJvMFFhdnBvX0ZFeHNScHdmbGVHQnloX0ZreGI5amhObnM4SEllMmdLM2tnWDNId2VpeG9sRWdSLWFEN2lNMEVTRUpCV2pNLTdwWHpLZXg4VDBXM3BSSGJfRFN3c0cwSmQ2WE14S1laYnB2X2dkbFhTQ0hCSy1XbldLbUNsd 21 | type: Opaque 22 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-app.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: app.k8s.io/v1beta1 2 | kind: Application 3 | metadata: 4 | name: external-secrets 5 | namespace: external-secrets 6 | spec: {} 7 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-deployable-ns.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: external-secrets-deployable 5 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-helm-appsub.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | annotations: 5 | apps.open-cluster-management.io/reconcile-option: replace 6 | name: external-secrets-helm 7 | namespace: external-secrets 8 | spec: 9 | channel: external-secrets-helm-channel/external-secrets-helm 10 | # Chart name 11 | package: kubernetes-external-secrets 12 | packageFilter: 13 | # Chart version 14 | version: 6.3.0 15 | packageOverrides: 16 | - packageName: kubernetes-external-secrets 17 | # Chart release name 18 | packageAlias: external-secrets 19 | packageOverrides: 20 | # Release values 21 | - path: spec 22 | value: 23 | image: 24 | repository: quay.io/noseka1/kubernetes-external-secrets 25 | tag: 6.3.0-patch1 26 | pullPolicy: Always 27 | env: 28 | LOG_LEVEL: debug 29 | # REPLACE this URL with a correct HashiCorp Vault URL 30 | VAULT_ADDR: https://vault-vault.apps.cluster-cbb5.sandbox1118.opentlc.com 31 | DEFAULT_VAULT_MOUNT_POINT: kubernetes 32 | # This role must exist in Vault. This role must grant access to secret data 33 | # See also https://www.vaultproject.io/docs/auth/kubernetes 34 | DEFAULT_VAULT_ROLE: external-secrets 35 | CUSTOM_KUBERNETES_TOKEN_PATH: /mnt/token 36 | filesFromSecret: 37 | token: 38 | mountPath: /mnt 39 | secret: custom-kubernetes-token 40 | serviceMonitor: 41 | enabled: true 42 | namespace: external-secrets 43 | placement: 44 | placementRef: 45 | name: external-secrets 46 | kind: PlacementRule 47 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-helm-channel-ns.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: external-secrets-helm-channel 5 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-helm-channel.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Channel 3 | metadata: 4 | name: external-secrets-helm 5 | namespace: external-secrets-helm-channel 6 | spec: 7 | type: HelmRepo 8 | pathname: https://external-secrets.github.io/kubernetes-external-secrets 9 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-ns-appsub.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | annotations: 5 | apps.open-cluster-management.io/reconcile-option: replace 6 | name: external-secrets-ns 7 | namespace: external-secrets 8 | spec: 9 | channel: external-secrets-ns-channel/external-secrets-ns 10 | placement: 11 | placementRef: 12 | name: external-secrets 13 | kind: PlacementRule 14 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-ns-channel-ns.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: external-secrets-ns-channel 5 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-ns-channel.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Channel 3 | metadata: 4 | name: external-secrets-ns 5 | namespace: external-secrets-ns-channel 6 | spec: 7 | type: Namespace 8 | pathname: external-secrets-deployable 9 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-ns.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: external-secrets 5 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-placementrule.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: external-secrets 5 | namespace: external-secrets 6 | spec: 7 | clusterConditions: 8 | - type: ManagedClusterConditionAvailable 9 | status: "True" 10 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/external-secrets-test-deployable.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Deployable 3 | metadata: 4 | name: external-secrets-test 5 | namespace: external-secrets-deployable 6 | spec: 7 | channels: 8 | - external-secrets-ns 9 | template: 10 | apiVersion: kubernetes-client.io/v1 11 | kind: ExternalSecret 12 | metadata: 13 | name: external-secrets-test 14 | spec: 15 | backendType: vault 16 | kvVersion: 2 17 | data: 18 | - name: testkey 19 | key: kv/data/mysecret 20 | property: testkey 21 | -------------------------------------------------------------------------------- /bootstrap/external-secrets/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - custom-kubernetes-token-deployable.yaml 6 | - external-secrets-app.yaml 7 | - external-secrets-deployable-ns.yaml 8 | - external-secrets-helm-appsub.yaml 9 | - external-secrets-helm-channel-ns.yaml 10 | - external-secrets-helm-channel.yaml 11 | - external-secrets-ns-appsub.yaml 12 | - external-secrets-ns-channel-ns.yaml 13 | - external-secrets-ns-channel.yaml 14 | - external-secrets-ns.yaml 15 | - external-secrets-placementrule.yaml 16 | - external-secrets-test-deployable.yaml 17 | -------------------------------------------------------------------------------- /bootstrap/gitops-namespace/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - openshift-gitops-ns.yaml 6 | -------------------------------------------------------------------------------- /bootstrap/gitops-namespace/openshift-gitops-ns.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: openshift-gitops 5 | -------------------------------------------------------------------------------- /bootstrap/gitops-operator/gitops-operator-app.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: app.k8s.io/v1beta1 2 | kind: Application 3 | metadata: 4 | name: gitops-operator 5 | spec: {} 6 | -------------------------------------------------------------------------------- /bootstrap/gitops-operator/gitops-operator-appsub.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | annotations: 5 | apps.open-cluster-management.io/github-path: manifests/gitops-operator 6 | apps.open-cluster-management.io/reconcile-option: replace 7 | name: gitops-operator 8 | spec: 9 | channel: openshift-gitops/gitops-operator 10 | placement: 11 | placementRef: 12 | name: gitops-operator 13 | kind: PlacementRule 14 | -------------------------------------------------------------------------------- /bootstrap/gitops-operator/gitops-operator-channel.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Channel 3 | metadata: 4 | name: gitops-operator 5 | spec: 6 | type: Git 7 | pathname: https://github.com/noseka1/multicluster-management-rhacm-argocd 8 | -------------------------------------------------------------------------------- /bootstrap/gitops-operator/gitops-operator-placementrule.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: gitops-operator 5 | spec: 6 | clusters: 7 | - name: local-cluster 8 | -------------------------------------------------------------------------------- /bootstrap/gitops-operator/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | namespace: openshift-gitops 5 | 6 | resources: 7 | - gitops-operator-appsub.yaml 8 | - gitops-operator-app.yaml 9 | - gitops-operator-channel.yaml 10 | - gitops-operator-placementrule.yaml 11 | -------------------------------------------------------------------------------- /check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | find . -name '*.yaml' | while read FILE; do 4 | BASE_NAME=$(basename $FILE) 5 | if [ "$BASE_NAME" = kustomization.yaml ]; then 6 | continue 7 | fi 8 | OBJECT_NAME=$(echo $BASE_NAME | sed -e 's/\(.*\)-[a-z0-9]\+\.yaml/\1/') 9 | if ! grep " name: $OBJECT_NAME" $FILE 1>/dev/null; then 10 | echo Error: $FILE 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /docs/diagrams/multi_cluster_management_1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
Hub cluster
Hub cluster
Argo CD
Argo CD
HashiCorp Vault
HashiCorp Vault
Managed cluster
Managed cluster
GoDaddy External Secrets
GoDaddy External Secrets
RHACM
RHACM
Deploy clusters
Deploy External Secrets
Deploy clu...
Configure clusters (GitOps)
Configure...
Provide secrets
Provide se...
RHACM Agent
RHACM Agent
Kubernetes API
Kubernetes API
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /docs/diagrams/multi_cluster_management_2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
Hub cluster
Hub cluster
Provide secrets
Provide secrets
HashiCorp Vault Primary
HashiCorp Vault Primary
Managed cluster
Managed cluster
Provide secrets
Provide secrets
HashiCorp Vault Secondary
HashiCorp Vault Secondary
RHACM
RHACM
Deploy clusters
Deploy External Secrets
Deploy clu...
Replicate secrets
Replicate...
RHACM Agent
RHACM Agent
Configure cluster (GitOps)
Configure cluster (GitOps)
Argo CD Local
Argo CD Local
GoDaddy External Secrets
GoDaddy External Secrets
Kubernetes API
Kubernetes API
GoDaddy External Secrets
GoDaddy External Secrets
Configure cluster (GitOps)
Configure cluster (GitOps)
Argo CD Local
Argo CD Local
Kubernetes API
Kubernetes API
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /docs/diagrams/multi_cluster_management_3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
Hub cluster
Hub cluster
Provide secrets
Provide secrets
HashiCorp Vault Primary
HashiCorp Vault Primary
Managed cluster
Managed cluster
Provide secrets
Provide secrets
HashiCorp Vault Secondary
HashiCorp Vault Secondary
RHACM
RHACM
Deploy clusters
Deploy External Secrets
Deploy clu...
Replicate secrets
Replicate...
RHACM Agent
RHACM Agent
Configure cluster (GitOps)
Configure cluster (GitOps)
Argo CD Local
Argo CD Local
GoDaddy External Secrets
GoDaddy External Secrets
Kubernetes API
Kubernetes API
Submariner Broker
Submariner Broker
Submariner Gateway Engine
Submariner Gateway Engine
Service Mesh (Istio)
Control plane
Service Mesh (Istio)...
Service Mesh (Istio)
Data plane
Service Mesh (Istio)...
GoDaddy External Secrets
GoDaddy External Secrets
Configure cluster (GitOps)
Configure cluster (GitOps)
Argo CD Local
Argo CD Local
Kubernetes API
Kubernetes API
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /docs/diagrams/multi_cluster_management_in_action.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
oc apply -k
boostrap/argocd-apps
oc ap...
argocd-apps
Subscription
argocd-apps...
local-cluster-cluster-config
Application
local-cluster-cluste...
local-cluster-deploy-mycluster
Application
local-cluster-deploy...
local-cluster AppProject
local-cluster AppProject
mycluster-cluster-config
Application
mycluster-cluster-co...
mycluster AppProject
mycluster AppProject
cluster
APIServer
cluster...
mycluster
ClusterDeployment
mycluster...
mycluster
ManagedCluster
mycluster...
...
...
...
...
local-cluster (Hub cluster)
local-cluster (Hub clus...
cluster
APIServer
cluster...
...
...
mycluster
mycluster
1
1
2
2
3
3
4
4
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /docs/diagrams/multi_cluster_management_secrets_management_bootstrap.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
external-secrets Channel (type Namespace)
external-secrets Channe...
custom-kubernetes-token Deployable
custom-kubernetes-token...
custom-kubernetes-token Secret
custom-kubernetes-tok...
Hub cluster
Hub cluster
RHACM
RHACM
Managed cluster
Managed cluster
external-secrets
Namespace
external-secrets...
Mount as volume
Mount as volume
kubernetes-external-secrets Pod
kubernetes-external-secret...
custom-kubernetes-token Secret
custom-kubernetes-token Se...
Deploy external-secrets
using a Helm chart
Deploy external-secrets...
Create token
used by kubernetes-external-secrets
to authenticate to HashiCorp Vault
Create token...
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /docs/diagrams/multi_cluster_management_secrets_management_in_action.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
Hub cluster
Hub cluster
Argo CD
Argo CD
HashiCorp Vault
HashiCorp Vault
Managed cluster
Managed cluster
ExternalSecret
ExternalSecret
Fetch secrets data
(authentication using
the custom-kubernetes-token)
Fetch secrets data...
Create
Create
kubernetes-external-secrets Pod
kubernetes-external-secrets Pod
Secret
Secret
Deploy ExternalSecret object
Deploy ExternalSecret object
Viewer does not support full SVG 1.1
-------------------------------------------------------------------------------- /docs/external-secrets/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/external-secrets/kubernetes-external-secrets:6.4.0 2 | 3 | COPY custom_kubernetes_token_path.diff /tmp 4 | USER root 5 | # Allow External Secrets operator to authenticate against a remote Kubernetes cluster 6 | RUN cd /app && patch -p1 < /tmp/custom_kubernetes_token_path.diff 7 | USER 1000 8 | -------------------------------------------------------------------------------- /docs/external-secrets/README.md: -------------------------------------------------------------------------------- 1 | # Allowing External Secrets to fetch secret data from HashiCorp Vault that is running on a remote Kubernetes cluster 2 | 3 | External Secrets assume that HashiCorp Vault instance is running on the same Kubernetes cluster as the External Secrets operator. To allow External Secrets to fetch secret data from Vault running on a remote Kubernetes cluster, the External Secrets need to use an authentication token that allows it to authenticate against the remote Kubernetes cluster. The location from where the External Secrets operator reads the authentication token was hard-coded in the operator. 4 | 5 | The External Secrets Dockerfile in this directory modifies the existing code to allow External Secrets to grab a token from an arbitrary location specified by the `CUSTOM_KUBERNETES_TOKEN_PATH` environment variable. The idea is that a secret that contains the remote authentication token will be mounted at this location. 6 | 7 | Build the custom External Secrets container image: 8 | 9 | ``` 10 | $ podman build \ 11 | --tag kubernetes-external-secrets:6.4.0-patch1 \ 12 | . 13 | ``` 14 | 15 | Push the image to the image registry. For example: 16 | 17 | ``` 18 | $ podman push kubernetes-external-secrets:6.4.0-patch1 quay.io/noseka1/kubernetes-external-secrets:6.4.0-patch1 19 | ``` 20 | 21 | Deploy a secret that contains a token that allows authenticating against a remote Kubernetes cluster: 22 | 23 | ``` 24 | apiVersion: v1 25 | kind: Secret 26 | metadata: 27 | name: custom-kubernetes-token 28 | data: 29 | # Replace this token with a token that can authenticate against the remote Kubernetes cluster. You can get 30 | # this token by running the following command against the remote Kubernetes cluster, for example: 31 | # oc sa get-token -n | base64 -w 0 32 | token: ZXlKaGJHY2lPaUpTVXpJMU5pSXNJbXRwWkNJNk ... 33 | type: Opaque 34 | ``` 35 | 36 | When deploying the External Secrets operator using a [Helm Chart](https://github.com/external-secrets/kubernetes-external-secrets/tree/master/charts/kubernetes-external-secrets), you can leverage the custom image by setting the Chart's `values.yaml` to something like this: 37 | 38 | ``` 39 | image: 40 | repository: quay.io/noseka1/kubernetes-external-secrets 41 | tag: 6.4.0-patch1 42 | pullPolicy: Always 43 | env: 44 | LOG_LEVEL: debug 45 | VAULT_ADDR: https://vault-vault.apps.cluster-7d77.sandbox828.opentlc.com 46 | DEFAULT_VAULT_MOUNT_POINT: kubernetes 47 | DEFAULT_VAULT_ROLE: external-secrets 48 | CUSTOM_KUBERNETES_TOKEN_PATH: /mnt/token 49 | filesFromSecret: 50 | token: 51 | mountPath: /mnt 52 | secret: custom-kubernetes-token 53 | ``` 54 | 55 | Helm will deploy you custom External Secrets image. The External Secrets operator will read the Kubernetes authentication token from the file `/mnt/token`. 56 | -------------------------------------------------------------------------------- /docs/external-secrets/custom_kubernetes_token_path.diff: -------------------------------------------------------------------------------- 1 | diff --git i/lib/backends/vault-backend.js w/lib/backends/vault-backend.js 2 | index 73cff2c..0618de7 100644 3 | --- i/lib/backends/vault-backend.js 4 | +++ w/lib/backends/vault-backend.js 5 | @@ -26,7 +26,15 @@ class VaultBackend extends KVBackend { 6 | _fetchServiceAccountToken () { 7 | if (!this._serviceAccountToken) { 8 | const fs = require('fs') 9 | - this._serviceAccountToken = fs.readFileSync('/var/run/secrets/kubernetes.io/serviceaccount/token', 'utf8') 10 | + // External Secrets assume that HashiCorp Vault instance is running on the same Kubernetes cluster as the External 11 | + // Secrets operator. To allow External Secrets to fetch secret data from Vault running on a remote Kubernetes 12 | + // cluster, the External Secrets need to use an authentication token that allows it to authenticate against the 13 | + // remote Kubernetes cluster. The location from where the External Secrets operator reads the authentication token 14 | + // was hard-coded in the operator. Modifying the existing code to allow External Secrets to grab a token from an 15 | + // arbitrary location specified by the CUSTOM_KUBERNETES_TOKEN_PATH environment variable. The idea is that a 16 | + // secret that contains the remote authentication token will be mounted at this location. 17 | + const tokenPath = process.env.CUSTOM_KUBERNETES_TOKEN_PATH || '/var/run/secrets/kubernetes.io/serviceaccount/token' 18 | + this._serviceAccountToken = fs.readFileSync(tokenPath, 'utf8') 19 | } 20 | return this._serviceAccountToken 21 | } 22 | -------------------------------------------------------------------------------- /manifests/apiserver/cluster-apiserver.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: config.openshift.io/v1 2 | kind: APIServer 3 | metadata: 4 | annotations: 5 | argocd.argoproj.io/sync-options: Prune=false 6 | name: cluster 7 | spec: 8 | audit: 9 | # You can control the amount of information that is logged to the API server audit logs by choosing 10 | # the audit log policy profile to use. Set audit log policy profile, choose one of: 11 | # Default, WriteRequestBodies, AllRequestBodies 12 | # See also: https://docs.openshift.com/container-platform/4.6/security/audit-log-policy-config.html 13 | profile: Default 14 | -------------------------------------------------------------------------------- /manifests/apiserver/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - cluster-apiserver.yaml 6 | -------------------------------------------------------------------------------- /manifests/auth/cluster-oauth.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: config.openshift.io/v1 2 | kind: OAuth 3 | metadata: 4 | annotations: 5 | argocd.argoproj.io/sync-options: Prune=false 6 | name: cluster 7 | spec: 8 | templates: {} 9 | -------------------------------------------------------------------------------- /manifests/auth/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - cluster-oauth.yaml 6 | -------------------------------------------------------------------------------- /manifests/gitops-operator/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - openshift-gitops-sub.yaml 6 | -------------------------------------------------------------------------------- /manifests/gitops-operator/openshift-gitops-sub.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: operators.coreos.com/v1alpha1 2 | kind: Subscription 3 | metadata: 4 | name: openshift-gitops 5 | namespace: openshift-operators 6 | spec: 7 | channel: preview 8 | installPlanApproval: Automatic 9 | name: openshift-gitops-operator 10 | source: redhat-operators 11 | sourceNamespace: openshift-marketplace 12 | -------------------------------------------------------------------------------- /manifests/ingress/default-ingresscontroller.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: operator.openshift.io/v1 2 | kind: IngressController 3 | metadata: 4 | annotations: 5 | argocd.argoproj.io/sync-options: Prune=false 6 | name: default 7 | namespace: openshift-ingress-operator 8 | spec: 9 | # Enable access logs. Send access logs to the stdout of a side-car container. 10 | # The alternative is to send the logs to a remote location via syslog. 11 | # See also: 12 | # https://docs.openshift.com/container-platform/4.6/networking/ingress-operator.html#nw-configure-ingress-access-logging_configuring-ingress 13 | logging: 14 | access: 15 | destination: 16 | type: Container 17 | -------------------------------------------------------------------------------- /manifests/ingress/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - default-ingresscontroller.yaml 6 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - mycluster-clusterdeployment.yaml 6 | - mycluster-infra-machinepool.yaml 7 | - mycluster-klusterletaddonconfig.yaml 8 | - mycluster-managedclusterinfo.yaml 9 | - mycluster-managedcluster.yaml 10 | - mycluster-worker-machinepool.yaml 11 | - secrets/mycluster-aws-creds-externalsecret.yaml 12 | - secrets/mycluster-install-config-externalsecret.yaml 13 | - secrets/mycluster-pull-secret-externalsecret.yaml 14 | - secrets/mycluster-ssh-private-key-externalsecret.yaml 15 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/mycluster-clusterdeployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: hive.openshift.io/v1 2 | kind: ClusterDeployment 3 | metadata: 4 | name: mycluster 5 | namespace: mycluster 6 | labels: 7 | cloud: AWS 8 | region: us-east-2 9 | vendor: OpenShift 10 | spec: 11 | # REPLACE 12 | baseDomain: sandbox1752.opentlc.com 13 | clusterName: mycluster 14 | controlPlaneConfig: 15 | servingCertificates: {} 16 | installAttemptsLimit: 2 17 | platform: 18 | aws: 19 | credentialsSecretRef: 20 | name: mycluster-aws-creds 21 | region: us-east-2 22 | provisioning: 23 | installConfigSecretRef: 24 | name: mycluster-install-config 25 | sshPrivateKeySecretRef: 26 | name: mycluster-ssh-private-key 27 | imageSetRef: 28 | #quay.io/openshift-release-dev/ocp-release:4.7.4-x86_64 29 | name: img4.7.4-x86-64-appsub 30 | # openshift-install may need to download RHCOS images from the public Web. 31 | # If the Hub cluster needs to use a corporate proxy to access public Web 32 | # then define it here: 33 | #installerEnv: 34 | #- name: HTTPS_PROXY 35 | # value: proxy.example.com:8080 36 | #- name: NO_PROXY 37 | # value: 10.0.0.0/8,*.example.com 38 | pullSecretRef: 39 | name: mycluster-pull-secret 40 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/mycluster-infra-machinepool.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: hive.openshift.io/v1 2 | kind: MachinePool 3 | metadata: 4 | name: mycluster-infra 5 | namespace: mycluster 6 | spec: 7 | clusterDeploymentRef: 8 | name: mycluster 9 | name: infra 10 | platform: 11 | aws: 12 | rootVolume: 13 | iops: 100 14 | size: 100 15 | type: gp2 16 | type: m5.xlarge 17 | labels: 18 | node-role.kubernetes.io/infra: "" 19 | taints: 20 | - effect: NoSchedule 21 | key: node-role.kubernetes.io/infra 22 | replicas: 3 23 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/mycluster-klusterletaddonconfig.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: agent.open-cluster-management.io/v1 2 | kind: KlusterletAddonConfig 3 | metadata: 4 | name: mycluster 5 | namespace: mycluster 6 | spec: 7 | clusterName: mycluster 8 | clusterNamespace: mycluster 9 | clusterLabels: 10 | cloud: Amazon 11 | vendor: OpenShift 12 | applicationManager: 13 | enabled: true 14 | argocdCluster: true 15 | policyController: 16 | enabled: true 17 | searchCollector: 18 | enabled: true 19 | certPolicyController: 20 | enabled: true 21 | iamPolicyController: 22 | enabled: true 23 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/mycluster-managedcluster.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cluster.open-cluster-management.io/v1 2 | kind: ManagedCluster 3 | metadata: 4 | labels: 5 | cloud: Amazon 6 | region: us-east-2 7 | name: mycluster 8 | vendor: OpenShift 9 | name: mycluster 10 | spec: 11 | hubAcceptsClient: true 12 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/mycluster-managedclusterinfo.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: internal.open-cluster-management.io/v1beta1 2 | kind: ManagedClusterInfo 3 | metadata: 4 | # This object is created by RHACM and it is created with a app.kubernetes.io/instance label attached to it. 5 | # RHACM adds this label to the ManagedClusterInfo object likely because a parent object was labeled using 6 | # this label and the labels are just copied to the child objects. The parent object was labeled by Argo CD. 7 | # The app.kubernetes.io/instance label is used by Argo CD to mark objects under its management. If the object 8 | # has this label, Argo CD will assume that it is an object that it manages. Because this object didn't exist 9 | # in the git repository, Argo CD displayed this object as out of sync. The purpose of this ManagedClusterInfo 10 | # object is to avoid Argo CD showing this object as out of sync. 11 | name: mycluster 12 | namespace: mycluster 13 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/mycluster-worker-machinepool.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: hive.openshift.io/v1 2 | kind: MachinePool 3 | metadata: 4 | name: mycluster-worker 5 | namespace: mycluster 6 | spec: 7 | clusterDeploymentRef: 8 | name: mycluster 9 | name: worker 10 | platform: 11 | aws: 12 | rootVolume: 13 | iops: 100 14 | size: 100 15 | type: gp2 16 | type: m5.xlarge 17 | autoscaling: 18 | minReplicas: 3 19 | maxReplicas: 10 20 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/secrets/mycluster-aws-creds-externalsecret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kubernetes-client.io/v1 2 | kind: ExternalSecret 3 | metadata: 4 | name: mycluster-aws-creds 5 | namespace: mycluster 6 | spec: 7 | backendType: vault 8 | kvVersion: 2 9 | template: 10 | type: Opaque 11 | data: 12 | - name: aws_access_key_id 13 | key: kv/data/mycluster 14 | property: aws_access_key_id 15 | - name: aws_secret_access_key 16 | key: kv/data/mycluster 17 | property: aws_secret_access_key 18 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/secrets/mycluster-install-config-externalsecret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kubernetes-client.io/v1 2 | kind: ExternalSecret 3 | metadata: 4 | name: mycluster-install-config 5 | namespace: mycluster 6 | spec: 7 | backendType: vault 8 | kvVersion: 2 9 | template: 10 | type: Opaque 11 | data: 12 | - name: install-config.yaml 13 | key: kv/data/mycluster 14 | property: install-config.yaml 15 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/secrets/mycluster-pull-secret-externalsecret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kubernetes-client.io/v1 2 | kind: ExternalSecret 3 | metadata: 4 | name: mycluster-pull-secret 5 | namespace: mycluster 6 | spec: 7 | backendType: vault 8 | kvVersion: 2 9 | template: 10 | type: kubernetes.io/dockerconfigjson 11 | data: 12 | - name: .dockerconfigjson 13 | key: kv/data/mycluster 14 | property: pull_secret 15 | -------------------------------------------------------------------------------- /manifests/managed-clusters/mycluster/secrets/mycluster-ssh-private-key-externalsecret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kubernetes-client.io/v1 2 | kind: ExternalSecret 3 | metadata: 4 | name: mycluster-ssh-private-key 5 | namespace: mycluster 6 | spec: 7 | backendType: vault 8 | kvVersion: 2 9 | template: 10 | type: Opaque 11 | data: 12 | - name: ssh-privatekey 13 | key: kv/data/mycluster 14 | property: ssh-privatekey 15 | -------------------------------------------------------------------------------- /manifests/monitoring/base/cluster-monitoring-config-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | annotations: 5 | argocd.argoproj.io/sync-options: Prune=false 6 | name: cluster-monitoring-config 7 | data: 8 | config.yaml: |+ 9 | # Enable monitoring your own services 10 | techPreviewUserWorkload: 11 | enabled: true 12 | alertmanagerMain: 13 | nodeSelector: 14 | node-role.kubernetes.io/worker: "" 15 | volumeClaimTemplate: 16 | metadata: 17 | name: alertmanager 18 | spec: 19 | resources: 20 | requests: 21 | storage: 40Gi 22 | prometheusK8s: 23 | nodeSelector: 24 | node-role.kubernetes.io/worker: "" 25 | volumeClaimTemplate: 26 | metadata: 27 | name: prometheus 28 | spec: 29 | resources: 30 | requests: 31 | storage: 40Gi 32 | prometheusOperator: 33 | nodeSelector: 34 | node-role.kubernetes.io/worker: "" 35 | grafana: 36 | nodeSelector: 37 | node-role.kubernetes.io/worker: "" 38 | k8sPrometheusAdapter: 39 | nodeSelector: 40 | node-role.kubernetes.io/worker: "" 41 | kubeStateMetrics: 42 | nodeSelector: 43 | node-role.kubernetes.io/worker: "" 44 | telemeterClient: 45 | nodeSelector: 46 | node-role.kubernetes.io/worker: "" 47 | openshiftStateMetrics: 48 | nodeSelector: 49 | node-role.kubernetes.io/worker: "" 50 | thanosQuerier: 51 | nodeSelector: 52 | node-role.kubernetes.io/worker: "" 53 | -------------------------------------------------------------------------------- /manifests/monitoring/base/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | namespace: openshift-monitoring 5 | 6 | resources: 7 | - cluster-monitoring-config-configmap.yaml 8 | -------------------------------------------------------------------------------- /manifests/monitoring/overlays/infra-nodes/cluster-monitoring-config-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: cluster-monitoring-config 5 | data: 6 | config.yaml: |+ 7 | # Enable monitoring your own services 8 | techPreviewUserWorkload: 9 | enabled: true 10 | alertmanagerMain: 11 | nodeSelector: 12 | node-role.kubernetes.io/infra: "" 13 | tolerations: 14 | - effect: NoSchedule 15 | operator: Exists 16 | volumeClaimTemplate: 17 | metadata: 18 | name: alertmanager 19 | spec: 20 | resources: 21 | requests: 22 | storage: 40Gi 23 | prometheusK8s: 24 | nodeSelector: 25 | node-role.kubernetes.io/infra: "" 26 | tolerations: 27 | - effect: NoSchedule 28 | operator: Exists 29 | volumeClaimTemplate: 30 | metadata: 31 | name: prometheus 32 | spec: 33 | resources: 34 | requests: 35 | storage: 40Gi 36 | prometheusOperator: 37 | nodeSelector: 38 | node-role.kubernetes.io/infra: "" 39 | tolerations: 40 | - effect: NoSchedule 41 | operator: Exists 42 | grafana: 43 | nodeSelector: 44 | node-role.kubernetes.io/infra: "" 45 | tolerations: 46 | - effect: NoSchedule 47 | operator: Exists 48 | k8sPrometheusAdapter: 49 | nodeSelector: 50 | node-role.kubernetes.io/infra: "" 51 | tolerations: 52 | - effect: NoSchedule 53 | operator: Exists 54 | kubeStateMetrics: 55 | nodeSelector: 56 | node-role.kubernetes.io/infra: "" 57 | tolerations: 58 | - effect: NoSchedule 59 | operator: Exists 60 | telemeterClient: 61 | nodeSelector: 62 | node-role.kubernetes.io/infra: "" 63 | tolerations: 64 | - effect: NoSchedule 65 | operator: Exists 66 | openshiftStateMetrics: 67 | nodeSelector: 68 | node-role.kubernetes.io/infra: "" 69 | tolerations: 70 | - effect: NoSchedule 71 | operator: Exists 72 | thanosQuerier: 73 | nodeSelector: 74 | node-role.kubernetes.io/infra: "" 75 | tolerations: 76 | - effect: NoSchedule 77 | operator: Exists 78 | -------------------------------------------------------------------------------- /manifests/monitoring/overlays/infra-nodes/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | patchesStrategicMerge: 5 | - cluster-monitoring-config-configmap.yaml 6 | 7 | bases: 8 | - ../../base 9 | -------------------------------------------------------------------------------- /manifests/registry/base/cluster-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: imageregistry.operator.openshift.io/v1 2 | kind: Config 3 | metadata: 4 | annotations: 5 | argocd.argoproj.io/sync-options: Prune=false 6 | name: cluster 7 | spec: 8 | # Create a route to allow accessing the image registry from outside of OpenShift. 9 | defaultRoute: true 10 | # Operator will update the registry as configuration resources are updated 11 | managementState: Managed 12 | # Place the image registry pods on infra nodes. 13 | nodeSelector: 14 | node-role.kubernetes.io/worker: "" 15 | -------------------------------------------------------------------------------- /manifests/registry/base/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - cluster-config.yaml 6 | -------------------------------------------------------------------------------- /manifests/registry/overlays/rwo/cluster-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: imageregistry.operator.openshift.io/v1 2 | kind: Config 3 | metadata: 4 | name: cluster 5 | spec: 6 | # Number of desired image registry pods 7 | replicas: 1 8 | # Cannot use ReadWriteOnce access mode with RollingUpdate rollout strategy 9 | rolloutStrategy: Recreate 10 | # Configure persistent storage for the image registry. 11 | storage: 12 | managementState: Managed 13 | pvc: 14 | claim: registry 15 | s3: null 16 | -------------------------------------------------------------------------------- /manifests/registry/overlays/rwo/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | patchesStrategicMerge: 5 | - cluster-config.yaml 6 | 7 | resources: 8 | - registry-pvc.yaml 9 | 10 | bases: 11 | - ../../base 12 | -------------------------------------------------------------------------------- /manifests/registry/overlays/rwo/registry-pvc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | name: registry 5 | namespace: openshift-image-registry 6 | spec: 7 | accessModes: 8 | - ReadWriteOnce 9 | resources: 10 | requests: 11 | storage: 100Gi 12 | -------------------------------------------------------------------------------- /manifests/users/cluster-viewers-group-clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: cluster-viewers-group 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: ClusterRole 8 | name: view 9 | subjects: 10 | - apiGroup: rbac.authorization.k8s.io 11 | kind: Group 12 | name: cluster-viewers 13 | -------------------------------------------------------------------------------- /manifests/users/cluster-viewers-group.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: user.openshift.io/v1 2 | kind: Group 3 | metadata: 4 | name: cluster-viewers 5 | users: 6 | - developer 7 | -------------------------------------------------------------------------------- /manifests/users/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - cluster-viewers-group-clusterrolebinding.yaml 6 | - cluster-viewers-group.yaml 7 | --------------------------------------------------------------------------------