Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add example for ArgoCD #179

Merged
merged 14 commits into from
Oct 18, 2022
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 "##########################"
64 changes: 64 additions & 0 deletions examples/argo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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`
* This will need a slack-secret as described [here](../podtatohead-deployment/README.md#Create-Secret-for-Slack-here)
* 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
thisthat marked this conversation as resolved.
Show resolved Hide resolved
```

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
* You might notice that post-deployment-tasks fail (this is expected, as the secret for the post-deployment task is not available)
* Therefore, you can create the post-deployment secret using the following command:
* `kubectl create secret generic slack-notification --from-literal=SECURE_DATA='{"slack_hook":"<WebHook>","text":"Deployed PodTatoHead Application"}' -n podtato-kubectl`

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