commit 77dc5eb01cc1f5ca95809d9348e22a2fc48fd08b Author: Mathod Date: Mon Nov 17 18:21:05 2025 +0100 init diff --git a/README.md b/README.md new file mode 100644 index 0000000..0185972 --- /dev/null +++ b/README.md @@ -0,0 +1,118 @@ +```shell +kind create cluster --config management.yaml +kind create cluster --config staging.yaml +kind create cluster --config production.yaml +``` + +```shell +kctx kind-management +``` + +``` +export GIT_TOKEN= +export GIT_REPO=https://github.com/Mathod95/courses/courses_002/autopilot +``` + +```shell +argocd-autopilot repo bootstrap +or +argocd-autopilot repo bootstrap --recover +``` + +```shell +INFO argocd initialized. password: +INFO run: + + kubectl port-forward -n argocd svc/argocd-server 8080:80 +``` + +```shell +kns argocd +``` + +```shell +❯ argocd login --core +Context 'kubernetes' updated + +❯ argocd cluster list +SERVER NAME VERSION STATUS MESSAGE PROJECT +https://kubernetes.default.svc in-cluster 1.32 Successful + +❯ argocd cluster add +CURRENT NAME CLUSTER SERVER +* kind-management kind-management https://127.0.0.1:41469 + kind-production kind-production https://127.0.0.1:44821 + kind-staging kind-staging https://127.0.0.1:40971 + +❯ argocd cluster add kind-production --project production +WARNING: This will create a service account `argocd-manager` on the cluster referenced by context `kind-production` with full cluster level privileges. Do you want to continue [y/N]? y +{"level":"info","msg":"ServiceAccount \"argocd-manager\" created in namespace \"kube-system\"","time":"2025-05-11T17:49:02+02:00"} +{"level":"info","msg":"ClusterRole \"argocd-manager-role\" created","time":"2025-05-11T17:49:02+02:00"} +{"level":"info","msg":"ClusterRoleBinding \"argocd-manager-role-binding\" created","time":"2025-05-11T17:49:02+02:00"} +{"level":"info","msg":"Created bearer token secret for ServiceAccount \"argocd-manager\"","time":"2025-05-11T17:49:02+02:00"} +Cluster 'https://127.0.0.1:44821' added + +❯ argocd cluster add kind-staging --project staging +WARNING: This will create a service account `argocd-manager` on the cluster referenced by context `kind-staging` with full cluster level privileges. Do you want to continue [y/N]? y +{"level":"info","msg":"ServiceAccount \"argocd-manager\" created in namespace \"kube-system\"","time":"2025-05-11T17:49:10+02:00"} +{"level":"info","msg":"ClusterRole \"argocd-manager-role\" created","time":"2025-05-11T17:49:10+02:00"} +{"level":"info","msg":"ClusterRoleBinding \"argocd-manager-role-binding\" created","time":"2025-05-11T17:49:10+02:00"} +{"level":"info","msg":"Created bearer token secret for ServiceAccount \"argocd-manager\"","time":"2025-05-11T17:49:10+02:00"} +Cluster 'https://127.0.0.1:40971' added +``` + +```shell +argocd-autopilot project create production --dest-server +argocd-autopilot project create staging --dest-server +argocd-autopilot project create management --dest-server in-cluster --project management --yes +``` + +``` +argocd-autopilot app create hello-world --app github.com/Mathod95/courses/courses_002/apps/examples -p production --wait-timeout 2m +argocd-autopilot app create hello-world --app github.com/Mathod95/courses/courses_002/apps/examples --p staging --wait-timeout 2m + +argocd-autopilot app create uptime-kuma --app github.com/Mathod95/courses/courses_002/apps/uptimekuma -p production --wait-timeout 2m +argocd-autopilot app create uptime-kuma --app github.com/Mathod95/courses/courses_002/apps/uptimekuma -p staging --wait-timeout 2m + +argocd-autopilot app create uptime-kuma --app github.com/Mathod95/courses/courses_002/apps/uptimekuma --project staging --namespace uptimekuma --wait-timeout 2m +``` + + +❯ argocd cluster list +aSERVER NAME VERSION STATUS MESSAGE PROJECT +https://192.168.1.23:6445 kind-staging 1.32 Successful staging +https://192.168.1.23:6444 kind-production 1.32 Successful production +https://kubernetes.default.svc in-cluster 1.32 Successful + +❯ argocd proj list +NAME DESCRIPTION DESTINATIONS SOURCES CLUSTER-RESOURCE-WHITELIST NAMESPACE-RESOURCE-BLACKLIST SIGNATURE-KEYS ORPHANED-RESOURCES DESTINATION-SERVICE-ACCOUNTS +default *,* * */* disabled +production production project *,* * */* disabled +staging staging project *,* * */* disabled + +❯ argocd cluster list +SERVER NAME VERSION STATUS MESSAGE PROJECT +https://192.168.1.23:6445 kind-staging 1.32 Successful staging +https://192.168.1.23:6444 kind-production 1.32 Successful production +https://kubernetes.default.svc in-cluster 1.32 Successful + +❯ argocd proj list +NAME DESCRIPTION DESTINATIONS SOURCES CLUSTER-RESOURCE-WHITELIST NAMESPACE-RESOURCE-BLACKLIST SIGNATURE-KEYS ORPHANED-RESOURCES DESTINATION-SERVICE-ACCOUNTS +default *,* * */* disabled +production production project https://192.168.1.23:6444,* * */* disabled +staging staging project https://192.168.1.23:6445,* * */* disabled + +❯ argocd-autopilot app create hello-world --app github.com/Mathod95/courses/courses_002/apps/examples -p production --wait-timeout 2m +INFO cloning git repository: https://github.com/Mathod95/courses.git +Enumerating objects: 41, done. +Counting objects: 100% (41/41), done. +Compressing objects: 100% (33/33), done. +Total 41 (delta 6), reused 34 (delta 4), pack-reused 0 (from 0) +INFO using revision: "", installation path: "/courses_002/autopilot" +INFO cloning repo: 'https://github.com/Mathod95/courses.git', to infer app type from path 'courses_002/apps/examples' +Enumerating objects: 41, done. +Counting objects: 100% (41/41), done. +Compressing objects: 100% (33/33), done. +Total 41 (delta 6), reused 34 (delta 4), pack-reused 0 (from 0) +INFO inferred application type: kustomize +FATAL cluster 'https://192.168.1.23:6444' is not configured yet, you need to create a project that uses this cluster first \ No newline at end of file diff --git a/draft/apps/examples/README.md b/draft/apps/examples/README.md new file mode 100644 index 0000000..6da7288 --- /dev/null +++ b/draft/apps/examples/README.md @@ -0,0 +1,6 @@ +# demo-app +### Installation: +To install this application using the `argocd-autopilot`, assuming you already have gone through the [bootstrap process](https://argocd-autopilot.readthedocs.io/en/latest/Getting-Started/), run the following: +```bash +argocd-autopilot app create hello-world --app github.com/Mathod95/courses/courses_002/apps/examples -p production +``` \ No newline at end of file diff --git a/draft/apps/examples/deployment.yaml b/draft/apps/examples/deployment.yaml new file mode 100644 index 0000000..943c7a2 --- /dev/null +++ b/draft/apps/examples/deployment.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: simple-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: trivial-go-web-app + template: + metadata: + labels: + app: trivial-go-web-app + spec: + containers: + - name: webserver-simple + image: docker.io/kostiscodefresh/simple-web-app:3d9b390 + ports: + - containerPort: 8080 \ No newline at end of file diff --git a/draft/apps/examples/kustomization.yaml b/draft/apps/examples/kustomization.yaml new file mode 100644 index 0000000..87b09a3 --- /dev/null +++ b/draft/apps/examples/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./deployment.yaml + - ./service.yaml \ No newline at end of file diff --git a/draft/apps/examples/service.yaml b/draft/apps/examples/service.yaml new file mode 100644 index 0000000..00d86d6 --- /dev/null +++ b/draft/apps/examples/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: simple-service +spec: + selector: + app: trivial-go-web-app + ports: + - protocol: TCP + port: 80 + targetPort: 8080 \ No newline at end of file diff --git a/draft/apps/uptimekuma/README.md b/draft/apps/uptimekuma/README.md new file mode 100644 index 0000000..8f8c1bc --- /dev/null +++ b/draft/apps/uptimekuma/README.md @@ -0,0 +1,6 @@ +# demo-app +### Installation: +To install this application using the `argocd-autopilot`, assuming you already have gone through the [bootstrap process](https://argocd-autopilot.readthedocs.io/en/latest/Getting-Started/), run the following: +```bash +argocd-autopilot app create uptimekuma --app github.com/Mathod95/courses/courses_002/apps/uptimekuma -p production +``` \ No newline at end of file diff --git a/draft/apps/uptimekuma/deployment.yaml b/draft/apps/uptimekuma/deployment.yaml new file mode 100644 index 0000000..4d9dc32 --- /dev/null +++ b/draft/apps/uptimekuma/deployment.yaml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: uptime-kuma +spec: + replicas: 1 + selector: + matchLabels: + app: uptime-kuma + template: + metadata: + labels: + app: uptime-kuma + spec: + containers: + - name: uptime-kuma + image: louislam/uptime-kuma:latest + ports: + - containerPort: 3001 + volumeMounts: + - mountPath: /app/data + name: uptime-kuma-data + volumes: + - name: uptime-kuma-data + persistentVolumeClaim: + claimName: uptime-kuma-pvc \ No newline at end of file diff --git a/draft/apps/uptimekuma/kustomization.yaml b/draft/apps/uptimekuma/kustomization.yaml new file mode 100644 index 0000000..015eb98 --- /dev/null +++ b/draft/apps/uptimekuma/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./deployment.yaml + - ./service.yaml + - ./persistent_volume.yaml + - ./persistent_volume_claim.yaml \ No newline at end of file diff --git a/draft/apps/uptimekuma/persistent_volume.yaml b/draft/apps/uptimekuma/persistent_volume.yaml new file mode 100644 index 0000000..a51e362 --- /dev/null +++ b/draft/apps/uptimekuma/persistent_volume.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: uptime-kuma-pv +spec: + capacity: + storage: 5Gi + accessModes: + - ReadWriteOnce + hostPath: + path: /mnt/data/uptime-kuma \ No newline at end of file diff --git a/draft/apps/uptimekuma/persistent_volume_claim.yaml b/draft/apps/uptimekuma/persistent_volume_claim.yaml new file mode 100644 index 0000000..6207b01 --- /dev/null +++ b/draft/apps/uptimekuma/persistent_volume_claim.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: uptime-kuma-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi \ No newline at end of file diff --git a/draft/apps/uptimekuma/service.yaml b/draft/apps/uptimekuma/service.yaml new file mode 100644 index 0000000..1df8554 --- /dev/null +++ b/draft/apps/uptimekuma/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: uptime-kuma +spec: + selector: + app: uptime-kuma + ports: + - protocol: TCP + port: 80 + targetPort: 3001 \ No newline at end of file diff --git a/draft/autopilot/apps/README.md b/draft/autopilot/apps/README.md new file mode 100644 index 0000000..9750d7c --- /dev/null +++ b/draft/autopilot/apps/README.md @@ -0,0 +1,27 @@ +# Apps +This directory contains all of the applications you installed by using: +```bash +argocd-autopilot app create --app -p +``` + +## Application Types +> If you don't specify the application `--type` argocd-autopilot will try to clone the source repository and infer the application type [automatically](https://argoproj.github.io/argo-cd/user-guide/tool_detection/#tool-detection) + +* ### Directory application + Such an application references a specific directory at a given repo URL, path and revision. It will be persisted in the GitOps Repository as a single file at `apps///config.json`. + #### Example: + ```bash + argocd-autopilot app create dir-example --app github.com/argoproj-labs/argocd-autopilot/examples/demo-dir/ -p --type dir + ``` + +* ### Kustomize application + A Kustomize application will have exactly one: `apps//base/kustomization.yaml` file, and one or more `apps//overlays//` folders. + + The `apps//base/kustomization.yaml` file is created the first time you create the application. The `apps//overlays//` folder is created for each project you install this application on. So all overlays of the same application are using the same base `kustomization.yaml`. + #### Example: + Try running the following command: + ```bash + argocd-autopilot app create hello-world --app github.com/argoproj-labs/argocd-autopilot/examples/demo-app/ -p --type kustomize + ``` + +###### * If you did not create a project yet take a look at: [creating a project](https://argocd-autopilot.readthedocs.io/en/stable/Getting-Started/#add-a-project-and-an-application). \ No newline at end of file diff --git a/draft/autopilot/apps/hello-world/base/kustomization.yaml b/draft/autopilot/apps/hello-world/base/kustomization.yaml new file mode 100644 index 0000000..f107f36 --- /dev/null +++ b/draft/autopilot/apps/hello-world/base/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- github.com/Mathod95/courses/courses_002/apps/examples diff --git a/draft/autopilot/apps/hello-world/overlays/production/config.json b/draft/autopilot/apps/hello-world/overlays/production/config.json new file mode 100644 index 0000000..0d6772a --- /dev/null +++ b/draft/autopilot/apps/hello-world/overlays/production/config.json @@ -0,0 +1,11 @@ +{ + "appName": "hello-world", + "userGivenName": "hello-world", + "destNamespace": "default", + "destServer": "https://192.168.1.23:6444", + "srcPath": "courses_002/autopilot/apps/hello-world/overlays/production", + "srcRepoURL": "https://github.com/Mathod95/courses.git", + "srcTargetRevision": "", + "labels": null, + "annotations": null +} \ No newline at end of file diff --git a/draft/autopilot/apps/hello-world/overlays/production/kustomization.yaml b/draft/autopilot/apps/hello-world/overlays/production/kustomization.yaml new file mode 100644 index 0000000..4e4f197 --- /dev/null +++ b/draft/autopilot/apps/hello-world/overlays/production/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- ../../base diff --git a/draft/autopilot/apps/hello-world/overlays/staging/config.json b/draft/autopilot/apps/hello-world/overlays/staging/config.json new file mode 100644 index 0000000..7ae0de0 --- /dev/null +++ b/draft/autopilot/apps/hello-world/overlays/staging/config.json @@ -0,0 +1,11 @@ +{ + "appName": "hello-world", + "userGivenName": "hello-world", + "destNamespace": "default", + "destServer": "https://192.168.1.23:6445", + "srcPath": "courses_002/autopilot/apps/hello-world/overlays/staging", + "srcRepoURL": "https://github.com/Mathod95/courses.git", + "srcTargetRevision": "", + "labels": null, + "annotations": null +} \ No newline at end of file diff --git a/draft/autopilot/apps/hello-world/overlays/staging/kustomization.yaml b/draft/autopilot/apps/hello-world/overlays/staging/kustomization.yaml new file mode 100644 index 0000000..4e4f197 --- /dev/null +++ b/draft/autopilot/apps/hello-world/overlays/staging/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- ../../base diff --git a/draft/autopilot/apps/uptime-kuma/base/kustomization.yaml b/draft/autopilot/apps/uptime-kuma/base/kustomization.yaml new file mode 100644 index 0000000..a2c8c8d --- /dev/null +++ b/draft/autopilot/apps/uptime-kuma/base/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- github.com/Mathod95/courses/courses_002/apps/uptimekuma diff --git a/draft/autopilot/apps/uptime-kuma/overlays/management/config.json b/draft/autopilot/apps/uptime-kuma/overlays/management/config.json new file mode 100644 index 0000000..5b35454 --- /dev/null +++ b/draft/autopilot/apps/uptime-kuma/overlays/management/config.json @@ -0,0 +1,11 @@ +{ + "appName": "uptime-kuma", + "userGivenName": "uptime-kuma", + "destNamespace": "default", + "destServer": "https://kubernetes.default.svc", + "srcPath": "courses_002/autopilot/apps/uptime-kuma/overlays/management", + "srcRepoURL": "https://github.com/Mathod95/courses.git", + "srcTargetRevision": "", + "labels": null, + "annotations": null +} \ No newline at end of file diff --git a/draft/autopilot/apps/uptime-kuma/overlays/management/kustomization.yaml b/draft/autopilot/apps/uptime-kuma/overlays/management/kustomization.yaml new file mode 100644 index 0000000..4e4f197 --- /dev/null +++ b/draft/autopilot/apps/uptime-kuma/overlays/management/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- ../../base diff --git a/draft/autopilot/bootstrap/argo-cd.yaml b/draft/autopilot/bootstrap/argo-cd.yaml new file mode 100644 index 0000000..58e6f9b --- /dev/null +++ b/draft/autopilot/bootstrap/argo-cd.yaml @@ -0,0 +1,38 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/managed-by: argocd-autopilot + app.kubernetes.io/name: argo-cd + name: argo-cd + namespace: argocd +spec: + destination: + namespace: argocd + server: https://kubernetes.default.svc + ignoreDifferences: + - group: argoproj.io + jsonPointers: + - /status + kind: Application + project: default + source: + path: courses_002/autopilot/bootstrap/argo-cd + repoURL: https://github.com/Mathod95/courses.git + syncPolicy: + automated: + allowEmpty: true + prune: true + selfHeal: true + syncOptions: + - allowEmpty=true +status: + health: {} + summary: {} + sync: + comparedTo: + destination: {} + source: + repoURL: "" + status: "" diff --git a/draft/autopilot/bootstrap/argo-cd/kustomization.yaml b/draft/autopilot/bootstrap/argo-cd/kustomization.yaml new file mode 100644 index 0000000..1826c0d --- /dev/null +++ b/draft/autopilot/bootstrap/argo-cd/kustomization.yaml @@ -0,0 +1,17 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +configMapGenerator: +- behavior: merge + literals: + - | + repository.credentials=- passwordSecret: + key: git_token + name: autopilot-secret + url: https://github.com/ + usernameSecret: + key: git_username + name: autopilot-secret + name: argocd-cm +kind: Kustomization +namespace: argocd +resources: +- github.com/argoproj-labs/argocd-autopilot/manifests/base?ref=v0.4.19 diff --git a/draft/autopilot/bootstrap/cluster-resources.yaml b/draft/autopilot/bootstrap/cluster-resources.yaml new file mode 100644 index 0000000..18f48c9 --- /dev/null +++ b/draft/autopilot/bootstrap/cluster-resources.yaml @@ -0,0 +1,47 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + annotations: + argocd.argoproj.io/sync-wave: "0" + creationTimestamp: null + name: cluster-resources + namespace: argocd +spec: + generators: + - git: + files: + - path: courses_002/autopilot/bootstrap/cluster-resources/*.json + repoURL: https://github.com/Mathod95/courses.git + requeueAfterSeconds: 20 + revision: "" + template: + metadata: {} + spec: + destination: {} + project: "" + syncPolicy: + preserveResourcesOnDeletion: true + template: + metadata: + labels: + app.kubernetes.io/managed-by: argocd-autopilot + app.kubernetes.io/name: cluster-resources-{{name}} + name: cluster-resources-{{name}} + namespace: argocd + spec: + destination: + server: '{{server}}' + ignoreDifferences: + - group: argoproj.io + jsonPointers: + - /status + kind: Application + project: default + source: + path: courses_002/autopilot/bootstrap/cluster-resources/{{name}} + repoURL: https://github.com/Mathod95/courses.git + syncPolicy: + automated: + allowEmpty: true + selfHeal: true +status: {} diff --git a/draft/autopilot/bootstrap/cluster-resources/in-cluster.json b/draft/autopilot/bootstrap/cluster-resources/in-cluster.json new file mode 100644 index 0000000..259083a --- /dev/null +++ b/draft/autopilot/bootstrap/cluster-resources/in-cluster.json @@ -0,0 +1 @@ +{"name":"in-cluster","server":"https://kubernetes.default.svc"} \ No newline at end of file diff --git a/draft/autopilot/bootstrap/cluster-resources/in-cluster/README.md b/draft/autopilot/bootstrap/cluster-resources/in-cluster/README.md new file mode 100644 index 0000000..6129ae5 --- /dev/null +++ b/draft/autopilot/bootstrap/cluster-resources/in-cluster/README.md @@ -0,0 +1,3 @@ +# Cluster Resources +This directory contains all cluster resources that should be applied to cluster: `in-cluster`. +For example `Namespace` resources that are shared by multiple applications on the same namespace. diff --git a/draft/autopilot/bootstrap/cluster-resources/in-cluster/argocd-ns.yaml b/draft/autopilot/bootstrap/cluster-resources/in-cluster/argocd-ns.yaml new file mode 100644 index 0000000..ba9bb98 --- /dev/null +++ b/draft/autopilot/bootstrap/cluster-resources/in-cluster/argocd-ns.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Namespace +metadata: + annotations: + argocd.argoproj.io/sync-options: Prune=false + creationTimestamp: null + name: argocd +spec: {} +status: {} diff --git a/draft/autopilot/bootstrap/cluster-resources/kind-production.json b/draft/autopilot/bootstrap/cluster-resources/kind-production.json new file mode 100644 index 0000000..a49eecc --- /dev/null +++ b/draft/autopilot/bootstrap/cluster-resources/kind-production.json @@ -0,0 +1 @@ +{"name":"kind-production","server":"https://192.168.1.23:6444"} \ No newline at end of file diff --git a/draft/autopilot/bootstrap/cluster-resources/kind-production/README.md b/draft/autopilot/bootstrap/cluster-resources/kind-production/README.md new file mode 100644 index 0000000..2700feb --- /dev/null +++ b/draft/autopilot/bootstrap/cluster-resources/kind-production/README.md @@ -0,0 +1,3 @@ +# Cluster Resources +This directory contains all cluster resources that should be applied to cluster: `https://192.168.1.23:6444`. +For example `Namespace` resources that are shared by multiple applications on the same namespace. diff --git a/draft/autopilot/bootstrap/cluster-resources/kind-staging.json b/draft/autopilot/bootstrap/cluster-resources/kind-staging.json new file mode 100644 index 0000000..3e51775 --- /dev/null +++ b/draft/autopilot/bootstrap/cluster-resources/kind-staging.json @@ -0,0 +1 @@ +{"name":"kind-staging","server":"https://192.168.1.23:6445"} \ No newline at end of file diff --git a/draft/autopilot/bootstrap/cluster-resources/kind-staging/README.md b/draft/autopilot/bootstrap/cluster-resources/kind-staging/README.md new file mode 100644 index 0000000..2a5b3fe --- /dev/null +++ b/draft/autopilot/bootstrap/cluster-resources/kind-staging/README.md @@ -0,0 +1,3 @@ +# Cluster Resources +This directory contains all cluster resources that should be applied to cluster: `https://192.168.1.23:6445`. +For example `Namespace` resources that are shared by multiple applications on the same namespace. diff --git a/draft/autopilot/bootstrap/root.yaml b/draft/autopilot/bootstrap/root.yaml new file mode 100644 index 0000000..04232ed --- /dev/null +++ b/draft/autopilot/bootstrap/root.yaml @@ -0,0 +1,40 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + creationTimestamp: null + finalizers: + - resources-finalizer.argocd.argoproj.io + labels: + app.kubernetes.io/managed-by: argocd-autopilot + app.kubernetes.io/name: root + name: root + namespace: argocd +spec: + destination: + namespace: argocd + server: https://kubernetes.default.svc + ignoreDifferences: + - group: argoproj.io + jsonPointers: + - /status + kind: Application + project: default + source: + path: courses_002/autopilot/projects + repoURL: https://github.com/Mathod95/courses.git + syncPolicy: + automated: + allowEmpty: true + prune: true + selfHeal: true + syncOptions: + - allowEmpty=true +status: + health: {} + summary: {} + sync: + comparedTo: + destination: {} + source: + repoURL: "" + status: "" diff --git a/draft/autopilot/projects/README.md b/draft/autopilot/projects/README.md new file mode 100644 index 0000000..baef199 --- /dev/null +++ b/draft/autopilot/projects/README.md @@ -0,0 +1,21 @@ +# Projects +This directory contains all of your `argocd-autopilot` projects. Projects provide a way to logically group applications and easily control things such as defaults and restrictions. + +### Creating a new project +To create a new project run: +```bash +export GIT_TOKEN= +export GIT_REPO= + +argocd-autopilot project create +``` + +### Creating a new project on different cluster +You can create a project that deploys applications to a different cluster, instead of the cluster where Argo-CD is installed. To do that run: +```bash +export GIT_TOKEN= +export GIT_REPO= + +argocd-autopilot project create --dest-kube-context +``` +Now all applications in this project that do not explicitly specify a different `--dest-server` will be created on the project's destination server. diff --git a/draft/autopilot/projects/management.yaml b/draft/autopilot/projects/management.yaml new file mode 100644 index 0000000..8029e4b --- /dev/null +++ b/draft/autopilot/projects/management.yaml @@ -0,0 +1,93 @@ +apiVersion: argoproj.io/v1alpha1 +kind: AppProject +metadata: + annotations: + argocd-autopilot.argoproj-labs.io/default-dest-server: https://kubernetes.default.svc + argocd.argoproj.io/sync-options: PruneLast=true + argocd.argoproj.io/sync-wave: "-2" + creationTimestamp: null + name: management + namespace: argocd +spec: + clusterResourceWhitelist: + - group: '*' + kind: '*' + description: management project + destinations: + - namespace: '*' + server: '*' + namespaceResourceWhitelist: + - group: '*' + kind: '*' + sourceRepos: + - '*' +status: {} + +--- +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + annotations: + argocd.argoproj.io/sync-wave: "0" + creationTimestamp: null + name: management + namespace: argocd +spec: + generators: + - git: + files: + - path: courses_002/autopilot/apps/**/management/config.json + repoURL: https://github.com/Mathod95/courses.git + requeueAfterSeconds: 20 + revision: "" + template: + metadata: {} + spec: + destination: {} + project: "" + - git: + files: + - path: courses_002/autopilot/apps/**/management/config_dir.json + repoURL: https://github.com/Mathod95/courses.git + requeueAfterSeconds: 20 + revision: "" + template: + metadata: {} + spec: + destination: {} + project: "" + source: + directory: + exclude: '{{ exclude }}' + include: '{{ include }}' + jsonnet: {} + recurse: true + repoURL: "" + syncPolicy: {} + template: + metadata: + labels: + app.kubernetes.io/managed-by: argocd-autopilot + app.kubernetes.io/name: '{{ appName }}' + name: management-{{ userGivenName }} + namespace: argocd + spec: + destination: + namespace: '{{ destNamespace }}' + server: '{{ destServer }}' + ignoreDifferences: + - group: argoproj.io + jsonPointers: + - /status + kind: Application + project: management + source: + path: '{{ srcPath }}' + repoURL: '{{ srcRepoURL }}' + targetRevision: '{{ srcTargetRevision }}' + syncPolicy: + automated: + allowEmpty: true + prune: true + selfHeal: true +status: {} diff --git a/draft/autopilot/projects/production.yaml b/draft/autopilot/projects/production.yaml new file mode 100644 index 0000000..d3f6184 --- /dev/null +++ b/draft/autopilot/projects/production.yaml @@ -0,0 +1,93 @@ +apiVersion: argoproj.io/v1alpha1 +kind: AppProject +metadata: + annotations: + argocd-autopilot.argoproj-labs.io/default-dest-server: https://192.168.1.23:6444 + argocd.argoproj.io/sync-options: PruneLast=true + argocd.argoproj.io/sync-wave: "-2" + creationTimestamp: null + name: production + namespace: argocd +spec: + clusterResourceWhitelist: + - group: '*' + kind: '*' + description: production project + destinations: + - namespace: '*' + server: '*' + namespaceResourceWhitelist: + - group: '*' + kind: '*' + sourceRepos: + - '*' +status: {} + +--- +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + annotations: + argocd.argoproj.io/sync-wave: "0" + creationTimestamp: null + name: production + namespace: argocd +spec: + generators: + - git: + files: + - path: courses_002/autopilot/apps/**/production/config.json + repoURL: https://github.com/Mathod95/courses.git + requeueAfterSeconds: 20 + revision: "" + template: + metadata: {} + spec: + destination: {} + project: "" + - git: + files: + - path: courses_002/autopilot/apps/**/production/config_dir.json + repoURL: https://github.com/Mathod95/courses.git + requeueAfterSeconds: 20 + revision: "" + template: + metadata: {} + spec: + destination: {} + project: "" + source: + directory: + exclude: '{{ exclude }}' + include: '{{ include }}' + jsonnet: {} + recurse: true + repoURL: "" + syncPolicy: {} + template: + metadata: + labels: + app.kubernetes.io/managed-by: argocd-autopilot + app.kubernetes.io/name: '{{ appName }}' + name: production-{{ userGivenName }} + namespace: argocd + spec: + destination: + namespace: '{{ destNamespace }}' + server: '{{ destServer }}' + ignoreDifferences: + - group: argoproj.io + jsonPointers: + - /status + kind: Application + project: production + source: + path: '{{ srcPath }}' + repoURL: '{{ srcRepoURL }}' + targetRevision: '{{ srcTargetRevision }}' + syncPolicy: + automated: + allowEmpty: true + prune: true + selfHeal: true +status: {} diff --git a/draft/autopilot/projects/staging.yaml b/draft/autopilot/projects/staging.yaml new file mode 100644 index 0000000..8ddd8a5 --- /dev/null +++ b/draft/autopilot/projects/staging.yaml @@ -0,0 +1,93 @@ +apiVersion: argoproj.io/v1alpha1 +kind: AppProject +metadata: + annotations: + argocd-autopilot.argoproj-labs.io/default-dest-server: https://192.168.1.23:6445 + argocd.argoproj.io/sync-options: PruneLast=true + argocd.argoproj.io/sync-wave: "-2" + creationTimestamp: null + name: staging + namespace: argocd +spec: + clusterResourceWhitelist: + - group: '*' + kind: '*' + description: staging project + destinations: + - namespace: '*' + server: '*' + namespaceResourceWhitelist: + - group: '*' + kind: '*' + sourceRepos: + - '*' +status: {} + +--- +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + annotations: + argocd.argoproj.io/sync-wave: "0" + creationTimestamp: null + name: staging + namespace: argocd +spec: + generators: + - git: + files: + - path: courses_002/autopilot/apps/**/staging/config.json + repoURL: https://github.com/Mathod95/courses.git + requeueAfterSeconds: 20 + revision: "" + template: + metadata: {} + spec: + destination: {} + project: "" + - git: + files: + - path: courses_002/autopilot/apps/**/staging/config_dir.json + repoURL: https://github.com/Mathod95/courses.git + requeueAfterSeconds: 20 + revision: "" + template: + metadata: {} + spec: + destination: {} + project: "" + source: + directory: + exclude: '{{ exclude }}' + include: '{{ include }}' + jsonnet: {} + recurse: true + repoURL: "" + syncPolicy: {} + template: + metadata: + labels: + app.kubernetes.io/managed-by: argocd-autopilot + app.kubernetes.io/name: '{{ appName }}' + name: staging-{{ userGivenName }} + namespace: argocd + spec: + destination: + namespace: '{{ destNamespace }}' + server: '{{ destServer }}' + ignoreDifferences: + - group: argoproj.io + jsonPointers: + - /status + kind: Application + project: staging + source: + path: '{{ srcPath }}' + repoURL: '{{ srcRepoURL }}' + targetRevision: '{{ srcTargetRevision }}' + syncPolicy: + automated: + allowEmpty: true + prune: true + selfHeal: true +status: {} diff --git a/kind/development.yaml b/kind/development.yaml new file mode 100644 index 0000000..2011903 --- /dev/null +++ b/kind/development.yaml @@ -0,0 +1,7 @@ +apiVersion: kind.x-k8s.io/v1alpha4 +kind: Cluster +name: development +nodes: +- role: control-plane +- role: worker +- role: worker \ No newline at end of file diff --git a/kind/management.yaml b/kind/management.yaml new file mode 100644 index 0000000..cfbe8fb --- /dev/null +++ b/kind/management.yaml @@ -0,0 +1,7 @@ +apiVersion: kind.x-k8s.io/v1alpha4 +kind: Cluster +name: management +nodes: +- role: control-plane +- role: worker +- role: worker \ No newline at end of file diff --git a/kind/production.yaml b/kind/production.yaml new file mode 100644 index 0000000..c5a0c3d --- /dev/null +++ b/kind/production.yaml @@ -0,0 +1,8 @@ +apiVersion: kind.x-k8s.io/v1alpha4 +kind: Cluster +name: production +nodes: +- role: control-plane +- role: control-plane +- role: worker +- role: worker \ No newline at end of file