diff --git a/.gitea/workflows/app-continuous-deploy.yml b/.gitea/workflows/app-continuous-deploy.yml deleted file mode 100644 index 96241bc..0000000 --- a/.gitea/workflows/app-continuous-deploy.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Casa LMS CI/CD Pipeline - -on: - push: - branches: - - fix/* - - main - - master - pull_request: - schedule: - - cron: '0 15 * * 0' # every sunday 3 pm - -jobs: - deploy: - runs-on: ["casa-vlan-cicd", "kubectl", "helm", "deploy"] - env: - GITHUB_TEMP: ${{ runner.temp }} - - steps: - - - name: Checkout code - uses: actions/checkout@v3 - - - name: Fetch limbo public actions - env: - RUNNER_TEMP: "${{ runner.temp }}" - WORKSPACE: "${{ gitea.workspace }}" - run: | - curl -fsSL https://git.limbosolutions.com/kb/gitea/raw/branch/main/cloud-scripts/setup-limbo-actions.sh | bash 2>&1 - - - name: Setup kubectl - uses: ./.gitea/limbo_actions/kubectl-setup - with: - kube_server: ${{ secrets.CASA_VLAN_KUBE_SERVER }} - kube_ca_base64: ${{ secrets.CASA_VLAN_KUBE_CA_BASE64 }} - kube_token: ${{ secrets.CASA_VLAN_KUBE_TOKEN }} - - - name: Deploy - shell: bash - run: | - ./ops-scripts/apply-app.sh - \ No newline at end of file diff --git a/README.md b/README.md index c6bf1c4..9ce92ea 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ Currently hosted on [kubernetes cluster - casa](https://git.limbosolutions.com/m - [Music](#music) - [Clients](#clients) - [Setup and Deploy](#setup-and-deploy) - - [App](#app) - - [Infra](#infra) - [Continuous Deploy](#continuous-deploy) - [Links](#links) @@ -52,16 +50,10 @@ systemctl --user enable --now squeezelite.service ## Setup and Deploy -### App +Using flux for reconciliation. ``` bash -./ops-scripts/apply-app.sh -``` - -### Infra - -``` bash -./ops-scripts/apply-infra.sh +./ops-scripts/apply-flux.sh ``` ### Continuous Deploy diff --git a/deploy/infra/ingress.yaml b/deploy/app/ingress.yaml similarity index 91% rename from deploy/infra/ingress.yaml rename to deploy/app/ingress.yaml index 69fa906..24dc739 100644 --- a/deploy/infra/ingress.yaml +++ b/deploy/app/ingress.yaml @@ -2,7 +2,6 @@ apiVersion: traefik.io/v1alpha1 kind: IngressRoute metadata: name: lyrionmusicserver - namespace: lyrionmusicserver spec: entryPoints: - websecure diff --git a/deploy/app/kustomization.yaml b/deploy/app/kustomization.yaml index cbbb0b1..b7925bf 100644 --- a/deploy/app/kustomization.yaml +++ b/deploy/app/kustomization.yaml @@ -1,10 +1,11 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization +namespace: lyrionmusicserver resources: - deployment.yaml - service.yaml - music-pvc.yaml - lms-data-pvc.yaml - playlists-pvc.yaml -generatorOptions: - disableNameSuffixHash: true \ No newline at end of file + - ingress.yaml + - music-pv.yaml diff --git a/deploy/infra/music-pv.yaml b/deploy/app/music-pv.yaml similarity index 100% rename from deploy/infra/music-pv.yaml rename to deploy/app/music-pv.yaml diff --git a/deploy/flux/.env.d/.gitignore b/deploy/flux/.env.d/.gitignore new file mode 100644 index 0000000..d29675e --- /dev/null +++ b/deploy/flux/.env.d/.gitignore @@ -0,0 +1,2 @@ +** +!.gitignore \ No newline at end of file diff --git a/deploy/flux/app-sync.yaml b/deploy/flux/app-sync.yaml new file mode 100644 index 0000000..f0f2b46 --- /dev/null +++ b/deploy/flux/app-sync.yaml @@ -0,0 +1,12 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: app +spec: + interval: 1m + sourceRef: + kind: GitRepository + name: lms + path: deploy/app + prune: true + \ No newline at end of file diff --git a/deploy/flux/git-repo.yaml b/deploy/flux/git-repo.yaml new file mode 100644 index 0000000..d34b06d --- /dev/null +++ b/deploy/flux/git-repo.yaml @@ -0,0 +1,11 @@ +apiVersion: source.toolkit.fluxcd.io/v1 +kind: GitRepository +metadata: + name: lms +spec: + interval: 5m0s + url: ssh://git@git.limbosolutions.com:2222/marcio.fernandes/lms.git + ref: + branch: main + secretRef: + name: flux-repo-ssh-credentials \ No newline at end of file diff --git a/deploy/flux/kustomization.yaml b/deploy/flux/kustomization.yaml new file mode 100644 index 0000000..f42eb98 --- /dev/null +++ b/deploy/flux/kustomization.yaml @@ -0,0 +1,18 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - git-repo.yaml + - app-sync.yaml +secretGenerator: + - name: flux-repo-ssh-credentials + namespace: lyrionmusicserver + files: + - "identity=./.env.d/flux-repo-ssh-key" + - "known_hosts=./.env.d/flux-repo-ssh-known_hosts" + - "pubkey=./.env.d/flux-repo-ssh-key.pub" + - name: flux-repo-ssh-credentials + namespace: lyrionmusicserver + files: + - "age.agekey=./.env.d/age.agekey" +generatorOptions: + disableNameSuffixHash: true \ No newline at end of file diff --git a/deploy/infra/cd-rbac.yaml b/deploy/infra/cd-rbac.yaml deleted file mode 100644 index 70d4bbf..0000000 --- a/deploy/infra/cd-rbac.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - namespace: lyrionmusicserver - name: ci-cd # change name to continuous-deploy -rules: -- apiGroups: [""] - resources: ["pods", "services", "secrets", "configmaps", "persistentvolumeclaims", "endpoints"] - verbs: ["get", "watch", "list", "create", "update", "patch", "delete"] -- apiGroups: ["apps"] - resources: ["deployments", "statefulsets"] - verbs: ["get", "watch", "list", "create", "update", "patch", "delete"] - ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: ci-cd #change name to continuous-deploy - namespace: lyrionmusicserver -subjects: -- kind: ServiceAccount - name: casa-ci-cd - namespace: home-assistant -roleRef: - kind: Role - name: ci-cd - apiGroup: rbac.authorization.k8s.io diff --git a/deploy/infra/kustomization.yaml b/deploy/infra/kustomization.yaml deleted file mode 100644 index 3abbc1c..0000000 --- a/deploy/infra/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -kind: Kustomization -resources: - - namespace.yaml - - cd-rbac.yaml - - music-pv.yaml - - ingress.yaml -generatorOptions: - disableNameSuffixHash: true \ No newline at end of file diff --git a/deploy/infra/namespace.yaml b/deploy/infra/namespace.yaml deleted file mode 100644 index 869139e..0000000 --- a/deploy/infra/namespace.yaml +++ /dev/null @@ -1,7 +0,0 @@ - -apiVersion: v1 -kind: Namespace -metadata: - name: lyrionmusicserver - labels: - name: lyrionmusicserver \ No newline at end of file diff --git a/ops-scripts/apply-app.sh b/ops-scripts/apply-app.sh deleted file mode 100755 index 0b895d0..0000000 --- a/ops-scripts/apply-app.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -e -echo "Executing app deploy." - -kubectl kustomize deploy/app | kubectl apply -f - \ No newline at end of file diff --git a/ops-scripts/apply-infra.sh b/ops-scripts/apply-infra.sh deleted file mode 100755 index f2cb358..0000000 --- a/ops-scripts/apply-infra.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -e -echo "Executing infra deploy." - -kubectl kustomize deploy/infra | kubectl apply -f - \ No newline at end of file