diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..c6936b0e --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +#shellcheck disable=SC2148,SC2155 +export KUBECONFIG=$(expand_path ./kubeconfig) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..9c858678 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners +* @onedr0p diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 00000000..45a023ce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,24 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: kind/bug +assignees: '' + +--- + +# Details + +**What steps did you take and what happened:** + + + +**What did you expect to happen:** + +**Anything else you would like to add:** + + + +**Additional Information:** + + diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..b7fa73a6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: +- name: Discuss on Discord + url: https://discord.com/invite/sTMX7Vh + about: Join our Discord community diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 00000000..cdafcbe6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,22 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: kind/enhancement +assignees: '' + +--- + +# Details + +**Describe the solution you'd like:** + + + +**Anything else you would like to add:** + + + +**Additional Information:** + + diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 00000000..d5561aef --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,19 @@ +--- +name: Question +about: Ask a question to the maintainer +title: '' +labels: kind/question +assignees: '' + +--- + +# Details + +**Ask your question:** + + + + + + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..49fca846 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ +**Description of the change** + + + +**Benefits** + + + +**Possible drawbacks** + + + +**Applicable issues** + + +- fixes # + +**Additional information** + + diff --git a/.github/workflows/flux-schedule.yaml b/.github/workflows/flux-schedule.yaml new file mode 100644 index 00000000..352aa750 --- /dev/null +++ b/.github/workflows/flux-schedule.yaml @@ -0,0 +1,45 @@ +--- + +name: Schedule - Update Flux + +on: # yamllint disable-line rule:truthy + workflow_dispatch: + schedule: + - cron: '0 12 * * *' + +jobs: + flux-upgrade: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Setup Flux CLI + uses: fluxcd/flux2/action@main + + - name: Upgrade Flux + id: upgrade + run: | + CLI_VERSION="$(flux -v)" + VERSION="v${CLI_VERSION#*flux version }" + flux install --version="${VERSION}" \ + --network-policy=false \ + --export > ./cluster/base/flux-system/gotk-components.yaml + echo "::set-output name=flux_version::$VERSION" + + - name: Create pull request for Flux upgrade + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: "flux/upgrade-${{ steps.upgrade.outputs.flux_version }}" + delete-branch: true + title: "chore(deps): upgrade flux components to ${{ steps.upgrade.outputs.flux_version }}" + signoff: true + committer: "Devin Buhl " + author: "Devin Buhl " + assignees: "onedr0p" + commit-message: "chore(deps): upgrade flux components to ${{ steps.upgrade.outputs.flux_version }}" + body: | + Release notes: https://github.com/fluxcd/flux2/releases/tag/${{ steps.upgrade.outputs.flux_version }} + labels: flux/upgrade diff --git a/.github/workflows/invalid-template.yaml b/.github/workflows/invalid-template.yaml new file mode 100644 index 00000000..ba17f3d4 --- /dev/null +++ b/.github/workflows/invalid-template.yaml @@ -0,0 +1,24 @@ +--- + +name: Invalid Template + +on: + issues: + types: + - labeled + - unlabeled + - reopened + +jobs: + support: + runs-on: ubuntu-20.04 + steps: + - uses: dessant/support-requests@v2 + with: + github-token: ${{ github.token }} + support-label: 'template-incomplete' + issue-comment: > + :wave: @{issue-author}, please follow the template provided. + close-issue: true + lock-issue: true + issue-lock-reason: 'resolved' diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..4138053a --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,23 @@ +--- + +name: Lint + +on: # yamllint disable-line rule:truthy + workflow_dispatch: + push: + branches: + - main + pull_request: + +jobs: + yaml: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: Lint YAML + uses: ibiqlik/action-yamllint@v3 + with: + file_or_dir: "./cluster" + config_file: "./.github/yamllint.config.yaml" diff --git a/.github/workflows/support.yaml b/.github/workflows/support.yaml new file mode 100644 index 00000000..3730f8fd --- /dev/null +++ b/.github/workflows/support.yaml @@ -0,0 +1,28 @@ +--- + +name: 'Support requests' + +on: + issues: + types: + - labeled + - unlabeled + - reopened + +jobs: + support: + runs-on: ubuntu-20.04 + steps: + - uses: dessant/support-requests@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + support-label: 'support' + issue-comment: > + :wave: @{issue-author}, we use the issue tracker exclusively + for bug reports and feature requests. However, this issue appears + to be a support request. Please use our support channels + to get help with. + - [Discord](https://discord.gg/sTMX7Vh) + close-issue: true + lock-issue: false + issue-lock-reason: 'off-topic' diff --git a/.github/yamllint.config.yaml b/.github/yamllint.config.yaml new file mode 100644 index 00000000..8d131eda --- /dev/null +++ b/.github/yamllint.config.yaml @@ -0,0 +1,19 @@ +ignore: | + .github/ + crds.yaml +extends: default +rules: + truthy: + allowed-values: ['true', 'false', 'on', 'yes'] + comments: + min-spaces-from-content: 1 + line-length: disable + braces: + min-spaces-inside: 0 + max-spaces-inside: 1 + brackets: + min-spaces-inside: 0 + max-spaces-inside: 0 + indentation: + spaces: 2 + indent-sequences: consistent diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..41532440 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Editors +.vscode/ +# Trash +.DS_Store +Thumbs.db +# k8s +kubeconfig +# sops +.decrypted~*.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..bc2313ae --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +fail_fast: false +repos: +- repo: https://github.com/adrienverge/yamllint.git + rev: v1.25.0 + hooks: + - args: + - -c + - .github/yamllint.config.yaml + id: yamllint +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: mixed-line-ending +- repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.1.9 + hooks: + - id: remove-crlf + - id: remove-tabs +- repo: https://github.com/sirosen/fix-smartquotes + rev: 0.2.0 + hooks: + - id: fix-smartquotes +- repo: https://github.com/k8s-at-home/sops-pre-commit + rev: v1.1.0 + hooks: + - id: sops-encrypted-check diff --git a/.sops.yaml b/.sops.yaml new file mode 100644 index 00000000..68d71dc0 --- /dev/null +++ b/.sops.yaml @@ -0,0 +1,4 @@ +--- +creation_rules: +- encrypted_regex: '((?i)(pass|secret($|[^N])|key|token|^data$|^stringData))' + pgp: >- diff --git a/README.md b/README.md index 1a0cd2c2..8a742401 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,37 @@ -# home-cluster-k3s -Template for creating a k3s cluster with k3sup, flux and sops +# cluster-k3s + +Template for creating a k3s cluster with [k3sup](https://github.com/alexellis/k3sup), [Flux](https://toolkit.fluxcd.io/) and [SOPS](https://github.com/mozilla/sops) + +This template will bootstrap the nodes you want with the following components + +- k3s +- flux +- metallb +- flannel + +## :memo:  Prerequisites + +### :computer:  Nodes + +Bare metal or VMs with a modern operating system like Ubuntu, Debian or CentOS. + +### :wrench:  Tools + +| Tool | Purpose | Required | +|--------------------------------------------------------|---------------------------------------------------------------------|:--------:| +| [k3sup](https://github.com/alexellis/k3sup) | Tool to install k3s on your nodes | ✅ | +| [flux](https://toolkit.fluxcd.io/) | Operator that manages your k8s cluster based on your Git repository | ✅ | +| [SOPS](https://github.com/mozilla/sops) | Encrypts k8s secrets with GnuPG | ✅ | +| [GnuPG](https://gnupg.org/) | Encrypts and signs your data | ✅ | +| [direnv](https://github.com/direnv/direnv) | Exports env vars based on present working directory | ❌ | +| [pre-commit](https://github.com/pre-commit/pre-commit) | Keeps formatting consistency across your files | ❌ | + +## :rocket:  Installation + +### :sailboat:  k3sup + +Bootstrap your nodes with k3s using k3sup + +## :handshake:  Thanks + +A lot of inspiration for my cluster came from the people that have shared their clusters over at [awesome-home-kubernetes](https://github.com/k8s-at-home/awesome-home-kubernetes) \ No newline at end of file