original
This commit is contained in:
commit
f9f3f02afe
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2023 Sam
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
118
README.md
Normal file
118
README.md
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
# Overview
|
||||||
|
In this demo we will learn the basics of ArgoCD
|
||||||
|
|
||||||
|
## Install the School App
|
||||||
|
```bash
|
||||||
|
# Setup MongoDB DB in K8s
|
||||||
|
kubectl create ns schoolapp
|
||||||
|
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||||
|
helm install schoolapp-mongodb --namespace schoolapp \
|
||||||
|
--set auth.enabled=true \
|
||||||
|
--set auth.rootUser=schoolapp \
|
||||||
|
--set auth.rootPassword=mongoRootPass \
|
||||||
|
bitnami/mongodb
|
||||||
|
|
||||||
|
# Add project repo to helm
|
||||||
|
helm repo add schoolapp https://gitlab.com/api/v4/projects/34240616/packages/helm/stable
|
||||||
|
|
||||||
|
# Install the Frontend
|
||||||
|
helm install frontend -n schoolapp schoolapp/schoolapp-frontend
|
||||||
|
# Install the API
|
||||||
|
helm install api -n schoolapp schoolapp/schoolapp-api
|
||||||
|
# Port forward the frontend
|
||||||
|
kubectl -n schoolapp port-forward service/frontend 8001:8080
|
||||||
|
# Port forward the api
|
||||||
|
kubectl -n schoolapp port-forward service/api 5000:5000
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test the School App
|
||||||
|
|
||||||
|
From a browser, go to http://127.0.0.1:8001
|
||||||
|
|
||||||
|
## ArgoCD Setup
|
||||||
|
|
||||||
|
Now let's get ArgoCD ready for our school app.
|
||||||
|
|
||||||
|
## Install ArgoCD
|
||||||
|
|
||||||
|
### Install the ArgoCD Server
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl create namespace argocd
|
||||||
|
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
Wait until all the pods are running
|
||||||
|
|
||||||
|
```bash
|
||||||
|
watch kubectl get po
|
||||||
|
```
|
||||||
|
|
||||||
|
## Access ArgoCD
|
||||||
|
|
||||||
|
### Expose the ArgoCD API Server
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl port-forward svc/argocd-server -n argocd 8002:443
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get the admin password
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
|
||||||
|
```
|
||||||
|
|
||||||
|
For this demo, I won't change the password, but you should go ahead and change the password and remove the K8s secret.
|
||||||
|
|
||||||
|
### Login using the UI
|
||||||
|
|
||||||
|
You can log in to the UI by opening a browser window and going to https://127.0.0.1:8002
|
||||||
|
|
||||||
|
```bash
|
||||||
|
username: admin
|
||||||
|
password: <THE_PASSWORD_YOU_GOT_ABOVE>
|
||||||
|
```
|
||||||
|
|
||||||
|
## School App Example with ArgoCD and Hardcoded Secrets
|
||||||
|
|
||||||
|
Now let's see how to use a GitOps approach with ArgoCD to run our school app.
|
||||||
|
|
||||||
|
## Delete the Current School App
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl delete ns schoolapp
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create the School App Application in ArgoCD
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl apply -f argocdSchoolApp.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test the School App with ArgoCD
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Port forward the frontend
|
||||||
|
kubectl port-forward service/frontend 8001:8080 -n schoolapp
|
||||||
|
# Port forward the api
|
||||||
|
kubectl port-forward service/api 5000:5000 -n schoolapp
|
||||||
|
```
|
||||||
|
|
||||||
|
Try creating and deleting a course and check the logs of the api pod.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl logs -n schoolapp -f $(kubectl get pods --template '{{range .items}}{{.metadata.name}}{{end}}' --selector=app=api) -c api
|
||||||
|
```
|
||||||
|
|
||||||
|
## Making a Change in Git
|
||||||
|
|
||||||
|
Now let's see how Argo CD can detect drift between the live state and the target state. Let's make a simple change in our Git repo for the called schoolapp-subchart/values.yaml. Change the mongodb.auth.enabled value from true to false.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
mongodb:
|
||||||
|
auth:
|
||||||
|
enabled: false
|
||||||
|
rootUser: 'schoolapp'
|
||||||
|
rootPassword: 'mongoRootPass'
|
||||||
|
```
|
||||||
|
Then commit and push your changes.
|
||||||
17
argocdSchoolApp.yaml
Normal file
17
argocdSchoolApp.yaml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: schoolapp
|
||||||
|
namespace: argocd
|
||||||
|
spec:
|
||||||
|
destination:
|
||||||
|
namespace: schoolapp
|
||||||
|
server: 'https://kubernetes.default.svc'
|
||||||
|
source:
|
||||||
|
path: schoolapp-subchart
|
||||||
|
repoURL: 'https://github.com/samgabrail/env0-argocd.git'
|
||||||
|
targetRevision: HEAD
|
||||||
|
project: default
|
||||||
|
syncPolicy:
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
12
schoolapp-subchart/Chart.lock
Normal file
12
schoolapp-subchart/Chart.lock
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
dependencies:
|
||||||
|
- name: schoolapp-frontend
|
||||||
|
repository: https://gitlab.com/api/v4/projects/34240616/packages/helm/stable
|
||||||
|
version: 0.5.8
|
||||||
|
- name: schoolapp-api
|
||||||
|
repository: https://gitlab.com/api/v4/projects/34240616/packages/helm/stable
|
||||||
|
version: 0.5.8
|
||||||
|
- name: mongodb
|
||||||
|
repository: https://charts.bitnami.com/bitnami
|
||||||
|
version: 11.1.1
|
||||||
|
digest: sha256:011d9f270e259d2fa11a8fe98444957281741c23b95c12f11c292c030539e7f3
|
||||||
|
generated: "2022-05-10T20:08:39.4974464Z"
|
||||||
16
schoolapp-subchart/Chart.yaml
Normal file
16
schoolapp-subchart/Chart.yaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v2
|
||||||
|
name: schoolapp-subchart
|
||||||
|
type: application
|
||||||
|
version: 1.0.0
|
||||||
|
appVersion: "1.0.0"
|
||||||
|
dependencies:
|
||||||
|
- name: schoolapp-frontend
|
||||||
|
version: 0.5.8
|
||||||
|
repository: https://gitlab.com/api/v4/projects/34240616/packages/helm/stable
|
||||||
|
- name: schoolapp-api
|
||||||
|
version: 0.5.8
|
||||||
|
repository: https://gitlab.com/api/v4/projects/34240616/packages/helm/stable
|
||||||
|
- name: mongodb
|
||||||
|
version: 11.1.1
|
||||||
|
repository: https://charts.bitnami.com/bitnami
|
||||||
BIN
schoolapp-subchart/charts/mongodb-11.1.1.tgz
Normal file
BIN
schoolapp-subchart/charts/mongodb-11.1.1.tgz
Normal file
Binary file not shown.
BIN
schoolapp-subchart/charts/schoolapp-api-0.5.8.tgz
Normal file
BIN
schoolapp-subchart/charts/schoolapp-api-0.5.8.tgz
Normal file
Binary file not shown.
BIN
schoolapp-subchart/charts/schoolapp-frontend-0.5.8.tgz
Normal file
BIN
schoolapp-subchart/charts/schoolapp-frontend-0.5.8.tgz
Normal file
Binary file not shown.
13
schoolapp-subchart/values.yaml
Normal file
13
schoolapp-subchart/values.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# This is a YAML-formatted file.
|
||||||
|
# Declare variables to be passed into your templates.
|
||||||
|
|
||||||
|
mongodb:
|
||||||
|
auth:
|
||||||
|
enabled: true
|
||||||
|
rootUser: 'schoolapp'
|
||||||
|
rootPassword: 'mongoRootPass'
|
||||||
|
|
||||||
|
schoolapp-api:
|
||||||
|
vault:
|
||||||
|
status: 'disabled'
|
||||||
|
kind: 'disabled'
|
||||||
Loading…
x
Reference in New Issue
Block a user