Skip to content

Commit

Permalink
Merge pull request #339 from stakater/correct-bullet-points-numbering
Browse files Browse the repository at this point in the history
Update docs for deploying environment in outer loop using gitops
  • Loading branch information
owais-rehman authored Nov 19, 2024
2 parents 1e6c226 + 689d2c7 commit 9db4e0f
Showing 1 changed file with 95 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,90 +2,102 @@

Lets see how can we add an environment to an application in a tenant. Lets say, we have added a production cluster and want to add a new environment in application for it to be deployed on production.

1. Create a folder named `production` at `<tenant-name>/<app-name>` which corresponds to the production environment. Suppose `gabbar` as tenant name, `stakater-nordmart-review` as application name, `production` as cluster name, `prod` as environment name.

```bash
└── gabbar
└── stakater-nordmart-review
└── prod
```

1. Create a folder named `<cluster-name>` at `<tenant-name>/<app-name>` which corresponds to the production environment. Suppose `<tenant-name>` as tenant name, `<app-name>` as application name, `<cluster-name>` as cluster name, `<env-name>` as environment name.
```bash
└── <tenant-name>
└── <app-name>
└── <env-name>
```
1. Add the Helm Chart of your application with production environment configurations.

```bash
└── gabbar
└── stakater-nordmart-review
└── prod
├── Chart.yaml
├── values.yaml
└── templates/
```

1. Add an folder `prod` inside `<tenant-name>/argocd-apps`. Add an ArgoCD Application in this folder which points to `<tenant-name>/<app-name>/prod`.

```yaml
# Name: stakater-nordmart-review.yaml(APP_NAME.yaml)
# Path: gabbar/argocd-apps/prod (TENANT_NAME/ argocd-apps/ENV_NAME/)
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: gabbar-prod-stakater-nordmart-review
namespace: openshift-gitops
spec:
destination:
namespace: TARGET_NAMESPACE
server: 'https://kubernetes.default.svc'
project: gabbar
source:
path: gabbar/stakater-nordmart-review/prod
repoURL: 'APPS_GITOPS_REPO_URL'
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
```
1. Add a folder called production (if not present) corresponding to the cluster name inside `argocd-apps` at root level, Add an ArgoCD Application in this folder which points to `<tenant-name>/argocd-apps/prod`.

```yaml
# Name: gabbar-prod.yaml (TENANT_NAME-ENV_NAME.yaml)
# Path: argocd-apps/prod
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: gabbar-prod
namespace: openshift-gitops
spec:
destination:
namespace: TARGET_NAMESPACE
server: 'https://kubernetes.default.svc'
project: gabbar
source:
path: gabbar/argocd-apps/prod
repoURL: 'APPS_GITOPS_REPO_URL'
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
```

```bash
└── <tenant-name>
└── <app-name>
└── <env-name>
├── Chart.yaml
├── values.yaml
└── templates/
```
1. Add an folder `<env-name>` inside `<tenant-name>/argocd-apps`. Add an ArgoCD Application in this folder which points to `<tenant-name>/<app-name>/<env-name>`.
```yaml
# Name: <app-name>.yaml(APP_NAME.yaml)
# Path: <tenant-name>/argocd-apps/<env-name> (TENANT_NAME/ argocd-apps/ENV_NAME/)
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: <tenant-name>-<env-name>-<app-name>
namespace: rh-openshift-gitops-instance
spec:
destination:
namespace: <target-namespace>
server: 'https://kubernetes.default.svc'
project: <tenant-name>
source:
path: <tenant-name>/<app-name>/<env-name>
repoURL: <apps-gitops-repo-url>
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
```
1. Add a folder called production (if not present) corresponding to the cluster name inside `argocd-apps` at root level, Add an ArgoCD Application in this folder which points to `<tenant-name>/argocd-apps/<env-name>`.
```yaml
# Name: <tenant-name>-<env-name>.yaml (TENANT_NAME-ENV_NAME.yaml)
# Path: argocd-apps/<env-name>
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: <tenant-name>-<env-name>
namespace: rh-openshift-gitops-instance
spec:
destination:
namespace: <target-namespace>
server: 'https://kubernetes.default.svc'
project: <tenant-name>
source:
path: <tenant-name>/argocd-apps/<env-name>
repoURL: <apps-gitops-repo-url>
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
```
1. You should have a similar folder structure at the end:

```bash
├── <tenant-name>
| ├── <app-name>
| | ├── <env-name>
| | | ├── Chart.yaml
| | | ├── values.yaml
| | └── └── templates/
├── └── argocd-apps
| └── <env-name>
| └── <app-name>.yaml
└── argocd-apps
└── <cluster-name> (cluster name)
└── <tenant-name>-prod.yaml
```

1. Make sure Application that deploys applications inside `argocd-apps/cluster-name/` folder is deployed in relevant `infra-gitops-config` repository.

```bash
├── gabbar
| ├── stakater-nordmart-review
| | ├── prod
| | | ├── Chart.yaml
| | | ├── values.yaml
| | └── └── templates/
├── └── argocd-apps
| └── prod
| └── stakater-nordmart-review.yaml
└── argocd-apps
└── production (cluster name)
└── gabbar-prod.yaml
```
!!! note
Anything defined in `<angle brackets>` are values that needs to be replaced according to specific needs.

1. Make sure Application that deploys applications inside `argocd-apps/cluster-name/` folder is deployed in relevant `infra-gitops-config` repository.
Brief details about what each key means is defined below:

1. `tenant-name`: Name of the tenant where this environment needs to be deployed.
1. `app-name`: Name of the application where this environment will be used.
1. `cluster-name`: Name of the cluster.
1. `env-name`: Name of the environment.
1. `target-namespace`: Name of the namespace where this environment will be deployed.
1. `apps-gitops-repo-url`: URL for Apps GitOps repository.

0 comments on commit 9db4e0f

Please sign in to comment.