From 13ea8de355ab24ba45e4ff3b9a7555502c12690a Mon Sep 17 00:00:00 2001 From: David Landry Date: Wed, 16 Oct 2024 18:41:07 -0400 Subject: [PATCH] feat(portfolio): add staging environment --- apps/portfolio/base/deployment.yaml | 22 +++++ apps/portfolio/base/kustomization.yaml | 6 ++ apps/portfolio/base/service.yaml | 13 +++ .../overlays/prod-sites/config.json.disabled | 11 +++ .../overlays/prod-sites/ingress.yaml | 31 ++++++ .../overlays/prod-sites/kustomization.yaml | 9 ++ .../overlays/staging-sites/config.json | 11 +++ .../overlays/staging-sites/ingress.yaml | 31 ++++++ .../overlays/staging-sites/kustomization.yaml | 9 ++ projects/prod-sites.yaml | 98 +++++++++++++++++++ projects/staging-sites.yaml | 98 +++++++++++++++++++ 11 files changed, 339 insertions(+) create mode 100644 apps/portfolio/base/deployment.yaml create mode 100644 apps/portfolio/base/kustomization.yaml create mode 100644 apps/portfolio/base/service.yaml create mode 100644 apps/portfolio/overlays/prod-sites/config.json.disabled create mode 100644 apps/portfolio/overlays/prod-sites/ingress.yaml create mode 100644 apps/portfolio/overlays/prod-sites/kustomization.yaml create mode 100644 apps/portfolio/overlays/staging-sites/config.json create mode 100644 apps/portfolio/overlays/staging-sites/ingress.yaml create mode 100644 apps/portfolio/overlays/staging-sites/kustomization.yaml create mode 100644 projects/prod-sites.yaml create mode 100644 projects/staging-sites.yaml diff --git a/apps/portfolio/base/deployment.yaml b/apps/portfolio/base/deployment.yaml new file mode 100644 index 0000000..82bb7c6 --- /dev/null +++ b/apps/portfolio/base/deployment.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: portfolio +spec: + replicas: 1 + selector: + matchLabels: + app: portfolio + template: + metadata: + annotations: + labels: + app: portfolio + spec: + containers: + - image: registry.int.nc.landry.land/portfolio-site + name: portfolio-site + ports: + - containerPort: 8080 + name: http + restartPolicy: Always diff --git a/apps/portfolio/base/kustomization.yaml b/apps/portfolio/base/kustomization.yaml new file mode 100644 index 0000000..ab1e6ea --- /dev/null +++ b/apps/portfolio/base/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ./deployment.yaml + - ./service.yaml diff --git a/apps/portfolio/base/service.yaml b/apps/portfolio/base/service.yaml new file mode 100644 index 0000000..f86b16a --- /dev/null +++ b/apps/portfolio/base/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + labels: + name: syncthing +spec: + ports: + - name: http + port: 80 + targetPort: http + selector: + app: syncthing diff --git a/apps/portfolio/overlays/prod-sites/config.json.disabled b/apps/portfolio/overlays/prod-sites/config.json.disabled new file mode 100644 index 0000000..0a72ff3 --- /dev/null +++ b/apps/portfolio/overlays/prod-sites/config.json.disabled @@ -0,0 +1,11 @@ +{ + "appName": "portfolio", + "userGivenName": "portfolio", + "destNamespace": "staging-sites", + "destServer": "https://kubernetes.default.svc", + "srcPath": "apps/portfolio/overlays/staging-sites", + "srcRepoURL": "ssh://git@gitea-ssh.gitops.svc.cluster.local:2222/davad/argo.git", + "srcTargetRevision": "", + "labels": null, + "annotations": null +} diff --git a/apps/portfolio/overlays/prod-sites/ingress.yaml b/apps/portfolio/overlays/prod-sites/ingress.yaml new file mode 100644 index 0000000..a070152 --- /dev/null +++ b/apps/portfolio/overlays/prod-sites/ingress.yaml @@ -0,0 +1,31 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: portfolio + labels: + app.kubernetes.io/name: portfolio + annotations: + cert-manager.io/cluster-issuer: letsencrypt-issuer + nginx.ingress.kubernetes.io/whitelist-source-range: 192.168.1.1/16 + + gethomepage.dev/enabled: "true" + gethomepage.dev/name: Portfolio + gethomepage.dev/group: Sites + gethomepage.dev/href: https://portfolio-test.int.nc.landry.land + # gethomepage.dev/description: + # gethomepage.dev/icon: syncthing +spec: + tls: + - hosts: + - "portfolio-test.int.nc.landry.land" + rules: + - host: "portfolio-test.int.nc.landry.land" + http: + paths: + - path: "/" + pathType: Prefix + backend: + service: + name: portfolio + port: + name: http diff --git a/apps/portfolio/overlays/prod-sites/kustomization.yaml b/apps/portfolio/overlays/prod-sites/kustomization.yaml new file mode 100644 index 0000000..1fd29f2 --- /dev/null +++ b/apps/portfolio/overlays/prod-sites/kustomization.yaml @@ -0,0 +1,9 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../../base +- ./ingress.yaml +images: +- name: registry.int.nc.landry.land/portfolio-site + newTag: latest diff --git a/apps/portfolio/overlays/staging-sites/config.json b/apps/portfolio/overlays/staging-sites/config.json new file mode 100644 index 0000000..0a72ff3 --- /dev/null +++ b/apps/portfolio/overlays/staging-sites/config.json @@ -0,0 +1,11 @@ +{ + "appName": "portfolio", + "userGivenName": "portfolio", + "destNamespace": "staging-sites", + "destServer": "https://kubernetes.default.svc", + "srcPath": "apps/portfolio/overlays/staging-sites", + "srcRepoURL": "ssh://git@gitea-ssh.gitops.svc.cluster.local:2222/davad/argo.git", + "srcTargetRevision": "", + "labels": null, + "annotations": null +} diff --git a/apps/portfolio/overlays/staging-sites/ingress.yaml b/apps/portfolio/overlays/staging-sites/ingress.yaml new file mode 100644 index 0000000..a070152 --- /dev/null +++ b/apps/portfolio/overlays/staging-sites/ingress.yaml @@ -0,0 +1,31 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: portfolio + labels: + app.kubernetes.io/name: portfolio + annotations: + cert-manager.io/cluster-issuer: letsencrypt-issuer + nginx.ingress.kubernetes.io/whitelist-source-range: 192.168.1.1/16 + + gethomepage.dev/enabled: "true" + gethomepage.dev/name: Portfolio + gethomepage.dev/group: Sites + gethomepage.dev/href: https://portfolio-test.int.nc.landry.land + # gethomepage.dev/description: + # gethomepage.dev/icon: syncthing +spec: + tls: + - hosts: + - "portfolio-test.int.nc.landry.land" + rules: + - host: "portfolio-test.int.nc.landry.land" + http: + paths: + - path: "/" + pathType: Prefix + backend: + service: + name: portfolio + port: + name: http diff --git a/apps/portfolio/overlays/staging-sites/kustomization.yaml b/apps/portfolio/overlays/staging-sites/kustomization.yaml new file mode 100644 index 0000000..198caf8 --- /dev/null +++ b/apps/portfolio/overlays/staging-sites/kustomization.yaml @@ -0,0 +1,9 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../../base +- ./ingress.yaml +images: +- name: registry.int.nc.landry.land/portfolio-site + newTag: staging diff --git a/projects/prod-sites.yaml b/projects/prod-sites.yaml new file mode 100644 index 0000000..a06df9e --- /dev/null +++ b/projects/prod-sites.yaml @@ -0,0 +1,98 @@ +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: prod-sites + namespace: argocd +spec: + clusterResourceWhitelist: + - group: "*" + kind: "*" + description: prod version of static sites + destinations: + - namespace: "prod-sites" + server: "*" + namespaceResourceWhitelist: + - group: "*" + kind: "*" + sourceRepos: + - "*" +status: {} + +--- +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + annotations: + argocd.argoproj.io/sync-wave: "0" + creationTimestamp: null + name: prod-sites + namespace: argocd +spec: + generators: + - git: + files: + - path: apps/**/prod-sites/config.json + repoURL: ssh://git@gitea-ssh.gitops.svc.cluster.local:2222/davad/argo.git + requeueAfterSeconds: 20 + revision: "" + template: + metadata: {} + spec: + destination: {} + project: "" + - git: + files: + - path: apps/**/prod-sites/config_dir.json + repoURL: ssh://git@gitea-ssh.gitops.svc.cluster.local:2222/davad/argo.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: prod-sites-{{ userGivenName }} + namespace: argocd + spec: + destination: + namespace: "{{ destNamespace }}" + server: "{{ destServer }}" + ignoreDifferences: + - group: argoproj.io + jsonPointers: + - /status + kind: Application + project: prod-sites + source: + path: "{{ srcPath }}" + repoURL: "{{ srcRepoURL }}" + targetRevision: "{{ srcTargetRevision }}" + syncPolicy: + automated: + allowEmpty: true + prune: true + selfHeal: true +status: {} +--- +apiVersion: v1 +kind: Namespace +metadata: + name: prod-sites diff --git a/projects/staging-sites.yaml b/projects/staging-sites.yaml new file mode 100644 index 0000000..94ebad8 --- /dev/null +++ b/projects/staging-sites.yaml @@ -0,0 +1,98 @@ +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: staging-sites + namespace: argocd +spec: + clusterResourceWhitelist: + - group: "*" + kind: "*" + description: staging version of static sites + destinations: + - namespace: "staging-sites" + server: "*" + namespaceResourceWhitelist: + - group: "*" + kind: "*" + sourceRepos: + - "*" +status: {} + +--- +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + annotations: + argocd.argoproj.io/sync-wave: "0" + creationTimestamp: null + name: staging-sites + namespace: argocd +spec: + generators: + - git: + files: + - path: apps/**/staging-sites/config.json + repoURL: ssh://git@gitea-ssh.gitops.svc.cluster.local:2222/davad/argo.git + requeueAfterSeconds: 20 + revision: "" + template: + metadata: {} + spec: + destination: {} + project: "" + - git: + files: + - path: apps/**/staging-sites/config_dir.json + repoURL: ssh://git@gitea-ssh.gitops.svc.cluster.local:2222/davad/argo.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-sites-{{ userGivenName }} + namespace: argocd + spec: + destination: + namespace: "{{ destNamespace }}" + server: "{{ destServer }}" + ignoreDifferences: + - group: argoproj.io + jsonPointers: + - /status + kind: Application + project: staging-sites + source: + path: "{{ srcPath }}" + repoURL: "{{ srcRepoURL }}" + targetRevision: "{{ srcTargetRevision }}" + syncPolicy: + automated: + allowEmpty: true + prune: true + selfHeal: true +status: {} +--- +apiVersion: v1 +kind: Namespace +metadata: + name: staging-sites