├── .gitignore ├── CONTRIBUTE.md ├── DCO ├── LICENSE ├── OWNER ├── README.md ├── SECURITY.md ├── ansible ├── README.md ├── keepalive │ ├── README.md │ ├── ansiblejob.yaml │ ├── kustomization.yaml │ ├── snow-keepalive-cronjob.yaml │ └── snow-keepalive-job.yaml ├── pacman │ ├── kustomization.yaml │ ├── mongo-deployment.yaml │ ├── mongo-pvc.yaml │ ├── mongo-service.yaml │ ├── pacman-deployment.yaml │ ├── pacman-f5-route.yaml │ ├── pacman-route.yaml │ ├── pacman-service.yaml │ ├── posthook │ │ └── f5-gslb-commit.yaml │ └── prehook │ │ └── create_snow_ticket.yaml └── subscription │ ├── application.yaml │ ├── channel.yaml │ ├── kustomization.yaml │ ├── namespace.yaml │ ├── placementrule.yaml │ └── subscription-nginx-placement.yaml ├── blueGreen ├── README.md ├── nginx │ ├── blue-ingress │ │ ├── ingress.yaml │ │ ├── kustomization.yaml │ │ └── service-blue.yaml │ ├── deployment │ │ ├── deployment.yaml │ │ └── kustomization.yaml │ └── green-ingress │ │ ├── ingress.yaml │ │ ├── kustomization.yaml │ │ └── service-green.yaml └── subscription │ ├── application.yaml │ ├── channel.yaml │ ├── kustomization.yaml │ ├── namespace.yaml │ ├── placementrule.yaml │ ├── subscription-nginx-blue.yaml │ ├── subscription-nginx-green.yaml │ ├── subscription-nginx-ingress-blue.yaml │ └── subscription-nginx-ingress-green.yaml ├── bma ├── BareMetalAssets │ ├── bmc-secret-dc01r3c1b3-powerflex390.yaml │ ├── bmc-secret-dc01r3c3b2-powerflex390.yaml │ ├── dc01r3c1b3-powerflex390.yaml │ └── dc01r3c3b2-powerflex390.yaml ├── README.md └── subscription │ ├── channel.yaml │ ├── kustomization.yaml │ ├── namespace.yaml │ └── subscription.yaml ├── book-import ├── app │ ├── deployment.yaml │ ├── route.yaml │ └── service.yaml └── subscription │ ├── application.yaml │ ├── channel.yaml │ ├── kustomization.yaml │ ├── namespace.yaml │ ├── placementrule.yaml │ └── subscription.yaml ├── cloud-provider ├── README.md ├── nginx │ ├── deployment-a-eu1.yaml │ ├── deployment-a-eu3.yaml │ ├── deployment-a-us1.yaml │ ├── deployment-a-us2.yaml │ ├── deployment-a-us3.yaml │ ├── deployment-a-uw1.yaml │ ├── deployment-az-cus.yaml │ ├── deployment-g-eu3.yaml │ ├── kustomization.yaml │ └── service.yaml └── subscription │ ├── application.yaml │ ├── channel.yaml │ ├── kustomization.yaml │ ├── namespace.yaml │ ├── placementrule-a-eu1.yaml │ ├── placementrule-a-eu3.yaml │ ├── placementrule-a-us1.yaml │ ├── placementrule-a-us2.yaml │ ├── placementrule-a-us3.yaml │ ├── placementrule-a-uw1.yaml │ ├── placementrule-az-cus.yaml │ ├── placementrule-g-eu3.yaml │ ├── subscription-provider-a-eu1.yaml │ ├── subscription-provider-a-eu3.yaml │ ├── subscription-provider-a-us1.yaml │ ├── subscription-provider-a-us2.yaml │ ├── subscription-provider-a-us3.yaml │ ├── subscription-provider-a-uw1.yaml │ ├── subscription-provider-az-cus.yaml │ └── subscription-provider-g-eu3.yaml ├── config-test ├── README.md ├── configmap │ └── configmap.yaml └── subscription │ ├── channel.yaml │ ├── kustomization.yaml │ ├── namespace.yaml │ └── subscription.yaml ├── placement ├── README.md ├── nginx │ ├── deployment.yaml │ ├── kustomization.yaml │ ├── route.yaml │ └── service.yaml └── subscription │ ├── application.yaml │ ├── channel.yaml │ ├── kustomization.yaml │ ├── namespace.yaml │ ├── placementrule.yaml │ └── subscription-nginx-placement.yaml └── policy ├── README.md ├── namespace ├── binding.yaml ├── kustomization.yaml ├── placementrule.yaml └── policy.yaml └── subscription ├── channel.yaml ├── kustomization.yaml ├── namespace.yaml └── subscription-policy.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | secret.yaml -------------------------------------------------------------------------------- /CONTRIBUTE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* 4 | 5 | - [Contributing guidelines](#contributing-guidelines) 6 | - [Contributions](#contributions) 7 | - [Certificate of Origin](#certificate-of-origin) 8 | - [Contributing A Patch](#contributing-a-patch) 9 | - [Issue and Pull Request Management](#issue-and-pull-request-management) 10 | - [Pre-check before submitting a PR](#pre-check-before-submitting-a-pr) 11 | - [Build images](#build-images) 12 | 13 | 14 | 15 | # Contributing guidelines 16 | 17 | ## Contributions 18 | 19 | All contributions to the repository must be submitted under the terms of the [Apache Public License 2.0](https://www.apache.org/licenses/LICENSE-2.0). 20 | 21 | ## Certificate of Origin 22 | 23 | By contributing to this project you agree to the Developer Certificate of 24 | Origin (DCO). This document was created by the Linux Kernel community and is a 25 | simple statement that you, as a contributor, have the legal right to make the 26 | contribution. See the [DCO](DCO) file for details. 27 | 28 | ## Contributing A Patch 29 | 30 | 1. Submit an issue describing your proposed change to the repo in question. 31 | 1. The [repo owners](OWNERS) will respond to your issue promptly. 32 | 1. Fork the desired repo, develop and test your code changes. 33 | 1. Submit a pull request. 34 | 35 | ## Issue and Pull Request Management 36 | 37 | Anyone may comment on issues and submit reviews for pull requests. However, in 38 | order to be assigned an issue or pull request, you must be a member of the 39 | [open-cluster-management](https://github.com/open-cluster-management) GitHub organization. 40 | 41 | Repo maintainers can assign you an issue or pull request by leaving a 42 | `/assign ` comment on the issue or pull request. 43 | 44 | Now, you can follow the [getting started guide](./README.md#getting-started) to work with the open-cluster-management hibernate-cronjob repository. 45 | -------------------------------------------------------------------------------- /DCO: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 1 Letterman Drive 6 | Suite D4700 7 | San Francisco, CA, 94129 8 | 9 | Everyone is permitted to copy and distribute verbatim copies of this 10 | license document, but changing it is not allowed. 11 | 12 | 13 | Developer's Certificate of Origin 1.1 14 | 15 | By making a contribution to this project, I certify that: 16 | 17 | (a) The contribution was created in whole or in part by me and I 18 | have the right to submit it under the open source license 19 | indicated in the file; or 20 | 21 | (b) The contribution is based upon previous work that, to the best 22 | of my knowledge, is covered under an appropriate open source 23 | license and I have the right under that license to submit that 24 | work with modifications, whether created in whole or in part 25 | by me, under the same open source license (unless I am 26 | permitted to submit under a different license), as indicated 27 | in the file; or 28 | 29 | (c) The contribution was provided directly to me by some other 30 | person who certified (a), (b) or (c) and I have not modified 31 | it. 32 | 33 | (d) I understand and agree that this project and the contribution 34 | are public and that a record of the contribution (including all 35 | personal information I submit with it, including my sign-off) is 36 | maintained indefinitely and may be redistributed consistent with 37 | this project or the open source license(s) involved. 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | -------------------------------------------------------------------------------- /OWNER: -------------------------------------------------------------------------------- 1 | approvers: 2 | - jnpacker 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This repository contains Red Hat Advanced Cluster Management examples of GitOps 2 | 3 | ## Tool Requirements 4 | - OpenShift CLI Version >= 4.3.0
_Needed for kustomize_ 5 | ```bash 6 | oc version 7 | ``` 8 | 9 | ## Examples 10 | 11 | 1. [Bare Metal Assets via gitops](bma/README.md) 12 | 2. [Blue-Green Application Management via gitops](blueGreen/README.md) 13 | 3. [Placement Rules example](placement/README.md) 14 | 4. [GitOps Policy example](policy/README.md) 15 | 16 | ### Help 17 | Contact me via GitHub 18 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Response 2 | 3 | If you've found a security issue that you'd like to disclose confidentially please contact Red Hat's Product Security team. 4 | Details at https://access.redhat.com/security/team/contact 5 | -------------------------------------------------------------------------------- /ansible/README.md: -------------------------------------------------------------------------------- 1 | # Demonstrate placement algorithm 2 | ## Tool Requirements 3 | - OpenShift CLI Version >= 4.3.0
_Needed for kustomize_ 4 | ```bash 5 | oc version 6 | ``` 7 | 8 | ## This example, allows you to demonstrate using an Ansible Pre & Post job. 9 | 1. Add the subscription to your Red Hat Advanced Cluster Management for Kubernetes HUB 10 | ``` 11 | clone https://github.com/open-cluster-management/demo-subscription-gitops.git 12 | oc apply -k demo-subscription-gitops/ansible/subscription/ 13 | ``` 14 | ### Using 15 | - Navigate to the Manage applications in the UI. Click the `nginx-ansible-demo` Application name. 16 | - View the Topology, look around, by default the application should have deployed to `vendor: OpenShift` clusters 17 | - Make adjustments directly in the Topology 18 | ```yaml 19 | clusterSelector: 20 | matchLabels: {} 21 | ``` 22 | -------------------------------------------------------------------------------- /ansible/keepalive/README.md: -------------------------------------------------------------------------------- 1 | # Creating a Service Now keep-alive using a ticket 2 | ## Modify the YAML 3 | 1. Update the `snow-keepalive-cronjob.yaml` update the `env` variables with the approriate, token, URL, job name, namespace and adjust the time to run, once every 24hrs 4 | 2. Do the same for `snow-keepalive-job.yaml` if you want to run the independent job 5 | 3. Apply the cronjob `oc -n NAMESPACE apply -k ansible/keepalive` where NAMESPACE is going to host your cronjob 6 | 4. Check on the cronjob `oc get cronjob`, this also creates an ansible job that is referenced for the `spec.extra_vars` values. 7 | 8 | 9 | ## env variables that you need to fill 10 | ```yaml 11 | TOWER_OAUTH_TOKEN # This is the token for accessing Ansible Tower 12 | TOWER_HOST # URL to the Ansible Tower 13 | TOWER_JOB_TEMPLATE_NAME # The name of the job template to use 14 | ANSIBLEJOB_NAMESPACE # Namespace where this cronjob is being created/run 15 | 16 | # Change these settings in snow-keepalive-cronjob.yaml and snow-keepalive-job.yaml 17 | ``` -------------------------------------------------------------------------------- /ansible/keepalive/ansiblejob.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: tower.ansible.com/v1alpha1 2 | kind: AnsibleJob 3 | metadata: 4 | name: snow-keepalive 5 | spec: 6 | extra_vars: 7 | appName: snow-keepalive-job 8 | sn_priority: 3 9 | sn_severity: 3 10 | target_clusters: 11 | - acm-hub 12 | job_template_name: Service now App Update 13 | tower_auth_secret: tower -------------------------------------------------------------------------------- /ansible/keepalive/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - ansiblejob.yaml 3 | - snow-keepalive-cronjob.yaml -------------------------------------------------------------------------------- /ansible/keepalive/snow-keepalive-cronjob.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: batch/v1beta1 3 | kind: CronJob 4 | metadata: 5 | name: snow-keepalive 6 | spec: 7 | # Time is measured in coordinated universal time (UTC) 8 | # ┌───────────── minute (0 - 59) 9 | # │ ┌───────────── hour (0 - 23) 10 | # │ │ ┌───────────── day of the month (1 - 31) 11 | # │ │ │ ┌───────────── month (1 - 12) 12 | # │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday; 13 | schedule: "0 0 * * *" 14 | jobTemplate: 15 | spec: 16 | backoffLimit: 1 17 | completions: 1 18 | parallelism: 1 19 | template: 20 | spec: 21 | containers: 22 | - env: 23 | - name: TOWER_OAUTH_TOKEN 24 | value: YOUR_ANSIBLE_TOWER_TOKEN_GOES_HERE 25 | - name: TOWER_HOST 26 | value: URL_FOR_YOUR_ANSIBLE_TOWER 27 | - name: TOWER_JOB_TEMPLATE_NAME 28 | value: JOB_TEMPLATE_NAME_FOUND_IN_TOWER 29 | - name: TOWER_VERIFY_SSL 30 | value: "False" 31 | - name: ANSIBLEJOB_NAME 32 | value: snow-keepalive 33 | - name: ANSIBLEJOB_NAMESPACE 34 | value: NAMESPACE_WHERE_THE_ANSIBLEJOB_KIND_IS_CREATED 35 | image: quay.io/open-cluster-management/platform-resource-runner:latest 36 | imagePullPolicy: Always 37 | name: snow-keepalive 38 | resources: {} 39 | terminationMessagePath: /dev/termination-log 40 | terminationMessagePolicy: File 41 | dnsPolicy: ClusterFirst 42 | restartPolicy: Never 43 | schedulerName: default-scheduler 44 | securityContext: {} 45 | serviceAccount: tower-resource-operator 46 | serviceAccountName: tower-resource-operator 47 | terminationGracePeriodSeconds: 30 -------------------------------------------------------------------------------- /ansible/keepalive/snow-keepalive-job.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: batch/v1 3 | kind: Job 4 | metadata: 5 | generateName: snow-keepalive-job- 6 | spec: 7 | backoffLimit: 1 8 | completions: 1 9 | parallelism: 1 10 | template: 11 | spec: 12 | containers: 13 | - env: 14 | - name: TOWER_OAUTH_TOKEN 15 | value: YOUR_ANSIBLE_TOWER_TOKEN_GOES_HERE 16 | - name: TOWER_HOST 17 | value: URL_FOR_YOUR_ANSIBLE_TOWER 18 | - name: TOWER_JOB_TEMPLATE_NAME 19 | value: JOB_TEMPLATE_NAME_FOUND_IN_TOWER 20 | - name: TOWER_VERIFY_SSL 21 | value: "False" 22 | - name: ANSIBLEJOB_NAME 23 | value: snow-keepalive 24 | - name: ANSIBLEJOB_NAMESPACE 25 | value: NAMESPACE_WHERE_THE_ANSIBLEJOB_KIND_IS_CREATED 26 | image: quay.io/open-cluster-management/platform-resource-runner:latest 27 | imagePullPolicy: Always 28 | name: snow-keepalive 29 | resources: {} 30 | terminationMessagePath: /dev/termination-log 31 | terminationMessagePolicy: File 32 | dnsPolicy: ClusterFirst 33 | restartPolicy: Never 34 | schedulerName: default-scheduler 35 | securityContext: {} 36 | serviceAccount: tower-resource-operator 37 | serviceAccountName: tower-resource-operator 38 | terminationGracePeriodSeconds: 30 -------------------------------------------------------------------------------- /ansible/pacman/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - mongo-pvc.yaml 3 | - mongo-deployment.yaml 4 | - mongo-service.yaml 5 | - pacman-deployment.yaml 6 | - pacman-service.yaml 7 | - pacman-route.yaml 8 | - pacman-f5-route.yaml -------------------------------------------------------------------------------- /ansible/pacman/mongo-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | labels: 5 | name: mongo 6 | name: mongo 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | name: mongo 12 | template: 13 | metadata: 14 | labels: 15 | name: mongo 16 | spec: 17 | containers: 18 | - image: bitnami/mongodb:latest 19 | name: mongo 20 | ports: 21 | - name: mongo 22 | containerPort: 27017 23 | volumeMounts: 24 | - name: mongo-db 25 | mountPath: /data/db 26 | volumes: 27 | - name: mongo-db 28 | persistentVolumeClaim: 29 | claimName: mongo-storage 30 | -------------------------------------------------------------------------------- /ansible/pacman/mongo-pvc.yaml: -------------------------------------------------------------------------------- 1 | kind: PersistentVolumeClaim 2 | apiVersion: v1 3 | metadata: 4 | name: mongo-storage 5 | spec: 6 | accessModes: 7 | - ReadWriteOnce 8 | resources: 9 | requests: 10 | storage: 8Gi -------------------------------------------------------------------------------- /ansible/pacman/mongo-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | labels: 5 | name: mongo 6 | name: mongo 7 | spec: 8 | type: ClusterIP 9 | ports: 10 | - port: 27017 11 | targetPort: 27017 12 | selector: 13 | name: mongo -------------------------------------------------------------------------------- /ansible/pacman/pacman-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | labels: 5 | name: pacman 6 | name: pacman 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | name: pacman 12 | template: 13 | metadata: 14 | labels: 15 | name: pacman 16 | spec: 17 | containers: 18 | - image: quay.io/jpacker/nodejs-pacman-app:latest 19 | name: pacman 20 | ports: 21 | - containerPort: 8080 22 | name: http-server 23 | -------------------------------------------------------------------------------- /ansible/pacman/pacman-f5-route.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: route.openshift.io/v1 2 | kind: Route 3 | metadata: 4 | name: f5-gslb-pacman 5 | labels: 6 | app.kubernetes.io/name: f5-gslb-pacman 7 | spec: 8 | # Added for f5 demonstration 9 | host: pacman.www-apps.jh21.dev06.red-chesterfield.com 10 | path: "/" 11 | to: 12 | kind: Service 13 | name: pacman 14 | -------------------------------------------------------------------------------- /ansible/pacman/pacman-route.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: route.openshift.io/v1 2 | kind: Route 3 | metadata: 4 | name: pacman 5 | labels: 6 | app.kubernetes.io/name: pacman 7 | spec: 8 | path: "/" 9 | to: 10 | kind: Service 11 | name: pacman -------------------------------------------------------------------------------- /ansible/pacman/pacman-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: pacman 5 | labels: 6 | name: pacman 7 | spec: 8 | type: ClusterIP 9 | ports: 10 | - port: 80 11 | targetPort: 8080 12 | protocol: TCP 13 | selector: 14 | name: pacman -------------------------------------------------------------------------------- /ansible/pacman/posthook/f5-gslb-commit.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: tower.ansible.com/v1alpha1 3 | kind: AnsibleJob 4 | metadata: 5 | name: f5-update-dns-load-balancer 6 | labels: 7 | app.kubernetes.io/name: nginx-ansible-demo 8 | spec: 9 | tower_auth_secret: toweraccess 10 | job_template_name: f5-gslb-publish 11 | extra_vars: 12 | BASE_DOMAIN: jh21.dev06.red-chesterfield.com 13 | BASE_AWS_DOMAIN: dev06.red-chesterfield.com 14 | BASE_GCP_DOMAIN: demo.gcp.red-chesterfield.com 15 | BASE_AZ_DOMAIN: az.dev06.red-chesterfield.com 16 | APP_NAME: pacman 17 | PROJECT_NAME: pacman 18 | 19 | 20 | -------------------------------------------------------------------------------- /ansible/pacman/prehook/create_snow_ticket.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: tower.ansible.com/v1alpha1 3 | kind: AnsibleJob 4 | metadata: 5 | name: service-now-nginx-demo 6 | namespace: nginx-pre-test 7 | spec: 8 | tower_auth_secret: toweraccess 9 | job_template_name: Service now App Update 10 | extra_vars: 11 | sn_severity: 3 12 | sn_priority: 3 13 | appName: pacman-ansible-demonstration 14 | -------------------------------------------------------------------------------- /ansible/subscription/application.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: app.k8s.io/v1beta1 3 | kind: Application 4 | metadata: 5 | name: pacman-ansible-demo 6 | namespace: pacman 7 | spec: 8 | componentKinds: 9 | - group: apps.open-cluster-management.io 10 | kind: Subscription 11 | descriptor: {} 12 | selector: 13 | matchExpressions: 14 | - key: app 15 | operator: In 16 | values: 17 | - pacman-ansible-demo 18 | -------------------------------------------------------------------------------- /ansible/subscription/channel.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Namespace 4 | metadata: 5 | name: demo 6 | --- 7 | apiVersion: apps.open-cluster-management.io/v1 8 | kind: Channel 9 | metadata: 10 | name: gitops 11 | namespace: demo 12 | spec: 13 | type: GitHub 14 | pathname: https://github.com/open-cluster-management/demo-subscription-gitops.git 15 | #secretRef: 16 | # name: my-github-secret -------------------------------------------------------------------------------- /ansible/subscription/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - namespace.yaml 3 | - channel.yaml 4 | - placementrule.yaml 5 | - subscription-nginx-placement.yaml 6 | - application.yaml 7 | -------------------------------------------------------------------------------- /ansible/subscription/namespace.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Namespace 4 | metadata: 5 | name: pacman 6 | -------------------------------------------------------------------------------- /ansible/subscription/placementrule.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: PlacementRule 4 | metadata: 5 | labels: 6 | app: pacman-ansible-demo 7 | name: pacman-ansible-demo-placement-0 8 | namespace: pacman 9 | spec: 10 | clusterReplicas: 2 11 | clusterSelector: 12 | matchExpressions: 13 | - key: region 14 | operator: In 15 | values: 16 | - us-east-1 17 | - europe-west3 18 | - centralus 19 | # matchLabels: 20 | # 'cloud': 'Google' 21 | clusterConditions: 22 | - type: ManagedClusterConditionAvailable 23 | status: "True" 24 | -------------------------------------------------------------------------------- /ansible/subscription/subscription-nginx-placement.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: Subscription 4 | metadata: 5 | annotations: 6 | apps.open-cluster-management.io/git-branch: master 7 | apps.open-cluster-management.io/git-path: ansible/pacman 8 | labels: 9 | app: pacman-ansible-demo 10 | name: pacman-ansible-demo-subscription-0 11 | namespace: pacman 12 | spec: 13 | hooksecretref: 14 | name: toweraccess 15 | channel: demo/gitops 16 | placement: 17 | placementRef: 18 | kind: PlacementRule 19 | name: pacman-ansible-demo-placement-0 20 | 21 | -------------------------------------------------------------------------------- /blueGreen/README.md: -------------------------------------------------------------------------------- 1 | # Demonstrate Blue-Green deployment of NGINX via Git Ops 2 | ## Tool Requirements 3 | - OpenShift CLI Version >= 4.3.0
_Needed for kustomize_ 4 | ```bash 5 | oc version 6 | ``` 7 | 8 | ## This repo is setup to manage the Blue / Green deployment of nginx 9 | ### Activate a subscription (ONLY RUN ONCE) 10 | 1. Create a fork the repository and create two branches. 11 | a. Create two branches, `blue-nginx` and `green-nginx` 12 | b. Modify `subscription/channel.yaml`, changing the value of `spec.pathname` to that of your fork of this repository 13 | c. Update nginx/blue-ingress & nginx/green-ingress, replacing `MY_INGRESS_URL` with a suitable ingress URL 14 | 2. Create the file `subscriptions/secret.yaml` 15 | ```yaml 16 | --- 17 | apiVersion: v1 18 | kind: Secret 19 | metadata: 20 | name: my-github-secret 21 | namespace: baremetal-assets 22 | data: 23 | user: BASE64_ENCRYPTED_USERNAME 24 | accessToken: BASE64_ENCRYPTED_PASSWORD 25 | ``` 26 | - Base64 encode your git username, and replace `BASE64_ENCRYPED_USERNAME` 27 | - Base64 encode your git access token, and replace `BASE64_ENCRYPTED_PASSWORD` 28 | 3. Add the subscription to your Red Hat Advanced Cluster Management for Kubernetes HUB 29 | ``` 30 | oc apply -k subscription/ 31 | ``` 32 | 4. Update the subscription/placementrule.yaml, replacing `MY_LABELS_2MATCH` with the appropriate label(s) from your target cluster. 33 | ### How it works 34 | - Three namespaces are created on the hub: `demo` for the channel and `nginx-blue` and `nginx-green` for the subscriptions 35 | - Four subscriptions are created 36 | 1. The ingress & service resources from `master` branch, in `nginx-blue` and `nginx-green` 37 | 2. The blue deployment from `blue-nginx` branch 38 | 3. The green deployment from `green-nginx` branch 39 | ### How to upgrade green to v1.14.2 40 | - The default configuration: 41 | - `blue` is nginx `v1.12.2` 42 | - `green` is nginx `v1.12.2` 43 | - Modify the `blueGreen/nginx/deployment/deployment.yaml` to 1.14.2 in the `blue-nginx` branch 44 | - Commit the change a push it to the remote repo 45 | _*Note:* That you can apply Git branch controls, where approvals(reviews) are required and not even admin's can merge without approval. 46 | - This will cause the nginx pods in the `nginx-blue` namespace to be updated to 1.14.2 47 | - Now make a pull request from `nginx-blue` to `nginx-green` this merges the version changes from Blue to Green. You can apply branch control to require a review and use a CI system to validate the deployment YAML and image tag. 48 | - Once you `merge` the pull request, the pods in the `nginx-green` namespace will upgrade to 1.14.2 49 | - A ReplicaSet is used to guarantee zero downtime during updates. If you watch the pods in the deployment, you will see that new pods go into the Running state, before the original pods are Terminated. 50 | 51 | 52 | -------------------------------------------------------------------------------- /blueGreen/nginx/blue-ingress/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: nginx-virtual-host-ingress-green 5 | spec: 6 | rules: 7 | - host: nginx-blue.kilo-bravo.demo.red-chesterfield.com 8 | http: 9 | paths: 10 | - backend: 11 | serviceName: blue-nginx-service 12 | servicePort: 8080 -------------------------------------------------------------------------------- /blueGreen/nginx/blue-ingress/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - ingress.yaml 3 | - service-blue.yaml 4 | -------------------------------------------------------------------------------- /blueGreen/nginx/blue-ingress/service-blue.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blue-nginx-service 5 | spec: 6 | selector: 7 | app: nginx 8 | ports: 9 | - name: http 10 | protocol: TCP 11 | port: 8080 12 | targetPort: 8080 13 | -------------------------------------------------------------------------------- /blueGreen/nginx/deployment/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-deployment 5 | labels: 6 | app: nginx 7 | spec: 8 | replicas: 3 9 | selector: 10 | matchLabels: 11 | app: nginx 12 | template: 13 | metadata: 14 | labels: 15 | app: nginx 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: bitnami/nginx:1.12.2 20 | ports: 21 | - containerPort: 8080 22 | -------------------------------------------------------------------------------- /blueGreen/nginx/deployment/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - deployment.yaml 3 | 4 | -------------------------------------------------------------------------------- /blueGreen/nginx/green-ingress/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: nginx-virtual-host-ingress-green 5 | spec: 6 | rules: 7 | - host: nginx.kilo-bravo.demo.red-chesterfield.com 8 | http: 9 | paths: 10 | - backend: 11 | serviceName: green-nginx-service 12 | servicePort: 8080 -------------------------------------------------------------------------------- /blueGreen/nginx/green-ingress/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - ingress.yaml 3 | - service-green.yaml 4 | -------------------------------------------------------------------------------- /blueGreen/nginx/green-ingress/service-green.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: green-nginx-service 5 | spec: 6 | selector: 7 | app: nginx 8 | ports: 9 | - name: http 10 | protocol: TCP 11 | port: 8080 12 | targetPort: 8080 13 | -------------------------------------------------------------------------------- /blueGreen/subscription/application.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: app.k8s.io/v1beta1 3 | kind: Application 4 | metadata: 5 | name: nginx-blue 6 | namespace: nginx-blue 7 | spec: 8 | selector: 9 | matchExpressions: 10 | - key: app 11 | operator: In 12 | values: 13 | - nginx-deployment 14 | componentKinds: 15 | - group: app.ibm.com/v1alpha1 16 | kind: Subscription 17 | --- 18 | apiVersion: app.k8s.io/v1beta1 19 | kind: Application 20 | metadata: 21 | name: nginx-green 22 | namespace: nginx-green 23 | spec: 24 | selector: 25 | matchExpressions: 26 | - key: app 27 | operator: In 28 | values: 29 | - nginx-deployment 30 | componentKinds: 31 | - group: app.ibm.com/v1alpha1 32 | kind: Subscription -------------------------------------------------------------------------------- /blueGreen/subscription/channel.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: Channel 4 | metadata: 5 | name: gitops 6 | namespace: demo 7 | spec: 8 | type: GitHub 9 | pathname: https://github.com/open-cluster-management/demo-subscription-gitops.git 10 | #secretRef: 11 | # name: my-github-secret -------------------------------------------------------------------------------- /blueGreen/subscription/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - namespace.yaml 3 | #- secret.yaml 4 | - channel.yaml 5 | - placementrule.yaml 6 | - subscription-nginx-ingress-blue.yaml 7 | - subscription-nginx-ingress-green.yaml 8 | - subscription-nginx-blue.yaml 9 | - subscription-nginx-green.yaml 10 | - application.yaml 11 | -------------------------------------------------------------------------------- /blueGreen/subscription/namespace.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Namespace 4 | metadata: 5 | name: demo 6 | --- 7 | apiVersion: v1 8 | kind: Namespace 9 | metadata: 10 | name: nginx-blue 11 | --- 12 | apiVersion: v1 13 | kind: Namespace 14 | metadata: 15 | name: nginx-green 16 | -------------------------------------------------------------------------------- /blueGreen/subscription/placementrule.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: PlacementRule 4 | metadata: 5 | name: nginx-deployment 6 | namespace: nginx-green 7 | labels: 8 | app: nginx-deployment 9 | spec: 10 | clusterSelector: 11 | matchLabels: 12 | name: MY_LABELS_2MATCH 13 | --- 14 | apiVersion: apps.open-cluster-management.io/v1 15 | kind: PlacementRule 16 | metadata: 17 | name: nginx-deployment 18 | namespace: nginx-blue 19 | labels: 20 | app: nginx-deployment 21 | spec: 22 | clusterSelector: 23 | matchLabels: 24 | name: MY_LABELS_2MATCH -------------------------------------------------------------------------------- /blueGreen/subscription/subscription-nginx-blue.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: blue-nginx-subscription 5 | namespace: nginx-blue 6 | annotations: 7 | apps.open-cluster-management.io/github-path: blueGreen/nginx/deployment 8 | apps.open-cluster-management.io/github-branch: blue-nginx 9 | labels: 10 | app: nginx-deployment 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: nginx-deployment 16 | kind: PlacementRule 17 | 18 | 19 | -------------------------------------------------------------------------------- /blueGreen/subscription/subscription-nginx-green.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: green-nginx-subscription 5 | namespace: nginx-green 6 | annotations: 7 | apps.open-cluster-management.io/github-path: blueGreen/nginx/deployment 8 | apps.open-cluster-management.io/github-branch: green-nginx 9 | labels: 10 | app: nginx-deployment 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: nginx-deployment 16 | kind: PlacementRule 17 | -------------------------------------------------------------------------------- /blueGreen/subscription/subscription-nginx-ingress-blue.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: ingress-nginx-subscription-blue 5 | namespace: nginx-blue 6 | labels: 7 | app: nginx-deployment 8 | annotations: 9 | apps.open-cluster-management.io/github-path: blueGreen/nginx/blue-ingress 10 | apps.open-cluster-management.io/github-branch: master 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: nginx-deployment 16 | kind: PlacementRule 17 | 18 | -------------------------------------------------------------------------------- /blueGreen/subscription/subscription-nginx-ingress-green.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: ingress-nginx-subscription-green 5 | namespace: nginx-green 6 | labels: 7 | app: nginx-deployment 8 | annotations: 9 | apps.open-cluster-management.io/github-path: blueGreen/nginx/green-ingress 10 | apps.open-cluster-management.io/github-branch: master 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: nginx-deployment 16 | kind: PlacementRule 17 | 18 | -------------------------------------------------------------------------------- /bma/BareMetalAssets/bmc-secret-dc01r3c1b3-powerflex390.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Secret 4 | metadata: 5 | name: dc01r3c1b3-powerflex390-bmc-secret 6 | type: Opaque 7 | data: 8 | password: am9zaA== 9 | username: dGVzdA== -------------------------------------------------------------------------------- /bma/BareMetalAssets/bmc-secret-dc01r3c3b2-powerflex390.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Secret 4 | metadata: 5 | name: dc01r3c3b2-powerflex390-bmc-secret 6 | type: Opaque 7 | data: 8 | password: am9zaA== 9 | username: dGVzdA== -------------------------------------------------------------------------------- /bma/BareMetalAssets/dc01r3c1b3-powerflex390.yaml: -------------------------------------------------------------------------------- 1 | # Datacenter: 01 2 | # Rack: 3 3 | # Chasis: 1 <<< Changed 4 | # Blade: 1 << Changed 5 | apiVersion: inventory.open-cluster-management.io/v1alpha1 6 | kind: BareMetalAsset 7 | metadata: 8 | name: dc01r3c1b3-powerflex390 9 | spec: 10 | bmc: 11 | address: 3.3.3.3 12 | credentialsName: dc01r3c1b3-powerflex390-bmc-secret 13 | bootMACAddress: "00:33:33:22:33:00" -------------------------------------------------------------------------------- /bma/BareMetalAssets/dc01r3c3b2-powerflex390.yaml: -------------------------------------------------------------------------------- 1 | # Datacenter: 01 2 | # Rack: 3 3 | # Chasis: 3 4 | # Blade: 2 5 | apiVersion: inventory.open-cluster-management.io/v1alpha1 6 | kind: BareMetalAsset 7 | metadata: 8 | name: dc01r3c3b2-powerflex390 9 | spec: 10 | bmc: 11 | address: 3.3.3.3 12 | credentialsName: dc01r3c3b2-powerflex390-bmc-secret 13 | bootMACAddress: "00:33:33:22:33:00" -------------------------------------------------------------------------------- /bma/README.md: -------------------------------------------------------------------------------- 1 | # Demonstrate BareMetalAssets via Git Ops 2 | ## Tool Requirements 3 | - OpenShift CLI Version >= 4.3.0
_Needed for kustomize_ 4 | ```bash 5 | oc version 6 | ``` 7 | 8 | ## This repo is setup to manage your Bare Metal Assets as code 9 | ### Activate a subscription (ONLY RUN ONCE) 10 | 1. Create a branch in the repository or fork the repository. 11 | - If you branched, update `./subscription/subscription.yaml` and set `apps.open-cluster-management.io/github-branch: master` to your branch name. 12 | - If you forked the repo, update `./subscription/channel.yaml` and set `spec.pathname` to your forked git repository url 13 | 2. Create the file `./subscriptions/secret.yaml` 14 | ```yaml 15 | --- 16 | apiVersion: v1 17 | kind: Secret 18 | metadata: 19 | name: my-github-secret 20 | namespace: baremetal-assets 21 | data: 22 | user: BASE64_ENCRYPTED_USERNAME 23 | accessToken: BASE64_ENCRYPTED_PASSWORD 24 | ``` 25 | - Base64 encode your git username, and replace `BASE64_ENCRYPED_USERNAME` 26 | - Base64 encode your git access token, and replace `BASE64_ENCRYPTED_PASSWORD` 27 | 3. Add the subscription to your Red Hat Advanced Cluster Management for Kubernetes HUB 28 | ``` 29 | oc apply -k subscription/ 30 | ``` 31 | ### Using 32 | - After you have completed the ONE time setup, you will start to see the BMA Objects from the `./bma/BareMetalAssets` folder start appearing in the Bare Metal Asset UI. 33 | - If you commit a change to your branch or forked repo, those changes will appear in the Bare Metal Asset UI in <60s 34 | - The namespace used for the Bare Metal Asset Objects is `default` 35 | 36 | ### Help 37 | Reach out to `acm-contact@redhat.com` in coreos.slack.com for help 38 | -------------------------------------------------------------------------------- /bma/subscription/channel.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: Channel 4 | metadata: 5 | name: datacenter01 6 | namespace: baremetal-assets 7 | spec: 8 | type: GitHub 9 | pathname: https://github.com/open-cluster-management/demo-subscription-gitops.git 10 | #secretRef: 11 | # name: my-github-secret -------------------------------------------------------------------------------- /bma/subscription/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - namespace.yaml 3 | #- secret.yaml 4 | - channel.yaml 5 | - subscription.yaml -------------------------------------------------------------------------------- /bma/subscription/namespace.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Namespace 4 | metadata: 5 | name: baremetal-assets -------------------------------------------------------------------------------- /bma/subscription/subscription.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: bma-subscription 5 | namespace: default 6 | annotations: 7 | apps.open-cluster-management.io/github-path: bma/BareMetalAssets 8 | apps.open-cluster-management.io/github-branch: master 9 | spec: 10 | channel: baremetal-assets/datacenter01 11 | placement: 12 | local: true 13 | -------------------------------------------------------------------------------- /book-import/app/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | labels: 5 | name: book-import 6 | name: book-import 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | name: book-import 12 | template: 13 | metadata: 14 | labels: 15 | name: book-import 16 | spec: 17 | containers: 18 | - image: quay.io/jpacker/hugo-nginx:latest 19 | name: book-import 20 | ports: 21 | - containerPort: 8080 22 | name: http-server 23 | -------------------------------------------------------------------------------- /book-import/app/route.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: route.openshift.io/v1 2 | kind: Route 3 | metadata: 4 | name: book-import 5 | labels: 6 | name: book-import 7 | spec: 8 | path: "/" 9 | to: 10 | kind: Service 11 | name: book-import 12 | tls: 13 | termination: edge 14 | insecureEdgeTerminationPolicy: Redirect -------------------------------------------------------------------------------- /book-import/app/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: book-import 5 | labels: 6 | name: book-import 7 | spec: 8 | type: ClusterIP 9 | ports: 10 | - port: 80 11 | targetPort: 8080 12 | protocol: TCP 13 | selector: 14 | name: book-import -------------------------------------------------------------------------------- /book-import/subscription/application.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: app.k8s.io/v1beta1 3 | kind: Application 4 | metadata: 5 | name: book-import 6 | namespace: book-import 7 | spec: 8 | selector: 9 | matchExpressions: 10 | - key: app 11 | operator: In 12 | values: 13 | - book-import 14 | -------------------------------------------------------------------------------- /book-import/subscription/channel.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Namespace 4 | metadata: 5 | name: demo 6 | --- 7 | apiVersion: apps.open-cluster-management.io/v1 8 | kind: Channel 9 | metadata: 10 | name: gitops 11 | namespace: demo 12 | spec: 13 | type: GitHub 14 | pathname: https://github.com/open-cluster-management/demo-subscription-gitops.git 15 | #secretRef: 16 | # name: my-github-secret -------------------------------------------------------------------------------- /book-import/subscription/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - namespace.yaml 3 | - application.yaml 4 | - channel.yaml 5 | - placementrule.yaml 6 | - subscription.yaml -------------------------------------------------------------------------------- /book-import/subscription/namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: book-import 5 | 6 | -------------------------------------------------------------------------------- /book-import/subscription/placementrule.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: PlacementRule 4 | metadata: 5 | labels: 6 | app: book-import 7 | name: book-import-placement-0 8 | namespace: book-import 9 | spec: 10 | clusterSelector: 11 | matchLabels: 12 | 'usage': 'development' 13 | clusterConditions: 14 | - type: ManagedClusterConditionAvailable 15 | status: "True" -------------------------------------------------------------------------------- /book-import/subscription/subscription.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: Subscription 4 | metadata: 5 | annotations: 6 | apps.open-cluster-management.io/git-branch: master 7 | apps.open-cluster-management.io/git-path: book-import/app 8 | labels: 9 | app: book-import 10 | name: book-import-subscription-0 11 | namespace: book-import 12 | spec: 13 | channel: demo/gitops 14 | placement: 15 | placementRef: 16 | kind: PlacementRule 17 | name: book-import-placement-0 18 | 19 | -------------------------------------------------------------------------------- /cloud-provider/README.md: -------------------------------------------------------------------------------- 1 | # Demonstrate placement algorithm 2 | ## Tool Requirements 3 | - OpenShift CLI Version >= 4.3.0
_Needed for kustomize_ 4 | ```bash 5 | oc version 6 | ``` 7 | 8 | ## This example, Deploys nginx with an internal service, that allows reading the Cloud provider and Region json. This is designed to work with the modified Pacman application. 9 | 1. Add the subscription to your Red Hat Advanced Cluster Management for Kubernetes HUB 10 | ``` 11 | clone https://github.com/open-cluster-management/demo-subscription-gitops.git 12 | oc apply -k demo-subscription-gitops/cloud-provider/subscription/ 13 | ``` 14 | ### results 15 | This will automatically provision the nginx with cloud provider and region identifier to: 16 | ### Amazon AWS 17 | - us-east-1 18 | - us-east-2 19 | - us-east-3 20 | - us-west-1 21 | - eu-central-1 22 | - eu-west-3 23 | 24 | ### Google GCP 25 | - europe-west3 26 | 27 | ### Azure 28 | - centralus 29 | 30 | ### Related 31 | Pacman deployment with an Ansible job in: `ansible/` -------------------------------------------------------------------------------- /cloud-provider/nginx/deployment-a-eu1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cloud-provider-nginx 5 | labels: 6 | app.kubernetes.io/name: nginx-cp 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app.kubernetes.io/name: nginx-cp 12 | template: 13 | metadata: 14 | labels: 15 | app.kubernetes.io/name: nginx-cp 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: quay.io/jpacker/nginx:1.16.1 20 | ports: 21 | - containerPort: 8080 22 | imagePullPolicy: Always 23 | env: 24 | - name: CLOUD_PROVIDER 25 | value: "Amazon" 26 | - name: ZONE 27 | value: "eu-central-1" 28 | volumeMounts: 29 | - mountPath: /app/provider 30 | name: cache-provider 31 | volumes: 32 | - name: cache-provider 33 | emptyDir: {} 34 | -------------------------------------------------------------------------------- /cloud-provider/nginx/deployment-a-eu3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cloud-provider-nginx 5 | labels: 6 | app.kubernetes.io/name: nginx-cp 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app.kubernetes.io/name: nginx-cp 12 | template: 13 | metadata: 14 | labels: 15 | app.kubernetes.io/name: nginx-cp 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: quay.io/jpacker/nginx:1.16.1 20 | ports: 21 | - containerPort: 8080 22 | imagePullPolicy: Always 23 | env: 24 | - name: CLOUD_PROVIDER 25 | value: "Amazon" 26 | - name: ZONE 27 | value: "eu-west-3" 28 | volumeMounts: 29 | - mountPath: /app/provider 30 | name: cache-provider 31 | volumes: 32 | - name: cache-provider 33 | emptyDir: {} 34 | -------------------------------------------------------------------------------- /cloud-provider/nginx/deployment-a-us1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cloud-provider-nginx 5 | labels: 6 | app.kubernetes.io/name: nginx-cp 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app.kubernetes.io/name: nginx-cp 12 | template: 13 | metadata: 14 | labels: 15 | app.kubernetes.io/name: nginx-cp 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: quay.io/jpacker/nginx:1.16.1 20 | ports: 21 | - containerPort: 8080 22 | imagePullPolicy: Always 23 | env: 24 | - name: CLOUD_PROVIDER 25 | value: "Amazon" 26 | - name: ZONE 27 | value: "us-east-1" 28 | volumeMounts: 29 | - mountPath: /app/provider 30 | name: cache-provider 31 | volumes: 32 | - name: cache-provider 33 | emptyDir: {} 34 | -------------------------------------------------------------------------------- /cloud-provider/nginx/deployment-a-us2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cloud-provider-nginx 5 | labels: 6 | app.kubernetes.io/name: nginx-cp 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app.kubernetes.io/name: nginx-cp 12 | template: 13 | metadata: 14 | labels: 15 | app.kubernetes.io/name: nginx-cp 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: quay.io/jpacker/nginx:1.16.1 20 | ports: 21 | - containerPort: 8080 22 | imagePullPolicy: Always 23 | env: 24 | - name: CLOUD_PROVIDER 25 | value: "Amazon" 26 | - name: ZONE 27 | value: "us-east-2" 28 | volumeMounts: 29 | - mountPath: /app/provider 30 | name: cache-provider 31 | volumes: 32 | - name: cache-provider 33 | emptyDir: {} 34 | -------------------------------------------------------------------------------- /cloud-provider/nginx/deployment-a-us3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cloud-provider-nginx 5 | labels: 6 | app.kubernetes.io/name: nginx-cp 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app.kubernetes.io/name: nginx-cp 12 | template: 13 | metadata: 14 | labels: 15 | app.kubernetes.io/name: nginx-cp 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: quay.io/jpacker/nginx:1.16.1 20 | ports: 21 | - containerPort: 8080 22 | imagePullPolicy: Always 23 | env: 24 | - name: CLOUD_PROVIDER 25 | value: "Amazon" 26 | - name: ZONE 27 | value: "us-west-3" 28 | volumeMounts: 29 | - mountPath: /app/provider 30 | name: cache-provider 31 | volumes: 32 | - name: cache-provider 33 | emptyDir: {} 34 | -------------------------------------------------------------------------------- /cloud-provider/nginx/deployment-a-uw1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cloud-provider-nginx 5 | labels: 6 | app.kubernetes.io/name: nginx-cp 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app.kubernetes.io/name: nginx-cp 12 | template: 13 | metadata: 14 | labels: 15 | app.kubernetes.io/name: nginx-cp 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: quay.io/jpacker/nginx:1.16.1 20 | ports: 21 | - containerPort: 8080 22 | imagePullPolicy: Always 23 | env: 24 | - name: CLOUD_PROVIDER 25 | value: "Amazon" 26 | - name: ZONE 27 | value: "us-west-1" 28 | volumeMounts: 29 | - mountPath: /app/provider 30 | name: cache-provider 31 | volumes: 32 | - name: cache-provider 33 | emptyDir: {} 34 | -------------------------------------------------------------------------------- /cloud-provider/nginx/deployment-az-cus.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cloud-provider-nginx 5 | labels: 6 | app.kubernetes.io/name: nginx-cp 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app.kubernetes.io/name: nginx-cp 12 | template: 13 | metadata: 14 | labels: 15 | app.kubernetes.io/name: nginx-cp 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: quay.io/jpacker/nginx:1.16.1 20 | ports: 21 | - containerPort: 8080 22 | imagePullPolicy: Always 23 | env: 24 | - name: CLOUD_PROVIDER 25 | value: "Azure" 26 | - name: ZONE 27 | value: "centralus" 28 | volumeMounts: 29 | - mountPath: /app/provider 30 | name: cache-provider 31 | volumes: 32 | - name: cache-provider 33 | emptyDir: {} 34 | -------------------------------------------------------------------------------- /cloud-provider/nginx/deployment-g-eu3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: cloud-provider-nginx 5 | labels: 6 | app.kubernetes.io/name: nginx-cp 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app.kubernetes.io/name: nginx-cp 12 | template: 13 | metadata: 14 | labels: 15 | app.kubernetes.io/name: nginx-cp 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: quay.io/jpacker/nginx:1.16.1 20 | ports: 21 | - containerPort: 8080 22 | imagePullPolicy: Always 23 | env: 24 | - name: CLOUD_PROVIDER 25 | value: "Google" 26 | - name: ZONE 27 | value: "europe-west3" 28 | volumeMounts: 29 | - mountPath: /app/provider 30 | name: cache-provider 31 | volumes: 32 | - name: cache-provider 33 | emptyDir: {} 34 | -------------------------------------------------------------------------------- /cloud-provider/nginx/kustomization.yaml: -------------------------------------------------------------------------------- 1 | namespace: provider 2 | resources: 3 | - service.yaml 4 | - deployment.yaml 5 | -------------------------------------------------------------------------------- /cloud-provider/nginx/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: cloud 5 | spec: 6 | selector: 7 | app.kubernetes.io/name: nginx-cp 8 | ports: 9 | - name: http 10 | protocol: TCP 11 | port: 8080 12 | targetPort: 8080 13 | -------------------------------------------------------------------------------- /cloud-provider/subscription/application.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: app.k8s.io/v1beta1 3 | kind: Application 4 | metadata: 5 | name: cloud 6 | namespace: provider 7 | spec: 8 | selector: 9 | matchLabels: 10 | app: cloud 11 | -------------------------------------------------------------------------------- /cloud-provider/subscription/channel.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: Channel 4 | metadata: 5 | name: gitops 6 | namespace: demo 7 | spec: 8 | type: GitHub 9 | pathname: https://github.com/open-cluster-management/demo-subscription-gitops.git 10 | #secretRef: 11 | # name: my-github-secret -------------------------------------------------------------------------------- /cloud-provider/subscription/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - namespace.yaml 3 | #- secret.yaml 4 | - channel.yaml 5 | - placementrule-a-us1.yaml 6 | - placementrule-a-us2.yaml 7 | - placementrule-a-eu1.yaml 8 | - placementrule-a-eu3.yaml 9 | - placementrule-g-eu3.yaml 10 | - placementrule-a-uw1.yaml 11 | - placementrule-az-cus.yaml 12 | - subscription-provider-a-us1.yaml 13 | - subscription-provider-a-us2.yaml 14 | - subscription-provider-a-eu1.yaml 15 | - subscription-provider-a-eu3.yaml 16 | - subscription-provider-g-eu3.yaml 17 | - subscription-provider-a-uw1.yaml 18 | - subscription-provider-az-cus.yaml 19 | - application.yaml 20 | -------------------------------------------------------------------------------- /cloud-provider/subscription/namespace.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Namespace 4 | metadata: 5 | name: demo 6 | --- 7 | apiVersion: v1 8 | kind: Namespace 9 | metadata: 10 | name: provider 11 | -------------------------------------------------------------------------------- /cloud-provider/subscription/placementrule-a-eu1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: cloud-provider-a-eu1 5 | namespace: provider 6 | labels: 7 | app: cloud 8 | spec: 9 | clusterConditions: 10 | - type: ManagedClusterConditionAvailable 11 | status: "True" 12 | clusterSelector: 13 | matchLabels: 14 | cloud: Amazon 15 | region: eu-central-1 16 | #clusterReplicas: 1 #Apply to how many matched clusters, default is ALL 17 | -------------------------------------------------------------------------------- /cloud-provider/subscription/placementrule-a-eu3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: cloud-provider-a-eu3 5 | namespace: provider 6 | labels: 7 | app: cloud 8 | spec: 9 | clusterConditions: 10 | - type: ManagedClusterConditionAvailable 11 | status: "True" 12 | clusterSelector: 13 | matchLabels: 14 | cloud: Amazon 15 | region: eu-west-3 16 | #clusterReplicas: 1 #Apply to how many matched clusters, default is ALL 17 | -------------------------------------------------------------------------------- /cloud-provider/subscription/placementrule-a-us1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: cloud-provider-a-us1 5 | namespace: provider 6 | labels: 7 | app: cloud 8 | spec: 9 | clusterConditions: 10 | - type: ManagedClusterConditionAvailable 11 | status: "True" 12 | clusterSelector: 13 | matchLabels: 14 | cloud: Amazon 15 | region: us-east-1 16 | #clusterReplicas: 1 #Apply to how many matched clusters, default is ALL 17 | -------------------------------------------------------------------------------- /cloud-provider/subscription/placementrule-a-us2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: cloud-provider-a-us2 5 | namespace: provider 6 | labels: 7 | app: cloud 8 | spec: 9 | clusterConditions: 10 | - type: ManagedClusterConditionAvailable 11 | status: "True" 12 | clusterSelector: 13 | matchLabels: 14 | cloud: Amazon 15 | region: us-east-2 16 | #clusterReplicas: 1 #Apply to how many matched clusters, default is ALL 17 | -------------------------------------------------------------------------------- /cloud-provider/subscription/placementrule-a-us3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: cloud-provider-a-us3 5 | namespace: provider 6 | labels: 7 | app: cloud 8 | spec: 9 | clusterConditions: 10 | - type: ManagedClusterConditionAvailable 11 | status: "True" 12 | clusterSelector: 13 | matchLabels: 14 | cloud: Amazon 15 | region: us-west-3 16 | #clusterReplicas: 1 #Apply to how many matched clusters, default is ALL 17 | -------------------------------------------------------------------------------- /cloud-provider/subscription/placementrule-a-uw1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: cloud-provider-a-uw1 5 | namespace: provider 6 | labels: 7 | app: cloud 8 | spec: 9 | clusterConditions: 10 | - type: ManagedClusterConditionAvailable 11 | status: "True" 12 | clusterSelector: 13 | matchLabels: 14 | cloud: Amazon 15 | region: us-west-1 16 | #clusterReplicas: 1 #Apply to how many matched clusters, default is ALL 17 | -------------------------------------------------------------------------------- /cloud-provider/subscription/placementrule-az-cus.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: cloud-provider-az-cus 5 | namespace: provider 6 | labels: 7 | app: cloud 8 | spec: 9 | clusterConditions: 10 | - type: ManagedClusterConditionAvailable 11 | status: "True" 12 | clusterSelector: 13 | matchLabels: 14 | cloud: Azure 15 | region: centralus 16 | #clusterReplicas: 1 #Apply to how many matched clusters, default is ALL 17 | -------------------------------------------------------------------------------- /cloud-provider/subscription/placementrule-g-eu3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: cloud-provider-g-eu3 5 | namespace: provider 6 | labels: 7 | app: cloud 8 | spec: 9 | clusterConditions: 10 | - type: ManagedClusterConditionAvailable 11 | status: "True" 12 | clusterSelector: 13 | matchLabels: 14 | cloud: Google 15 | region: europe-west3 16 | #clusterReplicas: 1 #Apply to how many matched clusters, default is ALL 17 | -------------------------------------------------------------------------------- /cloud-provider/subscription/subscription-provider-a-eu1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: cloud-amazon-eu-central-1 5 | namespace: provider 6 | annotations: 7 | apps.open-cluster-management.io/github-path: cloud-provider/nginx 8 | apps.open-cluster-management.io/github-branch: master 9 | labels: 10 | app: cloud 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: cloud-provider-a-eu1 16 | kind: PlacementRule 17 | packageOverrides: 18 | - packageName: kustomization 19 | packageOverrides: 20 | - value: 21 | namespace: provider 22 | resources: 23 | - service.yaml 24 | - deployment-a-eu1.yaml 25 | 26 | -------------------------------------------------------------------------------- /cloud-provider/subscription/subscription-provider-a-eu3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: cloud-amazon-eu-west-3 5 | namespace: provider 6 | annotations: 7 | apps.open-cluster-management.io/github-path: cloud-provider/nginx 8 | apps.open-cluster-management.io/github-branch: master 9 | labels: 10 | app: cloud 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: cloud-provider-a-eu3 16 | kind: PlacementRule 17 | packageOverrides: 18 | - packageName: kustomization 19 | packageOverrides: 20 | - value: 21 | namespace: provider 22 | resources: 23 | - service.yaml 24 | - deployment-a-eu3.yaml 25 | 26 | -------------------------------------------------------------------------------- /cloud-provider/subscription/subscription-provider-a-us1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: cloud-amazon-us-east-1 5 | namespace: provider 6 | annotations: 7 | apps.open-cluster-management.io/github-path: cloud-provider/nginx 8 | apps.open-cluster-management.io/github-branch: master 9 | labels: 10 | app: cloud 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: cloud-provider-a-us1 16 | kind: PlacementRule 17 | packageOverrides: 18 | - packageName: kustomization 19 | packageOverrides: 20 | - value: 21 | namespace: provider 22 | resources: 23 | - service.yaml 24 | - deployment-a-us1.yaml 25 | 26 | -------------------------------------------------------------------------------- /cloud-provider/subscription/subscription-provider-a-us2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: cloud-amazon-us-east-2 5 | namespace: provider 6 | annotations: 7 | apps.open-cluster-management.io/github-path: cloud-provider/nginx 8 | apps.open-cluster-management.io/github-branch: master 9 | labels: 10 | app: cloud 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: cloud-provider-a-us2 16 | kind: PlacementRule 17 | packageOverrides: 18 | - packageName: kustomization 19 | packageOverrides: 20 | - value: 21 | namespace: provider 22 | resources: 23 | - service.yaml 24 | - deployment-a-us2.yaml 25 | 26 | -------------------------------------------------------------------------------- /cloud-provider/subscription/subscription-provider-a-us3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: cloud-amazon-us-west-3 5 | namespace: provider 6 | annotations: 7 | apps.open-cluster-management.io/github-path: cloud-provider/nginx 8 | apps.open-cluster-management.io/github-branch: master 9 | labels: 10 | app: cloud 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: cloud-provider-a-us3 16 | kind: PlacementRule 17 | packageOverrides: 18 | - packageName: kustomization 19 | packageOverrides: 20 | - value: 21 | namespace: provider 22 | resources: 23 | - service.yaml 24 | - deployment-a-us3.yaml 25 | 26 | -------------------------------------------------------------------------------- /cloud-provider/subscription/subscription-provider-a-uw1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: cloud-amazon-us-west-1 5 | namespace: provider 6 | annotations: 7 | apps.open-cluster-management.io/github-path: cloud-provider/nginx 8 | apps.open-cluster-management.io/github-branch: master 9 | labels: 10 | app: cloud 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: cloud-provider-a-uw1 16 | kind: PlacementRule 17 | packageOverrides: 18 | - packageName: kustomization 19 | packageOverrides: 20 | - value: 21 | namespace: provider 22 | resources: 23 | - service.yaml 24 | - deployment-a-uw1.yaml 25 | 26 | -------------------------------------------------------------------------------- /cloud-provider/subscription/subscription-provider-az-cus.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: cloud-azure-centralus 5 | namespace: provider 6 | annotations: 7 | apps.open-cluster-management.io/github-path: cloud-provider/nginx 8 | apps.open-cluster-management.io/github-branch: master 9 | labels: 10 | app: cloud 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: cloud-provider-az-cus 16 | kind: PlacementRule 17 | packageOverrides: 18 | - packageName: kustomization 19 | packageOverrides: 20 | - value: 21 | namespace: provider 22 | resources: 23 | - service.yaml 24 | - deployment-az-cus.yaml 25 | 26 | -------------------------------------------------------------------------------- /cloud-provider/subscription/subscription-provider-g-eu3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: cloud-google-europe-west3 5 | namespace: provider 6 | annotations: 7 | apps.open-cluster-management.io/github-path: cloud-provider/nginx 8 | apps.open-cluster-management.io/github-branch: master 9 | labels: 10 | app: cloud 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: cloud-provider-g-eu3 16 | kind: PlacementRule 17 | packageOverrides: 18 | - packageName: kustomization 19 | packageOverrides: 20 | - value: 21 | namespace: provider 22 | resources: 23 | - service.yaml 24 | - deployment-g-eu3.yaml 25 | 26 | -------------------------------------------------------------------------------- /config-test/README.md: -------------------------------------------------------------------------------- 1 | # Demonstrate BareMetalAssets via Git Ops 2 | ## Tool Requirements 3 | - OpenShift CLI Version >= 4.3.0
_Needed for kustomize_ 4 | ```bash 5 | oc version 6 | ``` 7 | 8 | ## This repo is setup to manage your Bare Metal Assets as code 9 | ### Activate a subscription (ONLY RUN ONCE) 10 | 1. Create a branch in the repository or fork the repository. 11 | - If you branched, update `./subscription/subscription.yaml` and set `apps.open-cluster-management.io/github-branch: master` to your branch name. 12 | - If you forked the repo, update `./subscription/channel.yaml` and set `spec.pathname` to your forked git repository url 13 | 2. Create the file `./subscriptions/secret.yaml` 14 | ```yaml 15 | --- 16 | apiVersion: v1 17 | kind: Secret 18 | metadata: 19 | name: my-github-secret 20 | namespace: baremetal-assets 21 | data: 22 | user: BASE64_ENCRYPTED_USERNAME 23 | accessToken: BASE64_ENCRYPTED_PASSWORD 24 | ``` 25 | - Base64 encode your git username, and replace `BASE64_ENCRYPED_USERNAME` 26 | - Base64 encode your git access token, and replace `BASE64_ENCRYPTED_PASSWORD` 27 | 3. Add the subscription to your Red Hat Advanced Cluster Management for Kubernetes HUB 28 | ``` 29 | oc apply -k subscription/ 30 | ``` 31 | ### Using 32 | - After you have completed the ONE time setup, you will start to see the BMA Objects from the `./bma/BareMetalAssets` folder start appearing in the Bare Metal Asset UI. 33 | - If you commit a change to your branch or forked repo, those changes will appear in the Bare Metal Asset UI in <60s 34 | - The namespace used for the Bare Metal Asset Objects is `default` 35 | 36 | ### Help 37 | Reach out to `acm-contact@redhat.com` in coreos.slack.com for help 38 | -------------------------------------------------------------------------------- /config-test/configmap/configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: josh-demo 5 | data: 6 | my-name: JoshuaPacker 7 | -------------------------------------------------------------------------------- /config-test/subscription/channel.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: Channel 4 | metadata: 5 | name: test-channel 6 | namespace: test-ch 7 | spec: 8 | type: Git 9 | pathname: https://github.com/open-cluster-management/demo-subscription-gitops.git 10 | #secretRef: 11 | # name: my-github-secret 12 | -------------------------------------------------------------------------------- /config-test/subscription/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - namespace.yaml 3 | #- secret.yaml 4 | - channel.yaml 5 | - subscription.yaml -------------------------------------------------------------------------------- /config-test/subscription/namespace.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Namespace 4 | metadata: 5 | name: test-ch 6 | -------------------------------------------------------------------------------- /config-test/subscription/subscription.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: test-configmap 5 | namespace: default 6 | annotations: 7 | apps.open-cluster-management.io/github-path: config-test/configmap 8 | apps.open-cluster-management.io/github-branch: configmap 9 | labels: 10 | subscription-delete-resources: "false" 11 | spec: 12 | channel: test-ch/test-channel 13 | placement: 14 | local: true 15 | -------------------------------------------------------------------------------- /placement/README.md: -------------------------------------------------------------------------------- 1 | # Demonstrate placement algorithm 2 | ## Tool Requirements 3 | - OpenShift CLI Version >= 4.3.0
_Needed for kustomize_ 4 | ```bash 5 | oc version 6 | ``` 7 | 8 | ## This example, allows you to demonstrate moving an application from one cluster to another 9 | ### CLI: Activate a subscription (ONLY RUN ONCE) 10 | 1. Add the subscription to your Red Hat Advanced Cluster Management for Kubernetes HUB 11 | ``` 12 | clone https://github.com/open-cluster-management/demo-subscription-gitops.git 13 | oc apply -k demo-subscription-gitops/placement/subscription/ 14 | ``` 15 | ### Application Console: Create a new subscription 16 | A nice looking topology you might find is a development & production cluster. Using the console, you can easily create an Application that runs a copy of the application on you development clusters and a different version on proudction. 17 | 18 | #### Prerequisite 19 | At least two clusters, each with a distinct label, one for development and one for production. 20 | #### Console 21 | 1. Navigate in the left menu to `Managed applications` 22 | 2. Choose `Create application` 23 | 3. Enter the following values: 24 | * **Name:** `nginx` 25 | * **Namespace:** `nginx` 26 | * **Repository types** `Git` 27 | * **URL** `https://github.com/open-cluster-management/demo-subscription-gitops.git` 28 | * **Branch** `master` 29 | * ** Path** `placement/nginx 30 | * Select `Deploy application resources only on clusters matching specified labels` 31 | * Enter the label information for your development cluster 32 | 4. Select `Add another repository` 33 | * **Repository types** `Git` 34 | * **URL** `https://github.com/open-cluster-management/demo-subscription-gitops.git` 35 | * **Branch** `production` 36 | * ** Path** `placement/nginx 37 | * Select `Deploy application resources only on clusters matching specified labels` 38 | * Enter the label information for your production cluster 39 | 5. Click `Save` 40 | 41 | ### Viewing 42 | - Navigate to the Manage applications in the UI. Click the `nginx-placement` Application name. 43 | - View the Topology, look around, by default the application should have deployed to `vendor: OpenShift` clusters 44 | - Click the `Resources` tab 45 | - Edit the placement rule, and change `vendor: OpenShift` to `cloud: Amazon` and your application will be migrated to any cluster with the `cloud: Amazon` label. You need to adjust this key and value pair, based on what is seen in your Cluster List page as available labels 46 | - To spread the app to all clusters, change the YAML as follows: 47 | ```yaml 48 | clusterSelector: 49 | matchLabels: {} 50 | ``` 51 | -------------------------------------------------------------------------------- /placement/nginx/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-placement 5 | labels: 6 | app: nginx-placement 7 | spec: 8 | replicas: 3 9 | selector: 10 | matchLabels: 11 | app: nginx-placement 12 | template: 13 | metadata: 14 | labels: 15 | app: nginx-placement 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: quay.io/jpacker/nginx:1.16.1 20 | ports: 21 | - containerPort: 8080 22 | imagePullPolicy: Always 23 | -------------------------------------------------------------------------------- /placement/nginx/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - service.yaml 3 | - deployment.yaml 4 | - route.yaml 5 | -------------------------------------------------------------------------------- /placement/nginx/route.yaml: -------------------------------------------------------------------------------- 1 | kind: Route 2 | apiVersion: route.openshift.io/v1 3 | metadata: 4 | name: nginx 5 | spec: 6 | to: 7 | kind: Service 8 | name: placement-nginx-service 9 | weight: 100 10 | port: 11 | targetPort: 8080 12 | tls: 13 | termination: edge 14 | insecureEdgeTerminationPolicy: Redirect 15 | 16 | 17 | -------------------------------------------------------------------------------- /placement/nginx/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: placement-nginx-service 5 | spec: 6 | selector: 7 | app: nginx-placement 8 | ports: 9 | - name: http 10 | protocol: TCP 11 | port: 8080 12 | targetPort: 8080 13 | -------------------------------------------------------------------------------- /placement/subscription/application.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: app.k8s.io/v1beta1 3 | kind: Application 4 | metadata: 5 | name: nginx-placement 6 | namespace: nginx 7 | spec: 8 | selector: 9 | matchLabels: 10 | app: nginx-placement 11 | -------------------------------------------------------------------------------- /placement/subscription/channel.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: Channel 4 | metadata: 5 | name: gitops 6 | namespace: demo 7 | spec: 8 | type: GitHub 9 | pathname: https://github.com/open-cluster-management/demo-subscription-gitops.git 10 | #secretRef: 11 | # name: my-github-secret -------------------------------------------------------------------------------- /placement/subscription/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - namespace.yaml 3 | #- secret.yaml 4 | - channel.yaml 5 | - placementrule.yaml 6 | - subscription-nginx-placement.yaml 7 | - application.yaml 8 | -------------------------------------------------------------------------------- /placement/subscription/namespace.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Namespace 4 | metadata: 5 | name: demo 6 | --- 7 | apiVersion: v1 8 | kind: Namespace 9 | metadata: 10 | name: nginx 11 | -------------------------------------------------------------------------------- /placement/subscription/placementrule.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: PlacementRule 3 | metadata: 4 | name: nginx-placement 5 | namespace: nginx 6 | labels: 7 | app: nginx-placement 8 | spec: 9 | clusterConditions: 10 | - type: ManagedClusterConditionAvailable 11 | status: "True" 12 | #clusters: 13 | #- name: gcp1-hive 14 | clusterSelector: 15 | matchLabels: 16 | vendor: OpenShift 17 | #clusterReplicas: 1 #Apply to how many matched clusters, default is ALL 18 | -------------------------------------------------------------------------------- /placement/subscription/subscription-nginx-placement.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: placement-nginx-subscription 5 | namespace: nginx 6 | labels: 7 | app: nginx-placement 8 | annotations: 9 | apps.open-cluster-management.io/github-path: placement/nginx 10 | apps.open-cluster-management.io/github-branch: master 11 | spec: 12 | channel: demo/gitops 13 | placement: 14 | placementRef: 15 | name: nginx-placement 16 | kind: PlacementRule 17 | 18 | -------------------------------------------------------------------------------- /policy/README.md: -------------------------------------------------------------------------------- 1 | # GitOps driven policy demonstration 2 | - Log into the Red Hat ACM Hub 3 | - Activate the gitops subscription 4 | ```bash 5 | oc apply -k subscripton/ 6 | ``` 7 | - Navigate to the Governance, Risk and Policy section in the Red Hat ACM console 8 | - You will see a policy 9 | - Adjust the placementRule for the policy to target the correct clusters 10 | - Adjust the policy itself to target different namespaces. This can all be done in Git and will be reflected in the Red Hat ACM Hub -------------------------------------------------------------------------------- /policy/namespace/binding.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: mcm.ibm.com/v1alpha1 3 | kind: PlacementBinding 4 | metadata: 5 | name: binding-policy-namespace 6 | namespace: default 7 | placementRef: 8 | name: placement-policy-namespace 9 | kind: PlacementRule 10 | apiGroup: apps.open-cluster-management.io 11 | subjects: 12 | - name: policy-namespace 13 | kind: Policy 14 | apiGroup: policy.mcm.ibm.com -------------------------------------------------------------------------------- /policy/namespace/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - placementrule.yaml 3 | - policy.yaml 4 | - binding.yaml -------------------------------------------------------------------------------- /policy/namespace/placementrule.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: PlacementRule 4 | metadata: 5 | name: placement-policy-namespace 6 | namespace: default 7 | spec: 8 | clusterConditions: 9 | - type: OK 10 | clusterSelector: 11 | matchExpressions: [] -------------------------------------------------------------------------------- /policy/namespace/policy.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: policy.mcm.ibm.com/v1alpha1 3 | kind: Policy 4 | metadata: 5 | name: policy-namespace 6 | namespace: default 7 | annotations: 8 | policy.mcm.ibm.com/standards: NIST-CSF 9 | policy.mcm.ibm.com/categories: PR.IP Information Protection Processes and Procedures 10 | policy.mcm.ibm.com/controls: PR.IP-1 Baseline configuration 11 | spec: 12 | complianceType: musthave 13 | remediationAction: inform 14 | disabled: false 15 | namespaces: 16 | exclude: ["kube-*"] 17 | include: ["default"] 18 | object-templates: 19 | - complianceType: musthave 20 | objectDefinition: 21 | kind: Namespace # must have namespace 'prod' 22 | apiVersion: v1 23 | metadata: 24 | name: default 25 | 26 | 27 | -------------------------------------------------------------------------------- /policy/subscription/channel.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps.open-cluster-management.io/v1 3 | kind: Channel 4 | metadata: 5 | name: gitops 6 | namespace: demo 7 | spec: 8 | type: GitHub 9 | pathname: https://github.com/open-cluster-management/demo-subscription-gitops.git 10 | #secretRef: 11 | # name: my-github-secret -------------------------------------------------------------------------------- /policy/subscription/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - namespace.yaml 3 | #- secret.yaml 4 | - channel.yaml 5 | - subscription-policy.yaml -------------------------------------------------------------------------------- /policy/subscription/namespace.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Namespace 4 | metadata: 5 | name: demo 6 | 7 | -------------------------------------------------------------------------------- /policy/subscription/subscription-policy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps.open-cluster-management.io/v1 2 | kind: Subscription 3 | metadata: 4 | name: policy-subscription 5 | namespace: default 6 | annotations: 7 | apps.open-cluster-management.io/github-path: policy/namespace 8 | apps.open-cluster-management.io/github-branch: master 9 | spec: 10 | channel: demo/gitops 11 | placement: 12 | local: true 13 | 14 | --------------------------------------------------------------------------------