Skip to content

Commit

Permalink
Resolve suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Omar Farag <ofarag@redhat.com>
  • Loading branch information
o-farag committed Jun 7, 2023
1 parent c730c5f commit 58678fa
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 68 deletions.
5 changes: 1 addition & 4 deletions solutions/deploy-argocd-apps-pull/argocd-pull-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
The [ArgoCD](https://argo-cd.readthedocs.io/en/stable/) application controller uses the hub-spoke pattern or pull model mechanism for decentralized resource delivery to remote clusters.
By using [Open Cluster Management (OCM)](https://open-cluster-management.io/) APIs and components,
the ArgoCD Applications will be pulled from the multi-cluster control plane hub cluster down to
the registered OCM managed clusters. To try it out, check out the [Getting Started Guide](getting-started.md)
the registered OCM managed clusters. To try it out, check out the [Getting Started Guide](getting-started.md).

**Note:** The primary goal of this project is to migrate existing native OCM application delivery `AppSubscription` users to ArgoCD.
The pull model described in this project might not be suitable for every situation.
It is designed with the existing OCM AppSubscription users in mind to match their existing use cases.

## Overview
The current ArgoCD resource delivery is primarily pushing resources from a centralized cluster to the remote/managed clusters.
Expand Down
87 changes: 49 additions & 38 deletions solutions/deploy-argocd-apps-pull/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Getting Started

### Prerequisites
- [kind](https://kind.sigs.k8s.io) must be installed on your local machine. The Kubernetes version must be >= 1.19, see [kind user guide](https://kind.sigs.k8s.io/docs/user/quick-start/#creating-a-cluster) for more details.
-
- [kind](https://kind.sigs.k8s.io) must be installed on your local machine. The Kubernetes version must be >= 1.19. See the [kind user guide](https://kind.sigs.k8s.io/docs/user/quick-start/#creating-a-cluster) for more details.
- Download and install [clusteradm](https://github.com/open-cluster-management-io/clusteradm/releases). For Linux OS, run the following commands:

```
wget -qO- https://github.com/open-cluster-management-io/clusteradm/releases/latest/download/clusteradm_linux_amd64.tar.gz | sudo tar -xvz -C /usr/local/bin/
sudo chmod +x /usr/local/bin/clusteradm
```
- The [kubectl](https://kubernetes.io/docs/reference/kubectl/) cli, which should be compatible with your Kubernetes version. See [install and setup](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#before-you-begin) for more info.
### Steps
1. Setup an OCM Hub cluster and registered an OCM Managed cluster.
Expand All @@ -13,62 +20,65 @@
See [Open Cluster Management Quick Start](https://open-cluster-management.io/getting-started/quick-start/) for more details.
2. Install ArgoCD on the hub cluster and both managed clusters.
```
kubectl config use-context kind-hub #repeat for kind-cluster1 and kind-cluster2
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
```
See [ArgoCD website](https://argo-cd.readthedocs.io/en/stable/getting_started/) for more details.

3. On the Hub cluster, scale down the Application controller:
```
kubectl -n argocd scale statefulset/argocd-application-controller --replicas 0
for i in "hub" "cluster1" "cluster2"
do
kubectl config use-context kind-$i
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
done
```
**Note:** This step is not necssary if the ArgoCD instance you are using contains the feature:
https://argo-cd.readthedocs.io/en/latest/user-guide/skip_reconcile/
See [ArgoCD website](https://argo-cd.readthedocs.io/en/stable/getting_started/) for more details.
1. Install the Pull controller:
1. Install the Pull controller on the hub cluster:
```
kubectl config use-context kind-hub
kubectl apply -f https://raw.githubusercontent.com/open-cluster-management-io/argocd-pull-integration/main/deploy/install.yaml
```
1. If your controller starts successfully, you should see:
2. If your controller starts successfully, you should see:
```
$ kubectl -n open-cluster-management get deploy | grep pull
argocd-pull-integration-controller-manager 1/1 1 1 106s
```
1. On the Hub cluster, create an ArgoCD cluster secret that represents the managed cluster. This step can be automated with [OCM auto import controller](https://github.com/open-cluster-management-io/multicloud-integrations/).
3. On the Hub cluster, create ArgoCD cluster secrets that represent the managed clusters. This step can be automated with [OCM auto import controller](https://github.com/open-cluster-management-io/multicloud-integrations/).
**Note**: replace the `cluster-name` with the registered managed cluster name.
```
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: <cluster-name>-secret # cluster1-secret
namespace: argocd
labels:
argocd.argoproj.io/secret-type: cluster
type: Opaque
stringData:
name: <cluster-name> # cluster1
server: https://<cluster-name>-control-plane:6443 # https://cluster1-control-plane:6443
for i in "cluster1" "cluster2"
do
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: $i-secret # cluster1-secret
namespace: argocd
labels:
argocd.argoproj.io/secret-type: cluster
type: Opaque
stringData:
name: $i # cluster1
server: https://$i-control-plane:6443 # https://cluster1-control-plane:6443
EOF
done
```
1. On the Hub cluster, apply the manifests in `example/hub`:
4. On the Hub cluster, apply the manifests in `example/hub`:
```
kubectl config use-context kind-hub
kubectl apply -f example/hub
```
1. On the managed clusters, apply the manifests in `example/managed`:
5. On the managed clusters, apply the manifests in `example/managed`:
```
kubectl config use-context kind-cluster1 #repeat for kind-cluster2
kubectl apply -f example/managed
for i in "cluster1" "cluster2"
do
kubectl config use-context kind-$i
kubectl apply -f example/managed
done
```
1. On the Hub cluster, apply the `guestbook-app-set` manifest:
6. On the Hub cluster, apply the `guestbook-app-set` manifest:
```
kubectl apply -f example/guestbook-app-set.yaml
```
Expand All @@ -86,7 +96,7 @@
The `ocm-managed-cluster` annotation is for the ApplicationSet to generate multiple Application based on each cluster generator targets.
10. When this guestbook ApplicationSet reconciles, it will generate an Application for the registered ManagedCluster. For example:
7. When this guestbook ApplicationSet reconciles, it will generate an Application for the registered managed clusters. For example:
```
$ kubectl -n argocd get appset
NAME AGE
Expand All @@ -97,14 +107,14 @@
cluster2-guestbook-app Synced Healthy
```
11. On the Hub cluster, the pull controller will wrap the Application with a ManifestWork. For example:
8. On the Hub cluster, the pull controller will wrap the Application with a ManifestWork. For example:
```
$ kubectl -n cluster1 get manifestwork
NAME AGE
cluster1-guestbook-app-d0e5 2m41s
```
12. On a Managed cluster, you should see that the Application is pulled down successfully. For example:
9. On a managed cluster, you should see that the Application is pulled down successfully. For example:
```
$ kubectl -n argocd get app
NAME SYNC STATUS HEALTH STATUS
Expand All @@ -114,10 +124,11 @@
guestbook-ui 1/1 1 1 7m36s
```
13. On the Hub cluster, the status controller will sync the dormant Application with the ManifestWork status feedback. For example:
10. On the Hub cluster, the status controller will sync the dormant Application with the ManifestWork status feedback. For example:
```
$ kubectl -n argocd get app
NAME SYNC STATUS HEALTH STATUS
cluster1-guestbook-app Synced Healthy
cluster2-guestbook-app Synced Healthy
```
If you have issues or need help troubleshooting, check out the [troubleshooting guide](./troubleshooting.md)
29 changes: 3 additions & 26 deletions solutions/deploy-argocd-apps-pull/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#### For ArgoCD components, check the following containers for logs:
* argocd-pull-integration-* in the `open-cluster-management` namespace (only on the hub cluster)
* argocd-applicationset-controller
* argocd-application-controller (only on managed clusters)
* argocd-applicationset-controller in the `argocd` namespace
* argocd-application-controller (only on managed clusters) in the `argocd` namespace

#### If the ApplicationSet contains the following status:
```
Expand All @@ -15,28 +15,5 @@ status:
status: "False"
type: ErrorOccurred
```
Despite the type `ErrorOccurred`, the status is `"False"`, which means the ApplicationSet has been reconciled successfully. If the status is `"True"`, check the error message. If needed, check the `openshift-gitops-applicationset-controller` pod logs in the `openshift-gitops` namespace.

## Known Issues
* ArgoCD application only supports Git and Helm Repo. Object Storage is not supported.
* Resources are only deployed on the managed cluster(s).
* If a resource failed to be deployed, it won’t be included in the Multicluster ApplicationSet Report
* In the pull model, the local-cluster is excluded as target managed cluster
* For large environments with over 1000 managed clusters, ArgoCD applicationSets are deployed to hundreds of managed clusters. It may take several minutes for the ArgoCD application to be created on the hub cluster
* Workaround is to set the `requeueAfterSeconds` field to a higher value in the `clusterDecisionResource` generator of the ApplicationSet:
```
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: cm-allclusters-app-set
namespace: openshift-gitops
spec:
generators:
- clusterDecisionResource:
configMapRef: ocm-placement-generator
labelSelector:
matchLabels:
cluster.open-cluster-management.io/placement: app-placement
requeueAfterSeconds: 3600 # 1 hour
```
Despite the type `ErrorOccurred`, the status is `"False"`, which means the ApplicationSet has been reconciled successfully. If the status is `"True"`, check the error message. If needed, check the `argocd-applicationset-controller` pod logs in the `argocd` namespace.

0 comments on commit 58678fa

Please sign in to comment.