diff --git a/templates/appname-application.yaml b/templates/appname-application.yaml new file mode 100644 index 0000000..fc33694 --- /dev/null +++ b/templates/appname-application.yaml @@ -0,0 +1,20 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: argo-app-appname + namespace: argocd +spec: + destination: + name: '' + namespace: default + server: https://kubernetes.default.svc + source: + path: appname + repoURL: https://git.mziesel.nl/mans/argocd-test + targetRevision: HEAD + sources: [] + project: default + syncPolicy: + automated: + prune: true + selfHeal: true diff --git a/templates/bin/new-app.sh b/templates/bin/new-app.sh new file mode 100755 index 0000000..747fa5f --- /dev/null +++ b/templates/bin/new-app.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +[ $# != 1 ] && + echo "wrong number of args, run with --help" && + exit 1; + +APPNAME=$1 + +cp -r ./templates/new-svc "$APPNAME" +cp ./templates/appname-application.yaml "argocd-applications/base/$APPNAME-application.yaml" + +for file in "$APPNAME"/base/* ; do + rename appname "$APPNAME" "$file" + # NEWFILE=$(echo "$file" | sed "s/appname/$APPNAME/g") + NEWFILE=${file//appname/$APPNAME} + sed -i "s/appname/$APPNAME/g" "$NEWFILE" +done + +sed -i "s/appname/$APPNAME/g" "./$APPNAME/kustomization.yaml" +sed -i "s/appname/$APPNAME/g" "argocd-applications/base/$APPNAME-application.yaml" diff --git a/templates/new-svc/base/appname-deployment.yaml b/templates/new-svc/base/appname-deployment.yaml new file mode 100644 index 0000000..5a5a9eb --- /dev/null +++ b/templates/new-svc/base/appname-deployment.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: appname + namespace: appname +spec: + replicas: 3 + selector: + matchLabels: + app: appname + template: + metadata: + labels: + app: appname + spec: + containers: + - image: ghcr.io/gchq/appname:10.19.4 + name: appname + ports: + - name: web + containerPort: 80 diff --git a/templates/new-svc/base/appname-ingress.yaml b/templates/new-svc/base/appname-ingress.yaml new file mode 100644 index 0000000..618e3c4 --- /dev/null +++ b/templates/new-svc/base/appname-ingress.yaml @@ -0,0 +1,12 @@ +apiVersion: traefik.io/v1alpha1 +kind: IngressRoute +metadata: + name: appname-ingressroute +spec: + routes: + - match: Host(`appname.mziesel.nl`) + kind: Rule + services: + - name: appname + port: web + tls: {} diff --git a/templates/new-svc/base/appname-namespace.yaml b/templates/new-svc/base/appname-namespace.yaml new file mode 100644 index 0000000..d9b90e0 --- /dev/null +++ b/templates/new-svc/base/appname-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: appname diff --git a/templates/new-svc/base/appname-svc.yaml b/templates/new-svc/base/appname-svc.yaml new file mode 100644 index 0000000..cd89a23 --- /dev/null +++ b/templates/new-svc/base/appname-svc.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: appname +spec: + ports: + - name: web + port: 80 + targetPort: web + selector: + app: appname diff --git a/templates/new-svc/kustomization.yaml b/templates/new-svc/kustomization.yaml new file mode 100644 index 0000000..1b83a67 --- /dev/null +++ b/templates/new-svc/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: appname + +resources: + - ./base/appname-namespace.yaml + - ./base/appname-deployment.yaml + - ./base/appname-svc.yaml + - ./base/appname-ingress.yaml