Skip to content

Commit

Permalink
docs: Add example for ArgoCD (#179)
Browse files Browse the repository at this point in the history
Co-authored-by: Giovanni Liva <giovanni.liva@dynatrace.com>
  • Loading branch information
thschue and thisthat committed Oct 18, 2022
1 parent c2ab773 commit daf622d
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 432 deletions.
64 changes: 64 additions & 0 deletions examples/argo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
LFC_NAMESPACE ?= keptn-lifecycle-controller-system
PODTATO_NAMESPACE ?= podtato-kubectl
ARGO_NAMESPACE ?= argocd
ARGO_VERSION ?= 2.4.14
ARGO_SECRET = $(shell kubectl -n ${ARGO_NAMESPACE} get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo)

.PHONY: install
install:
@echo "-----------------------------------"
@echo "Create Namespace and install ArgoCD"
@echo "-----------------------------------"
kubectl create namespace $(ARGO_NAMESPACE)
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v$(ARGO_VERSION)/manifests/install.yaml

@echo ""
@echo "-------------------------------"
@echo "Wait for Resources to get ready"
@echo "-------------------------------"
kubectl wait --for=condition=available deployment/argocd-dex-server -n "$(ARGO_NAMESPACE)" --timeout=120s
kubectl wait --for=condition=available deployment/argocd-redis -n "$(ARGO_NAMESPACE)" --timeout=120s
kubectl wait --for=condition=available deployment/argocd-repo-server -n "$(ARGO_NAMESPACE)" --timeout=120s
kubectl wait --for=condition=available deployment/argocd-server -n "$(ARGO_NAMESPACE)" --timeout=120s


@echo ""
@echo "#######################################################"
@echo "ArgoCD Demo installed"
@echo "- Get Admin Password: make argo-get-password"
@echo "- Port-Forward ArgoCD: make port-forward-argocd"
@echo "- Get Argo CLI: https://argo-cd.readthedocs.io/en/stable/cli_installation/"
@echo "- Configure ArgoCD CLI (needs port-forward): make argo-configure-cli"
@echo "- Install PodTatoHead via ArgoCD: make argo-install-podtatohead"
@echo "#######################################################"

.PHONY: argo-configure-cli
argo-configure-cli:
@argocd login localhost:8080 --username admin --password $(ARGO_SECRET) --insecure

.PHONY: argo-get-password
argo-get-password:
@echo $(ARGO_SECRET)

.PHONY: port-forward-argocd
port-forward-argocd:
@echo ""
@echo "Open ArgoCD in your Browser: http://localhost:8080"
@echo "CTRL-c to stop port-forward"

@echo ""
kubectl port-forward svc/argocd-server -n "$(ARGO_NAMESPACE)" 8080:443

.PHONY: argo-install-podtatohead
argo-install-podtatohead:
@echo ""
kubectl apply -f config/app.yaml -n "$(ARGO_NAMESPACE)"

.PHONY: uninstall
uninstall:
kubectl delete -n $(ARGO_VERSION) -f https://raw.githubusercontent.com/argoproj/argo-cd/v$(ARGO_VERSION)/manifests/install.yaml --ignore-not-found=true
kubectl delete namespace $(ARGO_NAMESPACE) --ignore-not-found=true
@echo ""
@echo "##########################"
@echo "Argo Demo deleted"
@echo "##########################"
60 changes: 60 additions & 0 deletions examples/argo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Deploying an application using the Keptn Lifecycle Controller and ArgoCD

In this example, we will show you how to install our sample application *podtatohead* using the Keptn Lifecycle Controller and [ArgoCD](https://argo-cd.readthedocs.io/en/stable/).

# TL;DR
* You can install ArgoCD using: `make install`
* Afterward, you can fetch the secret for the ArgoCD CLI using: `make argo-get-password`
* Then you can port-forward the ArgoUI using: `make argo-port-forward`
* Alternatively, you can access Argo using the CLI, configure it using `make argo-configure-cli`
* Deploy the PodTatoHead Demo Application: `make argo-install-podtatohead`
* Watch the progress on your ArgoUI: `http://localhost:8080`

## Prerequisites:
This tutorial assumes, that you already installed the Keptn Lifecycle Controller (see https://github.com/keptn-sandbox/lifecycle-service). Furthermore, you have to install ArgoCD, as in the following their [installation instructions](https://argoproj.github.io/argo-cd/getting_started/).

### Install ArgoCD
If you don't have an already existing installation of ArgoCD, you can install it using the following commands:
```shell
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/latest/manifests/install.yaml
```

With these commands, ArgoCD will be installed in the `argocd` namespace.

After that, you can find the password for ArgoCD using the following command:
```shell
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
```

### Port-Forward ArgoCD and access the UI
To access the ArgoCD UI, you can port-forward the ArgoCD service using the following command:
```shell
kubectl port-forward svc/argocd-server -n argocd 8080:443
```
Then you can access the UI using http://localhost:8080.

## Installing the Demo Application
To install the demo application, you can use the following command:
```shell
kubectl apply -f https://raw.githubusercontent.com/keptn-sandbox/lifecycle-service/main/examples/argo/config/app.yaml
```

You will see that the application will be deployed using ArgoCD. You can watch the progress on the ArgoCD UI and should see the following:
![img.png](assets/argo-screen.png)

In the meanwhile you can watch the progress of the deployment using:
> `kubectl get pods -n podtato-kubectl`
* See that the pods are pending until the pre-deployment tasks have passed
* Pre-Deployment Tasks are started
* Pods get scheduled

> `kubectl get keptnworkloadinstances -n podtato-kubectl`
* Get the current status of the workloads
* See in which phase your workload deployments are at the moment

> `kubectl get keptnapplicationversions -n podtato-kubectl`
* Get the current status of the application
* See in which phase your application deployment is at the moment

After some time all resources should be in a succeeded state. In the Argo-UI you will see that the application is in sync.
Binary file added examples/argo/assets/argo-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions examples/argo/config/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: podtato-head
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/thschue/lifecycle-controller
targetRevision: main
path: examples/podtatohead-deployment
destination:
server: https://kubernetes.default.svc
namespace: podtato-kubectl
syncPolicy:
automated:
selfHeal: true
prune: true
1 change: 0 additions & 1 deletion examples/argo/podtatohead/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions examples/argo/podtatohead/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions examples/argo/podtatohead/app.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions examples/argo/podtatohead/check_entry.yaml

This file was deleted.

Loading

0 comments on commit daf622d

Please sign in to comment.