Skip to content

Commit

Permalink
Merge pull request #109 from Michkov/preview-selective
Browse files Browse the repository at this point in the history
Allow to select mode during bootstrap, allow to select application for deployment
  • Loading branch information
Michkov authored Feb 17, 2022
2 parents bbd829b + 922d968 commit d348f97
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ If you don't already have a test OpenShift cluster available, CodeReady Containe

### Bootstrap App Studio
Steps:
1) Run `./hack/bootstrap-cluster.sh` which will bootstrap Argo CD (using OpenShift GitOps) and setup the Argo CD `Application` Custom Resources (CRs) for each component. This command will output the Argo CD Web UI route when it's finished.
1) Run `./hack/bootstrap-cluster.sh [$MODE]` which will bootstrap Argo CD (using OpenShift GitOps) and setup the Argo CD `Application` Custom Resources (CRs) for each component. This command will output the Argo CD Web UI route when it's finished. For upstream mode keep the $MODE empty or "upstream". For development mode and preview mode set `$MODE` to `development` or `preview`, the modes are described in section 'Development modes for your own clusters'.
2) Open the Argo CD Web UI to see the status of your deployments. You can use the route from the previous step and login using your OpenShift credentials (using the 'Login with OpenShift' button), or login to the OpenShift Console and navigate to Argo CD using the OpenShift Gitops menu in the Applications pulldown.
![OpenShift Gitops menu with Cluster Argo CD menu option](documentation/images/argo-cd-login.png?raw=true "OpenShift Gitops menu")
3) If your deployment was successful, you should see several applications running, such as "all-components-staging", "gitops", and so on.
Expand Down Expand Up @@ -121,7 +121,7 @@ Even with 6 CPU cores, you will need to reduce the CPU resource requests for eac

## Development modes for your own clusters

Once you bootstrap a cluster above, the root ArgoCD Application and all of the component applications will each point to the upstream repository.
Once you bootstrap a cluster above, the root ArgoCD Application and all of the component applications will each point to the upstream repository. Or you can bootstrap cluster directly in mode which you need.

To enable development for a team or individual to test changes on your own cluster, you need to replace the references to `https://github.com/redhat-appstudio/infra-deployments.git` with references to your own fork.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
Expand Down
2 changes: 1 addition & 1 deletion argo-cd-apps/overlays/development/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
patchesStrategicMerge:
- repo-overlay.yaml
- delete-auth.yaml
- delete-applications.yaml



8 changes: 8 additions & 0 deletions argo-cd-apps/overlays/development/repo-overlay.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: build
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
source: # This will be replaced with a reference to your fork of this repo (see hack/patch-apps-for-dev.sh)
repoURL: https://github.com/redhat-appstudio/infra-deployments.git
Expand All @@ -11,6 +13,8 @@ apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: gitops
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
source:
repoURL: https://github.com/redhat-appstudio/infra-deployments.git
Expand All @@ -20,6 +24,8 @@ apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: has
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
source:
repoURL: https://github.com/redhat-appstudio/infra-deployments.git
Expand All @@ -29,6 +35,8 @@ apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: spi
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
source:
repoURL: https://github.com/redhat-appstudio/infra-deployments.git
Expand Down
14 changes: 12 additions & 2 deletions hack/bootstrap-cluster.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

MODE=$1

ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/..

if [ "$(oc auth can-i '*' '*' --all-namespaces)" != "yes" ]; then
Expand Down Expand Up @@ -46,8 +48,16 @@ echo "Add Role/RoleBindings for OpenShift GitOps:"
kustomize build $ROOT/openshift-gitops/cluster-rbac | kubectl apply -f -

echo
echo "Add parent Argo CD Application:"
kubectl apply -f $ROOT/argo-cd-apps/app-of-apps/all-applications-staging.yaml
if [ "$MODE" == "" ] || [ "$MODE" == "upstream" ]; then
echo "Setting Cluster Mode: Upstream"
kubectl apply -f $ROOT/argo-cd-apps/app-of-apps/all-applications-staging.yaml
elif [ "$MODE" == "development" ]; then
echo "Setting Cluster Mode: Development"
$ROOT/hack/development-mode.sh
elif [ "$MODE" == "preview" ]; then
echo "Setting Cluster Mode: Preview"
$ROOT/hack/preview.sh
fi

ARGO_CD_URL="https://$(kubectl get route/openshift-gitops-server -n openshift-gitops -o template --template={{.spec.host}})"

Expand Down
12 changes: 7 additions & 5 deletions hack/destroy-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ echo "Removing GitOps operator and operands:"

while : ; do
kubectl patch argocd/openshift-gitops -n openshift-gitops -p '{"metadata":{"finalizers":null}}' --type=merge
kubectl delete csv/openshift-gitops-operator.v1.3.0 -n openshift-operators
kubectl delete csv/openshift-gitops-operator.v1.3.0 -n openshift-gitops
kubectl delete csv/openshift-gitops-operator.v1.3.1 -n openshift-operators
kubectl delete csv/openshift-gitops-operator.v1.3.1 -n openshift-gitops
OPERATORS=$(oc get clusterserviceversions.operators.coreos.com -o name)
for OPERATOR in $OPERATORS; do
if echo $OPERATOR | grep -q openshift-gitops-operator; then
kubectl delete $OPERATOR
fi
done
kubectl delete namespace --timeout=30s openshift-gitops

kubectl get namespace/openshift-gitops
Expand All @@ -45,4 +47,4 @@ git clone --depth=1 https://github.com/codeready-toolchain/toolchain-e2e.git ${T
make -C ${TOOLCHAIN_E2E_TEMP_DIR} appstudio-cleanup

echo
echo "Complete."
echo "Complete."
4 changes: 4 additions & 0 deletions hack/preview-template.env
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ export SHARED_SECRET= # Random string
export SPI_TYPE= # GitHub
export SPI_CLIENT_ID=
export SPI_CLIENT_SECRET=

## Appliction management
### Deploy only listed applications
export DEPLOY_ONLY=""
18 changes: 17 additions & 1 deletion hack/util-set-development-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,20 @@ yq e '.metadata.name' $OVERLAYDIR/repo-overlay.yaml
echo
echo Each component above is set to the following repositories
echo if you do not see your component in the list, please send a PR update to $OVERLAYDIR/repo-overlay.yaml
yq e '.spec.source.repoURL' $OVERLAYDIR/repo-overlay.yaml
yq e '.spec.source.repoURL' $OVERLAYDIR/repo-overlay.yaml

if [ -n "$DEPLOY_ONLY" ]; then
for APP in $(yq e -N '.metadata.name' $OVERLAYDIR/repo-overlay.yaml); do
if ! grep "\b$APP\b" <<< $DEPLOY_ONLY; then
echo Disabling $APP based on DEPLOY_ONLY variable
cat >> $OVERLAYDIR/delete-applications.yaml <<EOF
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: $APP
\$patch: delete
EOF
fi
done
fi

0 comments on commit d348f97

Please sign in to comment.