Example repository demonstrating gitops with Kustomize and ArgoCD.
- CRD: Kubernetes Custom Resource Definitions. ArgoCD expands the kubernetes api with new resources, for example: "Application", "ApplicationSet" (CRDs)
- Application: A group of Kubernetes resources as defined by a manifest. This is a Custom Resource Definition (CRD).
- ApplicationSet: This CRD is used to generate multiple Applications based on different 'generators' - for example directories in a path.
Fork this repository.
Change namespace in the following files:
infra/kustomize/base/kustomization.yaml
infra/kustomize/overlays/dev/kustomization.yaml
infra/kustomize/overlays/test/kustomization.yaml
infra/kustomize/overlays/prod/kustomization.yamlChange namespace in the above files from "example" to something unique to avoid naming-collisions.
Important: Keep the -dev/-test/-prod suffixes.
Update .metadata.name in the following files:
./argo/infra/application-set.yaml
./argo/infra/example-application.yaml
./argo/bootstrap-application.yamlChange the .metadata.name in the above files to something unique and of your choosing to avoid name-collisions.
Update ./argo/infra/application-set.yaml:
To point the ApplicationSet to your git repository, change "repoURL" references:
- Change
.spec.generators[].git.repoURLto your git url - Change
spec.template.spec.source.repoURLto your git url
Change the generated application template name to avoid namecollisions:
- Change
.spec.template.metadata.name
Push the changes in step 2 and 3 to your forked git repository.
Argo -> New app ->
General:
Application Name: Up to you
Project Name: workshop
Source:
Repository URL: Your forked project # HTTPS Git URL (.git at the end)
Path: infra/kustomize/overlays/test
Destination:
Cluster URL: https://kubernetes.default.svc # Same cluster as Argo.or
oc apply -f argo/infra/example-application.yaml
oc apply -f argo/infra/application-set.yaml
or use OpenShift GUI (+)-button
Delete your application and applicationset in Argo
Create ./argo/bootstrap-application.yaml in OpenShift Console ( +-button), or in the terminal: oc apply -f ./argo/bootstrap-application.yaml
π 8 - Bonus: Create an OpenShift Route to expose web application in "./infra/kustomize/overlays/prod"
Example: (Modify name, namespace ('prod'), and host)
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: example-route
namespace: example-prod
spec:
host: example.com
to:
kind: Service
name: example
weight: 100
port:
targetPort: http
tls:
termination: edge
wildcardPolicy: None
Delete your bootstrap application in ArgoCD ('Delete')
ArgoCD: https://argo-cd.readthedocs.io/en/stable/
ArgoCD + Kustomize: https://argo-cd.readthedocs.io/en/stable/user-guide/kustomize/
ArgoCD ApplicationSets: https://argo-cd.readthedocs.io/en/stable/user-guide/application-set/
ArgoCD App of App pattern: https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#app-of-apps
OpenShift: https://docs.openshift.com/
Kubernetes: https://kubernetes.io/docs/home/
Main example image used: https://github.com/nkzk/go-stdout
Example web application: https://github.com/nkzk/example-go-image