Skip to content

Commit

Permalink
gitops
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzheng422 committed Nov 7, 2024
1 parent 49d4f00 commit cc4eddd
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 2 deletions.
100 changes: 98 additions & 2 deletions redhat/ocp4/4.16/2024.10.acm.aap.collect.heap.dump.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,113 @@ And define the job template.

# gitops source code

Our code example:
Our code example, we have gitops code and ansible playbook code in the same repo:

- https://github.com/wangzheng422/demo-acm-app-gitops

Use upstream k8s_core collection:

- https://docs.ansible.com/ansible/latest/collections/kubernetes/core/k8s_exec_module.html#ansible-collections-kubernetes-core-k8s-exec-module



<!-- - https://github.com/ansible/awx-resource-operator/blob/devel/roles/jobtemplate/tasks/main.yml -->

# deploy app using gitops

We will use `argocd push mode`, because the pull mode needs addtional configuration.

- https://github.com/ansible/awx-resource-operator/blob/devel/roles/jobtemplate/tasks/main.yml
![](imgs/2024.10.acm.aap.collect.heap.dump.md/2024-11-07-17-40-37.png)

Set the application name, and select the argo server, which runs on the hub cluster. Also switch on the yaml button, you can see the yaml file that will be created.

![](imgs/2024.10.acm.aap.collect.heap.dump.md/2024-11-07-17-41-47.png)

Select git type, set the github url, branch, and the path to the yaml that will be deployed. And set the target namespace, which will be created on the target ocp cluster.

![](imgs/2024.10.acm.aap.collect.heap.dump.md/2024-11-07-17-43-10.png)

Set the sync policy, which will be applied to argo cd.

![](imgs/2024.10.acm.aap.collect.heap.dump.md/2024-11-07-17-43-39.png)

And set the placement, which will tell argo cd which target cluster are.

![](imgs/2024.10.acm.aap.collect.heap.dump.md/2024-11-07-17-44-54.png)

For the placement, there is expression, which is the cluster name, which is sno-demo. And we can see you can select the cluster based on different labels.

![](imgs/2024.10.acm.aap.collect.heap.dump.md/2024-11-07-17-45-28.png)

And match the value with different logic.

![](imgs/2024.10.acm.aap.collect.heap.dump.md/2024-11-07-17-46-01.png)

```yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: java-app-threads
namespace: openshift-gitops
creationTimestamp: 2024-11-05T10:55:00Z
generation: 1
resourceVersion: "4491547"
uid: b515a956-6fcd-4e54-8adb-bec14ecd00e5
spec:
generators:
- clusterDecisionResource:
configMapRef: acm-placement
labelSelector:
matchLabels:
cluster.open-cluster-management.io/placement: java-app-threads-placement
requeueAfterSeconds: 180
template:
metadata:
name: java-app-threads-{{name}}
labels:
velero.io/exclude-from-backup: "true"
spec:
destination:
namespace: wzh-demo-01
server: "{{server}}"
project: default
sources:
- path: gitops/threads
repoURL: https://github.com/wangzheng422/demo-acm-app-gitops
targetRevision: main
repositoryType: git
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
- PruneLast=true
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
name: java-app-threads-placement
namespace: openshift-gitops
creationTimestamp: 2024-11-05T09:28:39Z
generation: 1
resourceVersion: "4486490"
uid: f34d925a-2f32-451f-8d9d-27689288e303
spec:
predicates:
- requiredClusterSelector:
labelSelector:
matchExpressions:
- key: name
operator: In
values:
- sno-demo
```
# create job/job template in aap
# Maintain multi-cluster consistency using policy
# end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cc4eddd

Please sign in to comment.