diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..d3d1cbc2 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,8 @@ +# Please sort into logical groups with comment headers. Sort groups in order of specificity. +# For example, default owners should always be the first group. +# Sort lines alphabetically within these groups to avoid accidentally adding duplicates. +# +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners + +# Default file owners. +* @bitwarden/dept-devops diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..61d7e2b9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,14 @@ +blank_issues_enabled: false +contact_links: + - name: Feature Requests + url: https://community.bitwarden.com/c/feature-requests/ + about: Request new features using the Community Forums. Please search existing feature requests before making a new one. + - name: Bitwarden Community Forums + url: https://community.bitwarden.com + about: Please visit the community forums for general community discussion, support and the development roadmap. + - name: Customer Support + url: https://bitwarden.com/contact/ + about: Please contact our customer support for account issues and general customer support. + - name: Security Issues + url: https://hackerone.com/bitwarden + about: We use HackerOne to manage security disclosures. diff --git a/.github/ISSUE_TEMPLATE/self-host.yml b/.github/ISSUE_TEMPLATE/self-host.yml new file mode 100644 index 00000000..9e3da36f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/self-host.yml @@ -0,0 +1,69 @@ +name: Bitwarden Self-Host Chart Bug Report +description: File a bug report +labels: [bug, self-host] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + + Please do not submit feature requests. The [Community Forums](https://community.bitwarden.com) has a section for submitting, voting for, and discussing product feature requests. + - type: textarea + id: reproduce + attributes: + label: Steps To Reproduce + description: How can we reproduce the behavior. + value: | + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. Click on '...' + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected Result + description: A clear and concise description of what you expected to happen. + validations: + required: true + - type: textarea + id: actual + attributes: + label: Actual Result + description: A clear and concise description of what is happening. + validations: + required: true + - type: textarea + id: screenshots + attributes: + label: Screenshots or Videos + description: If applicable, add screenshots and/or a short video to help explain your problem. + - type: textarea + id: additional-context + attributes: + label: Additional Context + description: Add any other context about the problem here. + - type: input + id: version + attributes: + label: Chart Version + description: Please use `helm list --namespace ns_here` and copy the chart name/version + validations: + required: true + - type: textarea + id: environment-details + attributes: + label: Environment Details + description: Please provide some additional environment details. + placeholder: | + - Environment: [e.g. AKS, EKS, K3s, K8s, OpenShift] + - Hardware: [e.g. Intel 6-core, 8GB RAM] + - type: checkboxes + id: issue-tracking-info + attributes: + label: Issue Tracking Info + description: | + Issue tracking information + options: + - label: I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress. diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 00000000..39a2b6e9 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ] +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..5fc80d59 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,78 @@ +--- +name: Build + +on: + push: + branches-ignore: + - "gh-pages" + paths-ignore: + - ".github/workflows/**" + workflow_dispatch: + +jobs: + build: + name: Build Helm charts + runs-on: ubuntu-22.04 + environment: Production + strategy: + fail-fast: false + matrix: + include: + - chart_name: self-host + steps: + - name: Checkout repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Set up Helm + uses: Azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5 + with: + version: 'v3.13.1' + + - name: Login to Azure - CI Subscription + uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Set up GPG key and passphrase + run: | + az keyvault secret download \ + --vault-name bitwarden-ci \ + --name helm-signing-gpg-private-key \ + --file private + + az keyvault secret download \ + --vault-name bitwarden-ci \ + --name helm-signing-gpg-private-key-passphrase \ + --file .passphrase + + az keyvault secret download \ + --vault-name bitwarden-ci \ + --name helm-signing-gpg-public-key \ + --file public + + gpg --dearmor private + gpg --dearmor public + + - name: Package Helm chart + id: helm_package + run: | + helm package \ + --sign \ + --key "DevOps Team" \ + --keyring private.gpg \ + --passphrase-file .passphrase \ + charts/${{ matrix.chart_name }} + PKG_NAME=$(ls *.tgz) + echo "name=$PKG_NAME" >> "$GITHUB_OUTPUT" + + - name: Verify Helm chart + run: helm verify ${{ steps.helm_package.outputs.name }} --keyring public.gpg + + - name: Upload Helm chart artifact + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + with: + name: ${{ matrix.chart_name }} + path: | + ${{ steps.helm_package.outputs.name }} + ${{ steps.helm_package.outputs.name }}.prov + if-no-files-found: error diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 00000000..de78fe2c --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,49 @@ +--- +name: Lint + +on: + pull_request: + paths: + - 'charts/*' + push: + branches: + - main + paths: + - 'charts/*' + workflow_dispatch: + +jobs: + lint: + name: Lint Helm charts + runs-on: ubuntu-22.04 + steps: + - name: Checkout repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: Azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5 + with: + version: 'v3.13.1' + + - name: Set up Python + uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + with: + python-version: '3.12' + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@e8788873172cb653a90ca2e819d79d65a66d4e76 # v2.4.0 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + CHANGED=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) + if [[ -n "$CHANGED" ]]; then + echo "changed=true" >> $GITHUB_OUTPUT + fi + + - name: Run chart-testing (lint) + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --target-branch ${{ github.event.repository.default_branch }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..11bec7f1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,90 @@ +--- +name: Release +run-name: Release - ${{ inputs.release_mode }} + +on: + workflow_dispatch: + inputs: + release_mode: + description: "Release Mode" + default: "Standard Release" + type: choice + options: + - Standard Release + - Dry Run + +jobs: + setup: + name: Setup + runs-on: ubuntu-22.04 + steps: + - name: Branch check + if: ${{ github.event.inputs.release_mode != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then + echo "===================================" + echo "[!] Can only release from the 'main' branch" + echo "===================================" + exit 1 + fi + + release: + name: Release Helm chart + runs-on: ubuntu-22.04 + needs: setup + permissions: + actions: read + contents: write + packages: write + steps: + - name: Checkout repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Set up Helm + uses: Azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5 + with: + version: v3.13.1 + + - name: Download Helm chart artifact + uses: bitwarden/gh-actions/download-artifacts@master + with: + branch: main + path: .cr-release-packages + workflow: build.yml + workflow_conclusion: success + + - name: Release Helm chart + if: ${{ github.event.inputs.release_mode != 'Dry Run' }} + env: + CR_GENERATE_RELEASE_NOTES: true + CR_MAKE_RELEASE_LATEST: true + CR_SKIP_EXISTING: true + CR_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: helm/chart-releaser-action@be16258da8010256c6e82849661221415f031968 # v1.5.0 + with: + skip_packaging: true + + - name: Login to GitHub Container Registry + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push charts to GitHub Container Registry + if: ${{ github.event.inputs.release_mode != 'Dry Run' }} + run: | + shopt -s nullglob + for pkg in .cr-release-packages/*; do + if [ -z "${pkg:-}" ]; then + break + fi + helm push "${pkg}" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/charts" + done diff --git a/.github/workflows/update-versions.yml b/.github/workflows/update-versions.yml new file mode 100644 index 00000000..ef7695c0 --- /dev/null +++ b/.github/workflows/update-versions.yml @@ -0,0 +1,139 @@ +--- +name: Update Versions + +on: + workflow_dispatch: + +jobs: + setup: + name: Setup + if: github.ref_name == 'main' + runs-on: ubuntu-22.04 + outputs: + core_version: ${{ steps.get-core.outputs.version }} + core_version_update: ${{ steps.core-update.outputs.update }} + web_version: ${{ steps.get-web.outputs.version }} + web_version_update: ${{ steps.web-update.outputs.update }} + + steps: + - name: Checkout Branch + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Get Latest Core Version + id: get-core + uses: bitwarden/gh-actions/get-release-version@master + with: + repository: bitwarden/server + trim: true + + - name: Check if Core Version needs updating + id: core-update + env: + LATEST_CORE_VERSION: ${{ steps.get-core.outputs.version }} + run: | + CORE_VERSION=$(sed -r -n '/define "bitwarden.coreVersionDefault"/!b;n;'\ + 's/\{\{- "([0-9]+\.[0-9]+\.[0-9]+)" -\}\}/\1/p' helpers.tpl) + + echo "Core Version: $CORE_VERSION" + echo "Latest Core Version: $LATEST_CORE_VERSION" + if [ "$CORE_VERSION" != "$LATEST_CORE_VERSION" ]; then + echo "Needs Core update!" + echo "update=1" >> $GITHUB_OUTPUT + else + echo "update=0" >> $GITHUB_OUTPUT + fi + working-directory: charts/self-host/templates + + - name: Get Latest Web Version + id: get-web + uses: bitwarden/gh-actions/get-release-version@master + with: + repository: bitwarden/clients + monorepo: true + monorepo-project: web + trim: true + + - name: Check if Web Version needs updating + id: web-update + env: + LATEST_WEB_VERSION: ${{ steps.get-web.outputs.version }} + run: | + WEB_VERSION=$(sed -r -n '/define "bitwarden.webVersionDefault"/!b;n;'\ + 's/\{\{- "([0-9]+\.[0-9]+\.[0-9]+)" -\}\}/\1/p' helpers.tpl) + + echo "Web Version: $WEB_VERSION" + echo "Latest Web Version: $LATEST_WEB_VERSION" + if [ "$WEB_VERSION" != "$LATEST_WEB_VERSION" ]; then + echo "Needs Web update!" + echo "update=1" >> $GITHUB_OUTPUT + else + echo "update=0" >> $GITHUB_OUTPUT + fi + working-directory: charts/self-host/templates + + update-versions: + name: "Create update_versions branch" + if: | + needs.setup.outputs.core_version_update == 1 || + needs.setup.outputs.web_version_update == 1 + runs-on: ubuntu-22.04 + needs: setup + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout Branch + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Create Update Versions Branch + run: | + git switch -c update-versions + git push -u origin update-versions + + - name: Checkout Update Versions Branch + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: update-versions + + - name: Update Core Version + env: + VERSION: ${{ needs.setup.outputs.core_version }} + run: sed '/define "bitwarden.coreVersionDefault"/!b;n;c{{- "'$VERSION'" -}}' helpers.tpl + working-directory: charts/self-host/templates + + - name: Update Web Version + env: + VERSION: ${{ needs.setup.outputs.web_version }} + run: sed '/define "bitwarden.webVersionDefault"/!b;n;c{{- "'$VERSION'" -}}' helpers.tpl + working-directory: charts/self-host/templates + + - name: Commit updated files + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -m "Updated core and web versions" -a + + - name: Push changes + run: git push -u origin update-versions + + - name: Create Update Versions PR + env: + PR_BRANCH: "update-versions" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BASE_BRANCH: ${{ github.ref_name }} + TITLE: "Update core and web versions" + run: | + gh pr create --title "$TITLE" \ + --base "$BASE_BRANCH" \ + --head "$PR_BRANCH" \ + --label "automated pr" \ + --body " + ## Type of change + - [ ] Bug fix + - [ ] New feature development + - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) + - [ ] Build/deploy pipeline (DevOps) + - [X] Other + + ## Objective + Automated version updates to core and web versions in charts/self-host/templates/helpers.tpl." diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml new file mode 100644 index 00000000..69537489 --- /dev/null +++ b/.github/workflows/version-bump.yml @@ -0,0 +1,97 @@ +--- +name: Version Bump + +on: + workflow_dispatch: + inputs: + version_number: + description: "New Version" + required: true + +jobs: + bump_version: + name: "Bump Version to ${{ github.event.inputs.version_number }}" + runs-on: ubuntu-22.04 + environment: Production + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout Branch + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Login to Azure - CI Subscription + uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@master + with: + keyvault: "bitwarden-ci" + secrets: "github-gpg-private-key, github-gpg-private-key-passphrase" + + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0 + with: + gpg_private_key: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key }} + passphrase: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key-passphrase }} + git_user_signingkey: true + git_commit_gpgsign: true + + - name: "Create version_bump_${{ github.event.inputs.version_number }} branch" + run: git switch -c version_bump_${{ github.event.inputs.version_number }} + + - name: Bump Version + uses: bitwarden/gh-actions/version-bump@master + with: + version: ${{ github.event.inputs.version_number }} + file_path: "charts/self-host/Chart.yaml" + + - name: Setup git + run: | + git config --local user.email "106330231+bitwarden-devops-bot@users.noreply.github.com" + git config --local user.name "bitwarden-devops-bot" + + - name: Check if version changed + id: version-changed + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "changes_to_commit=TRUE" >> $GITHUB_OUTPUT + else + echo "changes_to_commit=FALSE" >> $GITHUB_OUTPUT + echo "No changes to commit!"; + fi + + - name: Commit files + if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} + run: git commit -m "Bumped version to ${{ github.event.inputs.version_number }}" -a + + - name: Push changes + if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} + run: git push -u origin version_bump_${{ github.event.inputs.version_number }} + + - name: Create Version PR + if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} + env: + PR_BRANCH: "version_bump_${{ github.event.inputs.version_number }}" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + BASE_BRANCH: main + TITLE: "Bump version to ${{ github.event.inputs.version_number }}" + run: | + gh pr create --title "$TITLE" \ + --base "$BASE" \ + --head "$PR_BRANCH" \ + --label "version update" \ + --label "automated pr" \ + --body " + ## Type of change + - [ ] Bug fix + - [ ] New feature development + - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) + - [ ] Build/deploy pipeline (DevOps) + - [X] Other + + ## Objective + Automated version bump to ${{ github.event.inputs.version_number }}" diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..47b1df1a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +.cr-release-packages +.cr-index \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..1ce87587 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..d1892bd0 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Bitwarden Helm Charts Repository + +- [Self-Host](charts/self-host/README.md) diff --git a/charts/self-host/.helmignore b/charts/self-host/.helmignore new file mode 100644 index 00000000..9fad829b --- /dev/null +++ b/charts/self-host/.helmignore @@ -0,0 +1,5 @@ +.helmignore + +/ci + +README.md diff --git a/charts/self-host/Chart.yaml b/charts/self-host/Chart.yaml new file mode 100644 index 00000000..5dbe106e --- /dev/null +++ b/charts/self-host/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v2 +name: self-host +version: "0.1.1-Beta" + +appVersion: "2023.9.1" +description: A Helm chart for deploying a Bitwarden instance on Kubernetes +home: https://github.com/bitwarden/helm-charts/tree/main/charts/self-host +icon: https://raw.githubusercontent.com/bitwarden/brand/master/icons/icon-square.svg +maintainers: + - name: dept-devops +type: application diff --git a/charts/self-host/README.md b/charts/self-host/README.md new file mode 100644 index 00000000..1e9666b1 --- /dev/null +++ b/charts/self-host/README.md @@ -0,0 +1,907 @@ + +# Bitwarden Helm Chart + +The purpose of this chart is to enable the deployment of [Bitwarden](https://bitwarden.com/) to different Kubernetes environments. This chart is built for usage across multiple Kubernetes hosting scenarios. + +## Requirements + +- Kubectl +- Helm 3 +- SSL cert and key or certificate provider +- SMTP server/account +- Storage Class that supports ReadWriteMany + +--- + +## Add the repo to Helm + +```shell +helm repo add bitwarden https://bitwarden.github.io/helm-charts/ +helm repo update +``` + +## Installation Steps + +### Request Installation secrets + +- Request an installation ID and key from: [https://bitwarden.com/host/](https://bitwarden.com/host/) + +### Create config file + +Run the following command to create a custom values file used for deployment: + +```shell +helm show values bitwarden/bitwarden > my-values.yaml +``` + +### Update the config file + +Edit the `my-values.yaml` file and fill out the values. Required values that must be set: + +- general.domain +- general.ingress.enabled (set to disbled if you are creating your own ingress) +- general.ingress.className (nginx example provided) +- general.ingress.annotations (nginx example provided) +- general.ingress.paths (nginx example provided) +- general.ingress.cert.tls.name +- general.email.replyToEmail +- general.email.smtpHost +- general.emal.smtpPort +- general.email.smtpSsl +- sharedStorageClassName +- database.enabled (set to disbled if using an external SQL server) + +Note that default values for Nginx have been setup for the ingress in the values.yaml file. __*However, you will need to uncomment the ingress annotations and edit them as necessary for your environment.*__ Some other ingress controller examples are provided later in this document. + +### Create namespace + +1. Create a namespace to deploy Bitwarden to. In this guide, we will be using `bitwarden` as the namespace. + - Run `kubectl create namespace bitwarden`. + +### Secrets + +Create a secret to set the following values. + +- globalSettings__installation__id +- globalSettings__installation__key +- globalSettings__mail__smtp__username +- globalSettings__mail__smtp__password +- globalSettings__yubico__clientId +- globalSettings__yubico__key +- SA_PASSWORD (if using the Bitwarden SQL pod) +- globalSettings__sqlServer__connectionString (if using your own SQL server) + +Here we document the process of creating the secret using the command line. However, you can also use a CSI secret provider class, which we document an example of under "Installing the Azure Key Vault CSI Driver" later in this README. + +Examples of kubectl secret creation are provided below. One is for use with SQL deployed in a pod. The other is for usage with an external SQL server. + +- With included SQL pod + + ```shell + kubectl create secret generic custom-secret -n bitwarden\ + --from-literal=globalSettings__installation__id="REPLACE" \ + --from-literal=globalSettings__installation__key="REPLACE" \ + --from-literal=globalSettings__mail__smtp__username="REPLACE" \ + --from-literal=globalSettings__mail__smtp__password="REPLACE" \ + --from-literal=globalSettings__yubico__clientId="REPLACE" \ + --from-literal=globalSettings__yubico__key="REPLACE" \ + --from-literal=SA_PASSWORD="REPLACE" + ``` + +- With external SQL server + + ```shell + kubectl create secret generic custom-secret -n bitwarden\ + --from-literal=globalSettings__installation__id="REPLACE" \ + --from-literal=globalSettings__installation__key="REPLACE" \ + --from-literal=globalSettings__mail__smtp__username="REPLACE" \ + --from-literal=globalSettings__mail__smtp__password="REPLACE" \ + --from-literal=globalSettings__sqlServer__connectionString="Data Source=tcp:,1433;Initial Catalog=vault;Persist Security Info=False;User ID=;Password=;Multiple Active Result Sets=False;Connect Timeout=30;Encrypt=True;Trust Server Certificate=True" \ + --from-literal=globalSettings__yubico__clientId="REPLACE" \ + --from-literal=globalSettings__yubico__key="REPLACE" \ + ``` + +__*NOTE: These commands are recorded in your shell history. To avoid this, consider setting up a CSI secret provider class.*__ + +Set `secrets.secretName` to the name of the secret created above. + +### Optional Values + +Replace any optional values in `my-values.yaml` to best fit your cluster. This includes changing of resource limits and requests. + +#### Raw Manifests Files + +This chart allows you to include other Kubernetes manifest files either pre- or post-install. To do this, update the `rawManifests` section of the chart + +```yaml +rawManifests: + preInstall: [] + postInstall: [] +``` + +The example below shows how you can use the raw manifests to install Traefik's IngressRoute instead of using the Kubernetes Ingress controller. Note that you will want to disable the ingress controller under `general.ingress.enabled` to use this. + +```yaml +rawManifests: + preInstall: [] + postInstall: + - apiVersion: traefik.containo.us/v1alpha1 + kind: Middleware + metadata: + name: "bitwarden-middleware-stripprefix" + spec: + stripPrefix: + prefixes: + - /api + - /attachements + - /icons + - /notifications + - /events + - /sso + - /identity + ##### NOTE: Admin will not function correctly with path strip middleware + - apiVersion: traefik.containo.us/v1alpha1 + kind: IngressRoute + metadata: + name: "bitwarden-ingress" + spec: + entryPoints: + - websecure + routes: + - kind: Rule + match: Host(`REPLACEME.COM`) && PathPrefix(`/`) + services: + - kind: Service + name: bitwarden-web + passHostHeader: true + port: 5000 + - kind: Rule + match: Host(`REPLACEME.COM`) && PathPrefix(`/api`) + services: + - kind: Service + name: bitwarden-api + port: 5000 + middlewares: + - name: "bitwarden-middleware-stripprefix" + - kind: Rule + match: Host(`REPLACEME.COM`) && PathPrefix(`/attachments`) + services: + - kind: Service + name: bitwarden-api + port: 5000 + middlewares: + - name: "bitwarden-middleware-stripprefix" + - kind: Rule + match: Host(`REPLACEME.COM`) && PathPrefix(`/icons`) + services: + - kind: Service + name: bitwarden-icons + port: 5000 + middlewares: + - name: "bitwarden-middleware-stripprefix" + - kind: Rule + match: Host(`REPLACEME.COM`) && PathPrefix(`/notifications`) + services: + - kind: Service + name: bitwarden-notifications + port: 5000 + middlewares: + - name: "bitwarden-middleware-stripprefix" + - kind: Rule + match: Host(`REPLACEME.COM`) && PathPrefix(`/events`) + services: + - kind: Service + name: bitwarden-events + port: 5000 + middlewares: + - name: "bitwarden-middleware-stripprefix" + - kind: Rule + match: Host(`REPLACEME.COM`) && PathPrefix(`/sso`) + services: + - kind: Service + name: bitwarden-sso + port: 5000 + middlewares: + - name: "bitwarden-middleware-stripprefix" + - kind: Rule + match: Host(`REPLACEME.COM`) && PathPrefix(`/identity`) + services: + - kind: Service + name: bitwarden-identity + port: 5000 + middlewares: + - name: "bitwarden-middleware-stripprefix" + ##### NOTE: Admin will not function correctly with path strip middleware + - kind: Rule + match: Host(`REPLACEME.COM`) && PathPrefix(`/admin`) + services: + - kind: Service + name: bitwarden-admin + port: 5000 + tls: + certResolver: letsencrypt +``` + +Note that the certResolver is deployed with the Traefik ingress configuration. + +### Run Helm Install + +1. Run `helm install bitwarden bitwarden/bitwarden -n bitwarden -f my-values.yaml`. + - This installs a release named `bitwarden`, in the namespace `bitwarden`, using values from `my-values.yaml`. + - This may take over a minute to fully come up (some of the services might register as failed in the meantime) + - You can see help information for the `helm install` command by running `helm install --help`. + +> The current Bitwarden release is architected in a way which requires the sharing of persistent data between containers and therefore requires storage which supports the access mode ReadWriteMany. + +Edit values.yaml and update to suit your configuration. + +Minimal required to get a running installation: + +## Example Deployment on AKS + +Below is an example of deploying this chart on AKS using various ingress controllers and cert-manager to provision the certificate from LetsEncrypt. + +### Create namespace in AKS + +```shell +kubectl create ns bitwarden +``` + +### Deploy the ingress controller + +#### Nginx + +This is the simplest ingress to setup and has been provided as the default. You will need the ingress controller installed if you have not already done so. Follow the basic configuration found at ["Create an unmanaged ingress controller"](https://learn.microsoft.com/en-us/azure/aks/ingress-basic?tabs=azure-cli#basic-configuration). + +Then update the my-values.yaml file: + +```yaml +general: + # Domain name for the service + domain: "REPLACE" + ingress: + # Set to false if using a custom ingress + enabled: true + # Current supported values for ingress type include: nginx + className: "nginx" + ## - Annotations to add to the Ingress resource + annotations: + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + nginx.ingress.kubernetes.io/use-regex: "true" + nginx.ingress.kubernetes.io/proxy-read-timeout: "300" + nginx.ingress.kubernetes.io/rewrite-target: /$1 +``` + +__*Make certain to uncomment the annotations section and tweak as necessary for your environment.*__ These annotations can be used as-is. + +#### Azure Application Gateway + +Azure customers might want to use an Azure Application Gateway as the ingress controller for their AKS cluster. You will want to [enable the Application Gateway ingress controller for your cluster](https://learn.microsoft.com/en-us/azure/application-gateway/tutorial-ingress-controller-add-on-existing) before making these configuration changes. + +Update the my-values.yaml file. Tweak the annotations as necessary for your environment. + +```yaml +general: + domain: "replaceme.com" + ingress: + enabled: true + className: "azure-application-gateway" # This value might be different depending on how you created your ingress controller. Use "kubectl get ingressclasses -A" to find the name if unsure + ## - Annotations to add to the Ingress resource + annotations: + appgw.ingress.kubernetes.io/ssl-redirect: "true" + appgw.ingress.kubernetes.io/use-private-ip: "false" # This might be true depending on your setup + appgw.ingress.kubernetes.io/rewrite-rule-set: "bitwarden-ingress" # Make note of whatever you set this value to. It will be used later. + appgw.ingress.kubernetes.io/connection-draining: "true" # Update as necessary + appgw.ingress.kubernetes.io/connection-draining-timeout: "30" # Update as necessary + ## - Labels to add to the Ingress resource + labels: {} + # Certificate options + tls: + # TLS certificate secret name + name: tls-secret + # Cluster cert issuer (ex. Let's Encrypt) name if one exists + clusterIssuer: letsencrypt-staging + paths: + web: + path: /* + pathType: Prefix + attachments: + path: /attachments/* + pathType: Prefix + api: + path: /api/* + pathType: Prefix + icons: + path: /icons/* + pathType: Prefix + notifications: + path: /notifications/* + pathType: Prefix + events: + path: /events/* + pathType: Prefix + sso: + path: /sso/* + pathType: Prefix + identity: + path: /identity/* + pathType: Prefix + admin: + path: /admin* + pathType: Prefix +``` + +__*NOTE: Make sure to update the paths to what you see here.*__ + +Further settings will need to be set after the deployment on the Application Gateway itself. + +### Let's Encrypt + +If you have not done so, first install cert-manager on the cluster. + +```shell +kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml +``` + +> It is recommended to use the staging configuration of Let's Encrypt until your DNS records have been pointed correctly. + +Use one of the following certificate issuers depending on if you are in a production or a pre-production environment: + +#### Staging + +```shell +cat <" # Set the clientID of the user-assigned managed identity to use + # clientID: "" # Setting this to use workload identity + keyvaultName: "" + cloudName: "AzurePublicCloud" + objects: | + array: + - | + objectName: installationid + objectAlias: installationid + objectType: secret + objectVersion: "" + - | + objectName: installationkey + objectAlias: installationkey + objectType: secret + objectVersion: "" + - | + objectName: smtpusername + objectAlias: smtpusername + objectType: secret + objectVersion: "" + - | + objectName: smtppassword + objectAlias: smtppassword + objectType: secret + objectVersion: "" + - | + objectName: yubicoclientid + objectAlias: yubicoclientid + objectType: secret + objectVersion: "" + - | + objectName: yubicokey + objectAlias: yubicokey + objectType: secret + objectVersion: "" + - | + objectName: sapassowrd #-OR- dbconnectionstring if external SQL + objectAlias: sapassowrd #-OR- dbconnectionstring if external SQL + objectType: secret + objectVersion: "" + tenantId: "" + secretObjects: + - secretName: "bitwarden-secret" + type: Opaque + data: + - objectName: installationid + key: globalSettings__installation__id + - objectName: installationkey + key: globalSettings__installation__key + key: globalSettings__mail__smtp__username + - objectName: smtppassword + key: globalSettings__mail__smtp__password + - objectName: yubicoclientid + key: globalSettings__yubico__clientId + - objectName: yubicokey + key: globalSettings__yubico__key + - objectName: sapassowrd #-OR- dbconnectionstring if external SQL + key: SA_PASSWORD #-OR- globalSettings__sqlServer__connectionString if external SQL +EOF +``` + +Note the spots in the definition that say `""`. These will need to be updated for your environment. Also note that you will again have the choice between using the SQL Server Pod and an external SQL Server. Those spots that will need to change have been marked with a comment. Finally, you can name the secrets in Azure Key Vault based on your own naming convention. If you do so, you must make certain that to update the objectName properties under `spec.parameters.objects.array` to match the secrets created in Key Vault. + +The following commands would create these secrts in a Key Vault: + +```shell +kvname="kv-aks-bw-helm-cus-01" +az keyvault secret set --name installationid --vault-name $kvname --value +az keyvault secret set --name installationkey --vault-name $kvname --value +az keyvault secret set --name smtpusername --vault-name $kvname --value +az keyvault secret set --name smtppassword --vault-name $kvname --value +az keyvault secret set --name yubicoclientid --vault-name $kvname --value +az keyvault secret set --name yubicokey --vault-name $kvname --value +az keyvault secret set --name sapassword --vault-name $kvname --value '""' +# - OR - +# az keyvault secret set --name dbconnectionstring --vault-name $kvname --value '""' +``` + +__*NOTE: These values will be stored in your shell history. There are many other ways to set Key Vault secrets that are outside of the scope of this document. This provides you with one option.*__ + +Now, edit `my-values.yaml` to use this secret provider class we created. + +```yaml +secrets: + secretName: bitwarden-secret # spec.secretObjects.secretName in example + secretProviderClass: bitwarden-azure-keyvault-csi #metadata.name in example +``` + +### Helm + +```shell +helm install bitwarden ./bitwarden -n bitwarden +``` + +### Azure Application Gateway Rewrite Set + +Application Gateway ingress deployments have one more required step for Bitwarden to function correctly. If you are using another ingress controller, you may skip to the next section. + +We will need to create a rewrite set on the Application Gateway. There are various ways of doing this, but we will discuss using the Azure Portal. + + 1. Navigate to the Application Gateway in the Azure Portal + 2. Once in the Application Gateway, find the "Rewrites" blade in the left-hand navigation menu. + 3. Click the "+ Rewrite set" button at the top of the main page section to add a new rewrite set + 4. On the "Update rewrite set" page in the "Name and Association" tab: + - Set the Name field to the same value specified in the `appgw.ingress.kubernetes.io/rewrite-rule-set` ingress annotation + - Select all routing rules that start with something similar to "pr-bitwarden-bitwarden-ingress-rule-*" + 5. Click Next + 6. On the "Rewrite rule configuration" tab, click the "Add rewrite rule" button + 7. Enter a name for the rule. This can be anything that helps you with organization. Something simlar to "bitwarden-rewrite" will work. + 8. The rule sequence value does not matter for this purpose. + 9. Add a condition and set the following values: + - Type of variable to check: Server variable + - Server variable: uri_path + - Case-sensitive: No + - Operator: equal (=) + - Pattern to match: `^(\/(?!admin)[^\/]*)\/(.*)` + - Click OK + 10. Add an action and set the following values: + - Rewrite type: URL + - Action type: Set + - Components: URL path + - URL path value: `/{var_uri_path_2}` + - Re-evalueate path map: Unchecked + - Click OK + 11. Click "Create" at the bottom of the screen + +### Pointing your DNS + +#### Nginx Deployments + +You can find the public IP to point your DNS record at by running: + +```shell +kubectl get ingress -n bitwarden + +``` + +#### Application Gateway Deployments + +The public IP will be found on the Overview tab of the Application Gateway service in the Azure Portal. + +## Example Deployment on OpenShift + +This section will walk through an example of hosting Bitwarden on OpenShift. Note that there are many different permutations of how you can host Bitwarden on this platform. We will provide some basic pointers. + +### Create project in OpenShift + +Run the following shell commands to create a project in OpenShift. + +```shell +oc new-project bitwarden +oc project bitwarden +``` + +### Setup ingress + +We will use OpenShift Routes for our ingress in this example. Alternatively, ingress operators could be used. + +#### Disable default ingress + +In your `my-values.yaml`, disable the default ingress. + +```yaml +general: + domain: "replaceme.com" + ingress: + enabled: false +``` + +You can ignore the rest of the ingress section. + +#### Add raw manifests for routes + +Update the `rawManifests` section in `my-values.yaml` to include OpenShift Route manifests. + +```yaml +rawManifests: + preInstall: [] + postInstall: + - kind: Route + apiVersion: route.openshift.io/v1 + metadata: + name: bitwarden-web + namespace: bitwarden + annotations: + haproxy.router.openshift.io/rewrite-target: / + spec: + host: bitwarden.apps-crc.testing + path: "/" + to: + kind: Service + name: bitwarden-web + weight: 100 + port: + targetPort: 5000 + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + destinationCACertificate: '' + - kind: Route + apiVersion: route.openshift.io/v1 + metadata: + name: bitwarden-api + namespace: bitwarden + annotations: + haproxy.router.openshift.io/rewrite-target: / + spec: + host: bitwarden.apps-crc.testing + path: "/api" + to: + kind: Service + name: bitwarden-api + weight: 100 + port: + targetPort: 5000 + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + destinationCACertificate: '' + - kind: Route + apiVersion: route.openshift.io/v1 + metadata: + name: bitwarden-attachments + namespace: bitwarden + annotations: + haproxy.router.openshift.io/rewrite-target: / + spec: + host: bitwarden.apps-crc.testing + path: "/attachments" + to: + kind: Service + name: bitwarden-attachments + weight: 100 + port: + targetPort: 5000 + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + destinationCACertificate: '' + - kind: Route + apiVersion: route.openshift.io/v1 + metadata: + name: bitwarden-icons + namespace: bitwarden + annotations: + haproxy.router.openshift.io/rewrite-target: / + spec: + host: bitwarden.apps-crc.testing + path: "/icons" + to: + kind: Service + name: bitwarden-icons + weight: 100 + port: + targetPort: 5000 + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + destinationCACertificate: '' + - kind: Route + apiVersion: route.openshift.io/v1 + metadata: + name: bitwarden-notifications + namespace: bitwarden + annotations: + haproxy.router.openshift.io/rewrite-target: / + spec: + host: bitwarden.apps-crc.testing + path: "/notifications" + to: + kind: Service + name: bitwarden-notifications + weight: 100 + port: + targetPort: 5000 + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + destinationCACertificate: '' + - kind: Route + apiVersion: route.openshift.io/v1 + metadata: + name: bitwarden-events + namespace: bitwarden + annotations: + haproxy.router.openshift.io/rewrite-target: / + spec: + host: bitwarden.apps-crc.testing + path: "/events" + to: + kind: Service + name: bitwarden-events + weight: 100 + port: + targetPort: 5000 + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + destinationCACertificate: '' + - kind: Route + apiVersion: route.openshift.io/v1 + metadata: + name: bitwarden-sso + namespace: bitwarden + annotations: + haproxy.router.openshift.io/rewrite-target: / + spec: + host: bitwarden.apps-crc.testing + path: "/sso" + to: + kind: Service + name: bitwarden-sso + weight: 100 + port: + targetPort: 5000 + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + destinationCACertificate: '' + - kind: Route + apiVersion: route.openshift.io/v1 + metadata: + name: bitwarden-identity + namespace: bitwarden + annotations: + haproxy.router.openshift.io/rewrite-target: / + spec: + host: bitwarden.apps-crc.testing + path: "/identity" + to: + kind: Service + name: bitwarden-identity + weight: 100 + port: + targetPort: 5000 + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + destinationCACertificate: '' + - kind: Route + apiVersion: route.openshift.io/v1 + metadata: + name: bitwarden-admin + namespace: bitwarden + annotations: + # Rewrite will not work with admin + spec: + host: bitwarden.apps-crc.testing + path: "/admin" + to: + kind: Service + name: bitwarden-admin + weight: 100 + port: + targetPort: 5000 + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + destinationCACertificate: '' +``` + +Note that in this example we are setting `destinationCACertificate` to an empty string. This will use the default certificate setup in OpenShift. Alternatively, specify a certificate name here, or you can use Let's Encrypt by following this guide: [Secure Red Had OpenShift routs with Let's Encrypt](https://developer.ibm.com/tutorials/secure-red-hat-openshift-routes-with-lets-encrypt/). If you do so, you will need to add `kubernetes.io/tls-acme: "true"` to the annotations for each route. + +### Setup storage class + +A shared storage class will be required. As stated earlier in the document, a ReadWriteMany-capable Storage Class will need to be set up. There are several options for this in OpenShift. One viable option is to use the [NFS Subdir External Provisioner](https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/blob/master/charts/nfs-subdir-external-provisioner/README.md). + +### Setting secrets + +Using a secrets provider [HashiCorp Vault](https://developer.hashicorp.com/vault/docs/platform/k8s/csi/installation#installation-on-openshift) is valid, but we will focus on using the `oc` command to deploy our secrets. The process is similar to using `kubectl` detailed earlier. + +```shell +oc create secret generic custom-secret -n bitwarden \ + --from-literal=globalSettings__installation__id="REPLACE" \ + --from-literal=globalSettings__installation__key="REPLACE" \ + --from-literal=globalSettings__mail__smtp__username="REPLACE" \ + --from-literal=globalSettings__mail__smtp__password="REPLACE" \ + --from-literal=globalSettings__yubico__clientId="REPLACE" \ + --from-literal=globalSettings__yubico__key="REPLACE" \ + --from-literal=SA_PASSWORD="REPLACE" # If using SQL pod + # --from-literal="REPLACE" # If using your own SQL server +``` + +### Create a service account + +Bitwarden currently requires the use of a service account in OpenShift due to each container's need to run elevated commands on start-up. These commands are blocked by OpenShift's restricted SCCs. We need to create a service account and assign it to the `anyuid` SCC. + +```shell +oc create sa bitwarden-sa +oc adm policy add-scc-to-user anyuid -z bitwarden-sa +``` + +Next, update `my-values.yaml` to use this service account. Note that this is a different service account from the one in the `serviceAccount` section of the values YAML file. Instead, set the following keys to the name of the service account created: + +- component.admin.podServiceAccount +- component.api.podServiceAccount +- component.attachments.podServiceAccount +- component.events.podServiceAccount +- component.icons.podServiceAccount +- component.identity.podServiceAccount +- component.notifications.podServiceAccount +- component.scim.podServiceAccount +- component.sso.podServiceAccount +- component.web.podServiceAccount +- database.podServiceAccount + +#### Example + +```yaml +component: + # The Admin component + admin: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/admin + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + podServiceAccount: bitwarden-sa +``` + +__*NOTE: You can create your own SSC to fine-tune the security of these pods. [Managing SSCs in OpenShift](https://cloud.redhat.com/blog/managing-sccs-in-openshift) describes the out-of-the-box SSCs and how to create your own if desired.*__ + +### Update other settings + +Update the other settings in `my-values.yaml` based on your environment. Follow the instructions earlier in this document for required settings to update. + +### Deploy via Helm + +```shell +helm install bitwarden ./bitwarden -n bitwarden +``` diff --git a/charts/self-host/templates/admin.yaml b/charts/self-host/templates/admin.yaml new file mode 100644 index 00000000..733ac6cd --- /dev/null +++ b/charts/self-host/templates/admin.yaml @@ -0,0 +1,99 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.admin" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: admin + app: {{ template "bitwarden.admin" . }} +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.admin.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.admin" . }} + template: + metadata: + labels: + app.kubernetes.io/component: admin + app: {{ template "bitwarden.admin" . }} +{{ include "bitwarden.labels" . | indent 8 }} + spec: + {{- if .Values.component.admin.podServiceAccount }} + serviceAccount: "{{ .Values.component.admin.podServiceAccount }}" + serviceAccountName: "{{ .Values.component.admin.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.admin" . }} + image: "{{ .Values.component.admin.image.name }}:{{ template "bitwarden.coreVersion" }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + {{- if .Values.database.enabled }} + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + {{- end }} + env: + - name: ASPNETCORE_URLS + value: http://+:5000 + livenessProbe: + httpGet: + path: /alive + port: 5000 + initialDelaySeconds: 180 + ports: + - containerPort: 5000 + resources: +{{ toYaml .Values.component.admin.resources | indent 10 }} + volumeMounts: + - name: dataprotection + mountPath: /etc/bitwarden/core/aspnet-dataprotection + - name: licenses + mountPath: /etc/bitwarden/core/licenses + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + securityContext: +{{ toYaml .Values.component.admin.securityContext | indent 10 }} + volumes: + - name: dataprotection + persistentVolumeClaim: + claimName: {{ template "bitwarden.dataprotection" . }} + - name: licenses + persistentVolumeClaim: + claimName: {{ template "bitwarden.licenses" . }} + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "bitwarden.admin" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: admin +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.admin.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + selector: + app: {{ template "bitwarden.admin" . }} + ports: + - port: 5000 + targetPort: 5000 diff --git a/charts/self-host/templates/api.yaml b/charts/self-host/templates/api.yaml new file mode 100644 index 00000000..16875e2c --- /dev/null +++ b/charts/self-host/templates/api.yaml @@ -0,0 +1,104 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.api" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "bitwarden.api" . }} + app.kubernetes.io/component: api +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.api.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.api" . }} + template: + metadata: + labels: + app: {{ template "bitwarden.api" . }} + app.kubernetes.io/component: api +{{ include "bitwarden.labels" . | indent 8 }} + spec: + {{- if .Values.component.api.podServiceAccount }} + serviceAccount: "{{ .Values.component.api.podServiceAccount }}" + serviceAccountName: "{{ .Values.component.api.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.api" . }} + image: "{{ .Values.component.api.image.name }}:{{ template "bitwarden.coreVersion" }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + {{- if .Values.database.enabled }} + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + {{- end }} + env: + - name: ASPNETCORE_URLS + value: http://+:5000 + livenessProbe: + httpGet: + path: /alive + port: 5000 + initialDelaySeconds: 180 + ports: + - containerPort: 5000 + resources: +{{ toYaml .Values.component.api.resources | indent 10 }} + volumeMounts: + - name: attachments + mountPath: /etc/bitwarden/core/attachments + - name: dataprotection + mountPath: /etc/bitwarden/core/aspnet-dataprotection + - name: licenses + mountPath: /etc/bitwarden/core/licenses + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + securityContext: +{{ toYaml .Values.component.api.securityContext | indent 10 }} + volumes: + - name: dataprotection + persistentVolumeClaim: + claimName: {{ template "bitwarden.dataprotection" . }} + - name: attachments + persistentVolumeClaim: + claimName: {{ template "bitwarden.attachments" . }} + - name: licenses + persistentVolumeClaim: + claimName: {{ template "bitwarden.licenses" . }} + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "bitwarden.api" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: api +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.api.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + selector: + app: {{ template "bitwarden.api" . }} + ports: + - port: 5000 + targetPort: 5000 diff --git a/charts/self-host/templates/attachments.yaml b/charts/self-host/templates/attachments.yaml new file mode 100644 index 00000000..acddaab7 --- /dev/null +++ b/charts/self-host/templates/attachments.yaml @@ -0,0 +1,94 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.attachments" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "bitwarden.attachments" . }} + app.kubernetes.io/component: attachments +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.attachments.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.attachments" . }} + template: + metadata: + labels: + app: {{ template "bitwarden.attachments" . }} + app.kubernetes.io/component: attachments +{{ include "bitwarden.labels" . | indent 8 }} + spec: + {{- if .Values.component.attachments.podServiceAccount }} + serviceAccount: "{{ .Values.component.attachments.podServiceAccount }}" + serviceAccountName: "{{ .Values.component.attachments.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.attachments" . }} + image: "{{ .Values.component.attachments.image.name }}:{{ template "bitwarden.coreVersion" }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + {{- if .Values.database.enabled }} + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + {{- end }} + env: + - name: ASPNETCORE_URLS + value: http://+:5000 + livenessProbe: + httpGet: + path: /alive + port: 5000 + initialDelaySeconds: 180 + ports: + - containerPort: 5000 + resources: +{{ toYaml .Values.component.attachments.resources | indent 10 }} + volumeMounts: + - name: attachments + mountPath: /etc/bitwarden/core/attachments + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + securityContext: +{{ toYaml .Values.component.attachments.securityContext | indent 10 }} + volumes: + - name: attachments + persistentVolumeClaim: + claimName: {{ template "bitwarden.attachments" . }} + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "bitwarden.attachments" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: attachments +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.attachments.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + selector: + app: {{ template "bitwarden.attachments" . }} + ports: + - port: 5000 + targetPort: 5000 diff --git a/charts/self-host/templates/events.yaml b/charts/self-host/templates/events.yaml new file mode 100644 index 00000000..4a971c50 --- /dev/null +++ b/charts/self-host/templates/events.yaml @@ -0,0 +1,89 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.events" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "bitwarden.events" . }} + app.kubernetes.io/component: events +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.events.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.events" . }} + template: + metadata: + labels: + app: {{ template "bitwarden.events" . }} + app.kubernetes.io/component: events +{{ include "bitwarden.labels" . | indent 8 }} + spec: + {{- if .Values.component.events.podServiceAccount }} + serviceAccount: "{{ .Values.component.events.podServiceAccount }}" + serviceAccountName: "{{ .Values.component.events.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.events" . }} + image: "{{ .Values.component.events.image.name }}:{{ template "bitwarden.coreVersion" }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + {{- if .Values.database.enabled }} + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + {{- end }} + env: + - name: ASPNETCORE_URLS + value: http://+:5000 + livenessProbe: + httpGet: + path: /alive + port: 5000 + initialDelaySeconds: 180 + ports: + - containerPort: 5000 + resources: +{{ toYaml .Values.component.events.resources | indent 10 }} + volumeMounts: + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + securityContext: +{{ toYaml .Values.component.events.securityContext | indent 10 }} + volumes: + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "bitwarden.events" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: events +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.events.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + selector: + app: {{ template "bitwarden.events" . }} + ports: + - port: 5000 + targetPort: 5000 diff --git a/charts/self-host/templates/helpers.tpl b/charts/self-host/templates/helpers.tpl new file mode 100644 index 00000000..305c080e --- /dev/null +++ b/charts/self-host/templates/helpers.tpl @@ -0,0 +1,233 @@ +{{- define "bitwarden.coreVersionDefault" -}} +{{- "2023.9.1" -}} +{{- end -}} +{{- define "bitwarden.webVersionDefault" -}} +{{- "2023.9.2" -}} +{{- end -}} + +{{/* +Get the coreVersion for image tags +*/}} +{{- define "bitwarden.coreVersion" -}} +{{- default ( include "bitwarden.coreVersionDefault" nil ) .Values.general.coreVersionOverride -}} +{{- end -}} + +{{/* +Get the webVersion for image tags +*/}} +{{- define "bitwarden.webVersion" -}} +{{- default ( include "bitwarden.webVersionDefault" nil ) .Values.general.webVersionOverride -}} +{{- end -}} + +{{/* +Expand the name of the chart. +*/}} +{{- define "bitwarden.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "bitwarden.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "bitwarden.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +The name of the service account to use +*/}} +{{- define "bitwarden.serviceAccountName" -}} +{{- default (include "bitwarden.fullname" .) .Values.serviceAccount -}} +{{- end -}} + +{{/* +Generate basic labels +*/}} +{{- define "bitwarden.labels" -}} +app.kubernetes.io/name: {{ template "bitwarden.name" . }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +app.kubernetes.io/instance: {{ .Release.Name }} +helm.sh/chart: {{ template "bitwarden.chart" . }} +{{- if .Values.general.labels }} +{{ toYaml .Values.general.labels }} +{{- end -}} +{{- end -}} + +{{/* +Generate basic labels +*/}} +{{- define "bitwarden.rawPostInstallAnnotations" -}} +"helm.sh/hook": post-install,post-upgrade +"helm.sh/hook-weight": "9" +{{- end -}} + +{{/* +Generate basic labels +*/}} +{{- define "bitwarden.rawPreInstallAnnotations" -}} +"helm.sh/hook": pre-install,pre-upgrade +"helm.sh/hook-weight": "0" +{{- end -}} + + +{{/* +Name of Web components +*/}} +{{- define "bitwarden.web" -}} +{{ template "bitwarden.fullname" . }}-web +{{- end -}} + +{{/* +Name of Admin components +*/}} +{{- define "bitwarden.admin" -}} +{{ template "bitwarden.fullname" . }}-admin +{{- end -}} + +{{/* +Name of API components +*/}} +{{- define "bitwarden.api" -}} +{{ template "bitwarden.fullname" . }}-api +{{- end -}} + +{{/* +Name of Attachments components +*/}} +{{- define "bitwarden.attachments" -}} +{{ template "bitwarden.fullname" . }}-attachments +{{- end -}} + +{{/* +Name of Events components +*/}} +{{- define "bitwarden.events" -}} +{{ template "bitwarden.fullname" . }}-events +{{- end -}} + +{{/* +Name of Icons components +*/}} +{{- define "bitwarden.icons" -}} +{{ template "bitwarden.fullname" . }}-icons +{{- end -}} + +{{/* +Name of Identity components +*/}} +{{- define "bitwarden.identity" -}} +{{ template "bitwarden.fullname" . }}-identity +{{- end -}} + + +{{/* +Name of Notifications components +*/}} +{{- define "bitwarden.notifications" -}} +{{ template "bitwarden.fullname" . }}-notifications +{{- end -}} + +{{/* +Name of SSO components +*/}} +{{- define "bitwarden.sso" -}} +{{ template "bitwarden.fullname" . }}-sso +{{- end -}} + + +{{/* +Name of Webhook components +*/}} +{{- define "bitwarden.webhook" -}} +{{ template "bitwarden.fullname" . }}-webhook +{{- end -}} + + +{{/* +Name of MSSQL components +*/}} +{{- define "bitwarden.mssql" -}} +{{ template "bitwarden.fullname" . }}-mssql +{{- end -}} + + +{{/* +Name of Dataprotection volume +*/}} +{{- define "bitwarden.dataprotection" -}} +{{ template "bitwarden.fullname" . }}-dataprotection +{{- end -}} + +{{/* +Name of Licenses volume +*/}} +{{- define "bitwarden.licenses" -}} +{{ template "bitwarden.fullname" . }}-licenses +{{- end -}} + + +{{/* +Name of MSSQL Backups volume +*/}} +{{- define "bitwarden.mssqlBackups" -}} +{{ template "bitwarden.fullname" . }}-mssqlbackups +{{- end -}} + +{{/* +Name of MSSQL Data volume +*/}} +{{- define "bitwarden.mssqlData" -}} +{{ template "bitwarden.fullname" . }}-mssqldata +{{- end -}} + +{{/* +Name of MSSQL Log volume +*/}} +{{- define "bitwarden.mssqlLog" -}} +{{ template "bitwarden.fullname" . }}-mssqllog +{{- end -}} + +{{/* +Name of the Secret Provider Class +*/}} +{{- define "bitwarden.secretProviderClass" -}} +{{ template "bitwarden.fullname" . }}-secretproviderclass +{{- end -}} + +{{/* +Name of Ingress components +*/}} +{{- define "bitwarden.ingress" -}} +{{ template "bitwarden.fullname" . }}-ingress +{{- end -}} + +{{/* +Name of Feature Flag configMap +*/}} +{{- define "bitwarden.featureflags" -}} +{{ template "bitwarden.fullname" . }}-featureflags +{{- end -}} + +{{/* +Name of SCIM components +*/}} +{{- define "bitwarden.scim" -}} +{{ template "bitwarden.fullname" . }}-scim +{{- end -}} diff --git a/charts/self-host/templates/icons.yaml b/charts/self-host/templates/icons.yaml new file mode 100644 index 00000000..886a7bd5 --- /dev/null +++ b/charts/self-host/templates/icons.yaml @@ -0,0 +1,89 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.icons" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "bitwarden.icons" . }} + app.kubernetes.io/component: icons +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.icons.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.icons" . }} + template: + metadata: + labels: + app: {{ template "bitwarden.icons" . }} + app.kubernetes.io/component: icons +{{ include "bitwarden.labels" . | indent 8 }} + spec: + {{- if .Values.component.icons.podServiceAccount }} + serviceAccount: "{{ .Values.component.icons.podServiceAccount }}" + serviceAccountName: "{{ .Values.component.icons.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.icons" . }} + image: "{{ .Values.component.icons.image.name }}:{{ template "bitwarden.coreVersion" }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + {{- if .Values.database.enabled }} + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + {{- end }} + env: + - name: ASPNETCORE_URLS + value: http://+:5000 + livenessProbe: + httpGet: + path: /alive + port: 5000 + initialDelaySeconds: 180 + ports: + - containerPort: 5000 + volumeMounts: + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + resources: +{{ toYaml .Values.component.icons.resources | indent 10 }} + securityContext: +{{ toYaml .Values.component.icons.securityContext | indent 10 }} + volumes: + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "bitwarden.icons" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: icons +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.icons.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + selector: + app: {{ template "bitwarden.icons" . }} + ports: + - port: 5000 + targetPort: 5000 diff --git a/charts/self-host/templates/identity.yaml b/charts/self-host/templates/identity.yaml new file mode 100644 index 00000000..94ac047f --- /dev/null +++ b/charts/self-host/templates/identity.yaml @@ -0,0 +1,106 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.identity" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "bitwarden.identity" . }} + app.kubernetes.io/component: identity +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.identity.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.identity" . }} + template: + metadata: + labels: + app: {{ template "bitwarden.identity" . }} + app.kubernetes.io/component: identity +{{ include "bitwarden.labels" . | indent 8 }} + spec: + {{- if .Values.component.identity.podServiceAccount }} + serviceAccount: "{{ .Values.component.identity.podServiceAccount }}" + serviceAccountName: "{{ .Values.component.identity.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.identity" . }} + image: "{{ .Values.component.identity.image.name }}:{{ template "bitwarden.coreVersion" }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + {{- if .Values.database.enabled }} + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + {{- end }} + - secretRef: + name: {{ .Release.Name }}-identity-cert-password + env: + - name: ASPNETCORE_URLS + value: http://+:5000 + livenessProbe: + httpGet: + path: /alive + port: 5000 + initialDelaySeconds: 180 + ports: + - containerPort: 5000 + resources: +{{ toYaml .Values.component.identity.resources | indent 10 }} + volumeMounts: + - name: identity + mountPath: /etc/bitwarden/identity + - name: dataprotection + mountPath: /etc/bitwarden/core/aspnet-dataprotection + - name: licenses + mountPath: /etc/bitwarden/core/licenses + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + securityContext: +{{ toYaml .Values.component.identity.securityContext | indent 10 }} + volumes: + - name: identity + secret: + secretName: {{ .Release.Name }}-identity-cert + - name: dataprotection + persistentVolumeClaim: + claimName: {{ template "bitwarden.dataprotection" . }} + - name: licenses + persistentVolumeClaim: + claimName: {{ template "bitwarden.licenses" . }} + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "bitwarden.identity" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: identity +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.identity.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + selector: + app: {{ template "bitwarden.identity" . }} + ports: + - port: 5000 + targetPort: 5000 diff --git a/charts/self-host/templates/ingress.yaml b/charts/self-host/templates/ingress.yaml new file mode 100644 index 00000000..9d60b6e0 --- /dev/null +++ b/charts/self-host/templates/ingress.yaml @@ -0,0 +1,130 @@ +{{- if .Values.general.ingress.enabled }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ template "bitwarden.ingress" . }} + namespace: {{ .Release.Namespace }} + annotations: + {{- if .Values.general.ingress.tls.clusterIssuer }} + cert-manager.io/cluster-issuer: {{ .Values.general.ingress.tls.clusterIssuer }} + {{- end }} +{{- with .Values.general.ingress.annotations }} +{{ toYaml . | indent 4 }} +{{- end }} + labels: + app.kubernetes.io/component: ingress +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.general.ingress.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + ingressClassName: {{.Values.general.ingress.className}} + rules: + - host: {{ .Values.general.domain }} + http: + paths: + - path: {{ .Values.general.ingress.paths.web.path }} + {{ if .Values.general.ingress.paths.web.pathType }} + pathType: {{ .Values.general.ingress.paths.web.pathType }} + {{- end }} + backend: + service: + name: {{ template "bitwarden.web" . }} + port: + number: 5000 + + - path: {{ .Values.general.ingress.paths.attachments.path }} + {{ if .Values.general.ingress.paths.attachments.pathType }} + pathType: {{ .Values.general.ingress.paths.attachments.pathType }} + {{- end }} + backend: + service: + name: {{ template "bitwarden.attachments" . }} + port: + number: 5000 + + + - path: {{ .Values.general.ingress.paths.api.path }} + {{ if .Values.general.ingress.paths.api.pathType }} + pathType: {{ .Values.general.ingress.paths.api.pathType }} + {{- end }} + backend: + service: + name: {{ template "bitwarden.api" . }} + port: + number: 5000 + + + - path: {{ .Values.general.ingress.paths.icons.path }} + {{ if .Values.general.ingress.paths.icons.pathType }} + pathType: {{ .Values.general.ingress.paths.icons.pathType }} + {{- end }} + backend: + service: + name: {{ template "bitwarden.icons" . }} + port: + number: 5000 + + + - path: {{ .Values.general.ingress.paths.notifications.path }} + {{ if .Values.general.ingress.paths.notifications.pathType }} + pathType: {{ .Values.general.ingress.paths.notifications.pathType }} + {{- end }} + backend: + service: + name: {{ template "bitwarden.notifications" . }} + port: + number: 5000 + + + - path: {{ .Values.general.ingress.paths.events.path }} + {{ if .Values.general.ingress.paths.events.pathType }} + pathType: {{ .Values.general.ingress.paths.events.pathType }} + {{- end }} + backend: + service: + name: {{ template "bitwarden.events" . }} + port: + number: 5000 + + + - path: {{ .Values.general.ingress.paths.sso.path }} + {{ if .Values.general.ingress.paths.sso.pathType }} + pathType: {{ .Values.general.ingress.paths.sso.pathType }} + {{- end }} + backend: + service: + name: {{ template "bitwarden.sso" . }} + port: + number: 5000 + + + - path: {{ .Values.general.ingress.paths.identity.path }} + {{ if .Values.general.ingress.paths.identity.pathType }} + pathType: {{ .Values.general.ingress.paths.identity.pathType }} + {{- end }} + backend: + service: + name: {{ template "bitwarden.identity" . }} + port: + number: 5000 + + + - path: {{ .Values.general.ingress.paths.admin.path }} + {{ if .Values.general.ingress.paths.admin.pathType }} + pathType: {{ .Values.general.ingress.paths.admin.pathType }} + {{- end }} + backend: + service: + name: {{ template "bitwarden.admin" . }} + port: + number: 5000 + + tls: + - hosts: + - {{ .Values.general.domain }} + {{- if .Values.general.ingress.tls.name }} + secretName: {{ .Values.general.ingress.tls.name }} + {{- end }} +{{- end }} diff --git a/charts/self-host/templates/mssql.yaml b/charts/self-host/templates/mssql.yaml new file mode 100644 index 00000000..4c88105a --- /dev/null +++ b/charts/self-host/templates/mssql.yaml @@ -0,0 +1,124 @@ +{{- if .Values.database.enabled }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.mssql" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "bitwarden.mssql" . }} + app.kubernetes.io/component: mssql +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.database.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.mssql" . }} + template: + metadata: + labels: + app: {{ template "bitwarden.mssql" . }} + app.kubernetes.io/component: mssql +{{ include "bitwarden.labels" . | indent 8 }} +{{- with .Values.database.labels }} +{{ toYaml . | indent 8 }} +{{- end }} + spec: + {{- if .Values.database.podServiceAccount }} + serviceAccount: "{{ .Values.database.podServiceAccount }}" + serviceAccountName: "{{ .Values.database.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.mssql" . }} + image: "{{ .Values.database.image.name }}:{{ .Values.database.image.tag }}" + imagePullPolicy: Always + resources: +{{ toYaml .Values.database.resources | indent 12 }} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + ports: + - name: mssql + containerPort: 1433 + volumeMounts: + - name: mssql-data + mountPath: /var/opt/mssql/data + - name: mssql-log + mountPath: /var/opt/mssql/log + - name: mssql-backups + mountPath: /etc/bitwarden/mssql/backups + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + livenessProbe: + tcpSocket: + port: mssql + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 5 + readinessProbe: + tcpSocket: + port: mssql + initialDelaySeconds: 5 + periodSeconds: 2 + timeoutSeconds: 1 + startupProbe: + exec: + command: + - '/bin/sh' + - '-c' + - '/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -Q "SELECT 1" || exit 1' + initialDelaySeconds: 120 + periodSeconds: 10 + timeoutSeconds: 3 + securityContext: +{{ toYaml .Values.database.securityContext | indent 12 }} + enableServiceLinks: false + volumes: + - name: mssql-data + persistentVolumeClaim: + claimName: {{ template "bitwarden.mssqlData" . }} + - name: mssql-log + persistentVolumeClaim: + claimName: {{ template "bitwarden.mssqlLog" . }} + - name: mssql-backups + persistentVolumeClaim: + claimName: {{ template "bitwarden.mssqlBackups" . }} + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +kind: Service +apiVersion: v1 +metadata: + name: {{ template "bitwarden.mssql" . }} + labels: + app.kubernetes.io/component: mssql +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.database.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + type: ClusterIP + ports: + - name: http-port + port: 1433 + targetPort: 1433 + selector: + app: {{ template "bitwarden.mssql" . }} +{{- end }} diff --git a/charts/self-host/templates/notifications.yaml b/charts/self-host/templates/notifications.yaml new file mode 100644 index 00000000..feca93ed --- /dev/null +++ b/charts/self-host/templates/notifications.yaml @@ -0,0 +1,89 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.notifications" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "bitwarden.notifications" . }} + app.kubernetes.io/component: notifications +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.notifications.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.notifications" . }} + template: + metadata: + labels: + app: {{ template "bitwarden.notifications" . }} + app.kubernetes.io/component: notifications +{{ include "bitwarden.labels" . | indent 8 }} + spec: + {{- if .Values.component.notifications.podServiceAccount }} + serviceAccount: "{{ .Values.component.notifications.podServiceAccount }}" + serviceAccountName: "{{ .Values.component.notifications.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.notifications" . }} + image: "{{ .Values.component.notifications.image.name }}:{{ template "bitwarden.coreVersion" }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + {{- if .Values.database.enabled }} + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + {{- end }} + env: + - name: ASPNETCORE_URLS + value: http://+:5000 + livenessProbe: + httpGet: + path: /alive + port: 5000 + initialDelaySeconds: 180 + ports: + - containerPort: 5000 + resources: +{{ toYaml .Values.component.notifications.resources | indent 10 }} + volumeMounts: + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + securityContext: +{{ toYaml .Values.component.notifications.securityContext | indent 10 }} + volumes: + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "bitwarden.notifications" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: notifications +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.notifications.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + selector: + app: {{ template "bitwarden.notifications" . }} + ports: + - port: 5000 + targetPort: 5000 diff --git a/charts/self-host/templates/post-delete-hook.yaml b/charts/self-host/templates/post-delete-hook.yaml new file mode 100644 index 00000000..05d80185 --- /dev/null +++ b/charts/self-host/templates/post-delete-hook.yaml @@ -0,0 +1,40 @@ +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ .Release.Name }}-cleanup" + labels: + app.kubernetes.io/component: post-delete-hook + annotations: + "helm.sh/hook": post-delete + "helm.sh/hook-weight": "0" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: "{{ .Release.Name }}-cleanup" + labels: + app.kubernetes.io/component: post-delete-hook + spec: + {{- if .Values.serviceAccount }} + serviceAccountName: "{{ .Values.serviceAccount }}" + {{- end }} + containers: + - name: delete-resources + command: [ + "/bin/sh", "-c" + ] + args: [' + kubectl delete configmap {{ .Release.Name }}-config-map -n {{ .Release.Namespace }}; + kubectl delete configmap {{ .Release.Name }}-config-map-web -n {{ .Release.Namespace }}; + {{- if .Values.database.enabled }} + kubectl delete secret "{{ .Release.Name }}-sql-connection-string" -n {{ .Release.Namespace }}; + {{- end }} + kubectl delete secret {{ .Release.Name }}-identity-cert -n {{ .Release.Namespace }}; + kubectl delete secret {{ .Release.Name }}-identity-cert-password -n {{ .Release.Namespace }}; + kubectl delete job {{ .Release.Name }}-setup; + kubectl delete job {{ .Release.Name }}-migrator; + echo "Done" + '] + image: "bitnami/kubectl:1.21" + restartPolicy: Never diff --git a/charts/self-host/templates/post-install-db-migrator-job.yaml b/charts/self-host/templates/post-install-db-migrator-job.yaml new file mode 100644 index 00000000..d1b47ce6 --- /dev/null +++ b/charts/self-host/templates/post-install-db-migrator-job.yaml @@ -0,0 +1,87 @@ +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ .Release.Name }}-migrator" + labels: + app.kubernetes.io/component: post-install-db-migrator-job + annotations: + "helm.sh/hook": post-install,post-upgrade + "helm.sh/hook-weight": "0" + "helm.sh/hook-delete-policy": hook-succeeded,hook-failed +spec: + template: + metadata: + name: "{{ .Release.Name }}-migrator" + labels: + app.kubernetes.io/component: post-install-db-migrator-job + spec: + {{- if .Values.serviceAccount }} + serviceAccountName: "{{ .Values.serviceAccount }}" + {{- end }} + initContainers: + - name: wait-for-db + command: + - "/bin/bash" + - "-c" + {{- if .Values.database.enabled }} + args: [' + while [[ $(kubectl get pods -n {{ .Release.Namespace }} -l app={{ template "bitwarden.mssql" . }} -o jsonpath="{.items[*].status.containerStatuses[*].ready}") != "true" ]]; do sleep 1; done + + echo "SQL Ready!" + + while [[ $(kubectl get pods -n {{ .Release.Namespace }} -l app={{ template "bitwarden.admin" . }} -o jsonpath="{.items[*].status.containerStatuses[*].ready}") != "true" ]]; do sleep 1; done + + echo "Admin Ready!" + + while [ ! -f /db/vault.mdf ]; do sleep 1; done + + echo "DB Ready!" + '] + {{- else }} + args: [' + while [[ $(kubectl get pods -n {{ .Release.Namespace }} -l app={{ template "bitwarden.admin" . }} -o jsonpath="{.items[*].status.containerStatuses[*].ready}") != "true" ]]; do sleep 1; done + + echo "Admin Ready!" + '] + {{- end }} + image: "bitnami/kubectl:1.19" + volumeMounts: + {{- if .Values.database.enabled }} + - name: mssql-data + mountPath: /db + {{- end }} + containers: + - name: migrate-db + env: + - name: MSSQL_CONN_STRING + valueFrom: + secretKeyRef: + {{- if .Values.database.enabled }} + name: {{ .Release.Name }}-sql-connection-string + {{- else }} + name: "{{ .Values.secrets.secretName }}" + {{- end }} + key: globalSettings__sqlServer__connectionString + image: "bitwarden/mssqlmigratorutility:{{ template "bitwarden.coreVersion" }}" + volumeMounts: + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + restartPolicy: Never + volumes: + {{- if .Values.database.enabled }} + - name: mssql-data + persistentVolumeClaim: + claimName: {{ template "bitwarden.mssqlData" . }} + {{- end }} + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} diff --git a/charts/self-host/templates/post-install-raw-manifests.yaml b/charts/self-host/templates/post-install-raw-manifests.yaml new file mode 100644 index 00000000..bb496ba4 --- /dev/null +++ b/charts/self-host/templates/post-install-raw-manifests.yaml @@ -0,0 +1,6 @@ +{{- range .Values.rawManifests.postInstall }} +{{- $manifest := include "bitwarden.labels" $ | fromYaml | dict "labels" | dict "metadata" | mergeOverwrite . }} +{{- $manifest := include "bitwarden.rawPostInstallAnnotations" $ | fromYaml | dict "annotations" | mergeOverwrite $manifest }} +{{- toYaml $manifest }} +--- +{{- end }} diff --git a/charts/self-host/templates/pre-install-hook-configmap.yaml b/charts/self-host/templates/pre-install-hook-configmap.yaml new file mode 100644 index 00000000..212265b7 --- /dev/null +++ b/charts/self-host/templates/pre-install-hook-configmap.yaml @@ -0,0 +1,83 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-config-map + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "1" +data: + ACCEPT_EULA: "Y" + MSSQL_PID: "Express" + ASPNETCORE_ENVIRONMENT: "Production" + globalSettings__selfHosted: "true" + globalSettings__baseServiceUri__vault: "https://{{ .Values.general.domain }}" + globalSettings__baseServiceUri__api: "https://{{ .Values.general.domain }}/api" + globalSettings__baseServiceUri__identity: "https://{{ .Values.general.domain }}/identity" + globalSettings__baseServiceUri__admin: "https://{{ .Values.general.domain }}/admin" + globalSettings__baseServiceUri__notifications: "https://{{ .Values.general.domain }}/notifications" + globalSettings__baseServiceUri__sso: "https://{{ .Values.general.domain }}/sso" + globalSettings__baseServiceUri__internalNotifications: "http://{{ template "bitwarden.notifications" . }}:5000" + globalSettings__baseServiceUri__internalAdmin: "http://{{ template "bitwarden.admin" . }}:5000" + globalSettings__baseServiceUri__internalIdentity: "http://{{ template "bitwarden.identity" . }}:5000" + globalSettings__baseServiceUri__internalApi: "http://{{ template "bitwarden.api" . }}:5000" + globalSettings__baseServiceUri__internalVault: "http://{{ template "bitwarden.web" . }}:5000" + globalSettings__baseServiceUri__internalsso: "http://{{ template "bitwarden.sso" . }}:5000" + globalSettings__pushRelayBaseUri: "https://push.bitwarden.com" + globalSettings__attachment__baseDirectory: "/etc/bitwarden/core/attachments" + globalSettings__attachment__baseUrl: "https://{{ .Values.general.domain }}/attachments" + globalSettings__send__baseDirectory: "/etc/bitwarden/core/attachments/sendfiles" + globalSettings__send__baseUrl: "https://{{ .Values.general.domain }}/attachments/sendfiles" + globalSettings__mail__replyToEmail: "{{ .Values.general.email.replyToEmail }}" + globalSettings__mail__smtp__host: "{{ .Values.general.email.smtpHost }}" + globalSettings__mail__smtp__port: "{{ .Values.general.email.smtpPort }}" + globalSettings__mail__smtp__ssl: "{{ .Values.general.email.smtpSsl }}" + +{{- $currentGeneratedConfigMap := (lookup "v1" "ConfigMap" .Release.Namespace "{{ .Release.Name }}-config-map") }} +{{- if $currentGeneratedConfigMap}} + globalSettings__internalIdentityKey: {{ index $currentGeneratedConfigMap.data "globalSettings__internalIdentityKey"}} + globalSettings__oidcIdentityClientKey: {{ index $currentGeneratedConfigMap.data "globalSettings__oidcIdentityClientKey"}} + globalSettings__duo__aKey: {{ index $currentGeneratedConfigMap.data "globalSettings__oidcIdentityClientKey"}} +{{- else}} + globalSettings__internalIdentityKey: {{ (randAlphaNum 64) | quote }} + globalSettings__oidcIdentityClientKey: {{ (randAlphaNum 64) | quote }} + globalSettings__duo__aKey: {{ (randAlphaNum 64) | quote }} +{{- end }} + globalSettings__logDirectory: "/dev/null" + globalSettings__logRollBySizeLimit: "" + globalSettings__syslog__destination: "" + globalSettings__dataProtection__directory: "/etc/bitwarden/core/aspnet-dataprotection" + globalSettings__licenseDirectory: "/etc/bitwarden/core/licenses" + globalSettings__disableUserRegistration: {{ .Values.general.disableUserRegistration | quote }} + globalSettings__hibpApiKey: {{ .Values.general.hibpApiKey | quote }} + adminSettings__admins: {{ .Values.general.admins | quote }} + LOCAL_UID: "1000" + LOCAL_GID: "1000" + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-config-map-web + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-weight": "1" +data: + app-id.json: |- + { + "trustedFacets": [ + { + "version": { + "major": 1, + "minor": 0 + }, + "ids": [ + "https://{{ .Values.general.domain }}", + "ios:bundle-id:com.8bit.bitwarden", + "android:apk-key-hash:dUGFzUzf3lmHSLBDBIv+WaFyZMI" + ] + } + ] + } diff --git a/charts/self-host/templates/pre-install-job.yaml b/charts/self-host/templates/pre-install-job.yaml new file mode 100644 index 00000000..dcda8123 --- /dev/null +++ b/charts/self-host/templates/pre-install-job.yaml @@ -0,0 +1,69 @@ +{{- $identityCertPasswordTxtValue := (randAlpha 32) }} +{{- $currentIdentityCert := (lookup "v1" "Secret" "{.Release.Namespace}" "{{ .Release.Name }}-identity-cert") }} +{{- $identityCertPasswordTxtValue := (lookup "v1" "Secret" .Release.Namespace "{{ .Release.Name }}-identity-cert-password") }} + +{{- if $currentIdentityCert }} +{{- $identityCertPasswordTxtValue := index $currentIdentityCert.data "globalSettings__identityServer__certificatePassword" | b64dec }} +{{- end }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ .Release.Name }}-setup" + labels: + app.kubernetes.io/component: pre-install-hook + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-weight": "2" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: "{{ .Release.Name }}-setup" + labels: + app.kubernetes.io/component: pre-install-hook + spec: + {{- if .Values.serviceAccount }} + serviceAccountName: "{{ .Values.serviceAccount }}" + {{- end }} + +{{- if not $currentIdentityCert }} + initContainers: + - name: generate-identity-cert + command: + - "/bin/sh" + - "-c" + args: [' + openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout /bitwarden/identity.key -out /bitwarden/identity.crt -subj "/CN=Bitwarden IdentityServer" -days 36500; + openssl pkcs12 -export -out /bitwarden/identity.pfx -inkey /bitwarden/identity.key -in /bitwarden/identity.crt -passout pass:{{ $identityCertPasswordTxtValue }}; + chmod 777 /bitwarden/identity.pfx; + echo Done; + '] + image: "docker.io/nginx" + volumeMounts: + - name: temp + mountPath: "/bitwarden" +{{- end }} + containers: + - name: create-resources + command: + - "/bin/sh" + - "-c" + args: [' + ls -atlh /bitwarden; +{{- if not $currentIdentityCert }} + kubectl create secret generic {{ .Release.Name }}-identity-cert --from-file=/bitwarden/identity.pfx -n {{ .Release.Namespace }} ; + kubectl create secret generic {{ .Release.Name }}-identity-cert-password -n {{ .Release.Namespace }} + --from-literal=globalSettings__identityServer__certificatePassword={{ $identityCertPasswordTxtValue | quote }}; +{{- end }} + echo "Done" + '] + image: "bitnami/kubectl:1.21" + volumeMounts: + - name: temp + mountPath: "/bitwarden" + restartPolicy: Never + volumes: + - name: temp + emptyDir: + medium: Memory diff --git a/charts/self-host/templates/pre-install-raw-manifests.yaml b/charts/self-host/templates/pre-install-raw-manifests.yaml new file mode 100644 index 00000000..d6fda199 --- /dev/null +++ b/charts/self-host/templates/pre-install-raw-manifests.yaml @@ -0,0 +1,6 @@ +{{- range .Values.rawManifests.preInstall }} +{{- $manifest := include "bitwarden.labels" $ | fromYaml | dict "labels" | dict "metadata" | mergeOverwrite . }} +{{- $manifest := include "bitwarden.rawPreInstallAnnotations" $ | fromYaml | dict "annotations" | mergeOverwrite $manifest }} +{{- toYaml $manifest }} +--- +{{- end }} diff --git a/charts/self-host/templates/pre-install-secret-sql.yaml b/charts/self-host/templates/pre-install-secret-sql.yaml new file mode 100644 index 00000000..88322594 --- /dev/null +++ b/charts/self-host/templates/pre-install-secret-sql.yaml @@ -0,0 +1,61 @@ +{{- if .Values.database.enabled }} +{{- $dbServiceName := include "bitwarden.mssql" . }} + +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ .Release.Name }}-secret-sql" + labels: + app.kubernetes.io/component: pre-install-hook + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-weight": "3" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: "{{ .Release.Name }}-secret-sql" + labels: + app.kubernetes.io/component: pre-install-hook + spec: + {{- if .Values.serviceAccount }} + serviceAccountName: "{{ .Values.serviceAccount }}" + {{- end }} + containers: + - name: create-resources + command: + - "/bin/sh" + - "-c" + args: [' + kubectl create secret generic {{ .Release.Name }}-sql-connection-string -n {{ .Release.Namespace }} + --from-literal=globalSettings__sqlServer__connectionString="Data Source=tcp:{{ $dbServiceName }},1433;Initial Catalog=vault;Persist Security Info=False;User ID=sa;Password=$SA_PASSWORD;MultipleActiveResultSets=False;Connect Timeout=30;Encrypt=True;TrustServerCertificate=True" + + echo "Done" + '] + image: "bitnami/kubectl:1.21" + envFrom: + - secretRef: + name: "{{ .Values.secrets.secretName }}" + volumeMounts: + - name: temp + mountPath: "/bitwarden" + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + restartPolicy: Never + volumes: + - name: temp + emptyDir: + medium: Memory + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} +{{- end }} diff --git a/charts/self-host/templates/pre-install-service-acc.yaml b/charts/self-host/templates/pre-install-service-acc.yaml new file mode 100644 index 00000000..830cfa1f --- /dev/null +++ b/charts/self-host/templates/pre-install-service-acc.yaml @@ -0,0 +1,73 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.serviceAccount }} + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "0" + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: role:service-acc + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "0" +rules: # Authorization rules for this role + - apiGroups: [""] + resources: ["secrets"] + verbs: ["create","update","patch","delete"] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: role:service-acc-pods + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "0" +rules: # Authorization rules for this role + - apiGroups: [""] + resources: ["pods"] + verbs: ["get","list","watch"] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: rolebinding:service-acc + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "0" +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: role:service-acc +subjects: + - kind: ServiceAccount + name: {{ .Values.serviceAccount }} + namespace: {{ .Release.Namespace }} + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: rolebinding:service-acc-pods + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install,pre-upgrade + "helm.sh/hook-weight": "0" +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: role:service-acc-pods +subjects: + - kind: ServiceAccount + name: {{ .Values.serviceAccount }} + namespace: {{ .Release.Namespace }} diff --git a/charts/self-host/templates/scim.yaml b/charts/self-host/templates/scim.yaml new file mode 100644 index 00000000..0325b8dc --- /dev/null +++ b/charts/self-host/templates/scim.yaml @@ -0,0 +1,105 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.scim" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "bitwarden.scim" . }} + app.kubernetes.io/component: scim +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.scim.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.scim" . }} + template: + metadata: + labels: + app: {{ template "bitwarden.scim" . }} + app.kubernetes.io/component: scim +{{ include "bitwarden.labels" . | indent 8 }} + spec: + {{- if .Values.component.scim.podServiceAccount }} + serviceAccount: "{{ .Values.component.scim.podServiceAccount }}" + serviceAccountName: "{{ .Values.component.scim.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.scim" . }} + image: "{{ .Values.component.scim.image.name }}:{{ template "bitwarden.coreVersion" }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + {{- if .Values.database.enabled }} + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + {{- end }} + env: + - name: ASPNETCORE_URLS + value: http://+:5000 + livenessProbe: + httpGet: + path: /alive + port: 5000 + initialDelaySeconds: 180 + ports: + - containerPort: 5000 + resources: + resources: +{{ toYaml .Values.component.scim.resources | indent 10 }} + volumeMounts: + - name: attachments + mountPath: /etc/bitwarden/core/attachments + - name: dataprotection + mountPath: /etc/bitwarden/core/aspnet-dataprotection + - name: licenses + mountPath: /etc/bitwarden/core/licenses + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + securityContext: +{{ toYaml .Values.component.scim.securityContext | indent 10 }} + volumes: + - name: dataprotection + persistentVolumeClaim: + claimName: {{ template "bitwarden.dataprotection" . }} + - name: attachments + persistentVolumeClaim: + claimName: {{ template "bitwarden.attachments" . }} + - name: licenses + persistentVolumeClaim: + claimName: {{ template "bitwarden.licenses" . }} + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "bitwarden.scim" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: scim +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.scim.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + selector: + app: {{ template "bitwarden.scim" . }} + ports: + - port: 5000 + targetPort: 5000 diff --git a/charts/self-host/templates/sso.yaml b/charts/self-host/templates/sso.yaml new file mode 100644 index 00000000..8344392e --- /dev/null +++ b/charts/self-host/templates/sso.yaml @@ -0,0 +1,106 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.sso" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "bitwarden.sso" . }} + app.kubernetes.io/component: sso +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.sso.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.sso" . }} + template: + metadata: + labels: + app: {{ template "bitwarden.sso" . }} + app.kubernetes.io/component: sso +{{ include "bitwarden.labels" . | indent 8 }} + spec: + {{- if .Values.component.sso.podServiceAccount }} + serviceAccount: "{{ .Values.component.sso.podServiceAccount }}" + serviceAccountName: "{{ .Values.component.sso.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.sso" . }} + image: "{{ .Values.component.sso.image.name }}:{{ template "bitwarden.coreVersion" }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + - secretRef: + name: {{ .Release.Name }}-identity-cert-password + {{- if .Values.database.enabled }} + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + {{- end }} + env: + - name: ASPNETCORE_URLS + value: http://+:5000 + livenessProbe: + httpGet: + path: /alive + port: 5000 + initialDelaySeconds: 180 + ports: + - containerPort: 5000 + resources: +{{ toYaml .Values.component.sso.resources | indent 10 }} + volumeMounts: + - name: identity + mountPath: /etc/bitwarden/identity + - name: dataprotection + mountPath: /etc/bitwarden/core/aspnet-dataprotection + - name: licenses + mountPath: /etc/bitwarden/core/licenses + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + securityContext: +{{ toYaml .Values.component.sso.securityContext | indent 10 }} + volumes: + - name: identity + secret: + secretName: {{ .Release.Name }}-identity-cert + - name: dataprotection + persistentVolumeClaim: + claimName: {{ template "bitwarden.dataprotection" . }} + - name: licenses + persistentVolumeClaim: + claimName: {{ template "bitwarden.licenses" . }} + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "bitwarden.sso" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: sso +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.sso.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + selector: + app: {{ template "bitwarden.sso" . }} + ports: + - port: 5000 + targetPort: 5000 diff --git a/charts/self-host/templates/volumes.yaml b/charts/self-host/templates/volumes.yaml new file mode 100644 index 00000000..3c37d8d6 --- /dev/null +++ b/charts/self-host/templates/volumes.yaml @@ -0,0 +1,119 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: {{ .Release.Namespace }} + name: {{ template "bitwarden.dataprotection" . }} +spec: + accessModes: + - ReadWriteMany + storageClassName: {{ .Values.sharedStorageClassName }} + resources: + requests: + storage: {{ .Values.volume.dataprotection.size }} + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: {{ .Release.Namespace }} + name: {{ template "bitwarden.licenses" . }} + labels: + app.kubernetes.io/component: licenses +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.volume.licenses.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + accessModes: + - ReadWriteMany + storageClassName: {{ .Values.sharedStorageClassName }} + resources: + requests: + storage: {{ .Values.volume.licenses.size }} + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: {{ .Release.Namespace }} + name: {{ template "bitwarden.attachments" . }} + labels: + app.kubernetes.io/component: attachments +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.volume.attachments.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + accessModes: + - ReadWriteMany + storageClassName: {{ .Values.sharedStorageClassName }} + resources: + requests: + storage: {{ .Values.volume.attachments.size }} + +################# +# MSSQL Volumes # +################# +{{- if .Values.database.enabled }} + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: {{ .Release.Namespace }} + name: {{ template "bitwarden.mssqlLog" . }} + labels: + app.kubernetes.io/component: mssql-log +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.database.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + accessModes: + - ReadWriteMany + storageClassName: {{ .Values.sharedStorageClassName }} + resources: + requests: + storage: {{ .Values.database.volume.log.size }} + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: {{ .Release.Namespace }} + name: {{ template "bitwarden.mssqlBackups" . }} + labels: + app.kubernetes.io/component: mssql-backups +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.database.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + accessModes: + - ReadWriteMany + storageClassName: {{ .Values.sharedStorageClassName }} + resources: + requests: + storage: {{ .Values.database.volume.backups.size }} + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: {{ .Release.Namespace }} + name: {{ template "bitwarden.mssqlData" . }} + labels: + app.kubernetes.io/component: mssql-data +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.database.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + accessModes: + - ReadWriteMany + storageClassName: {{ .Values.sharedStorageClassName }} + resources: + requests: + storage: {{ .Values.database.volume.data.size }} +{{- end }} diff --git a/charts/self-host/templates/web.yaml b/charts/self-host/templates/web.yaml new file mode 100644 index 00000000..0d04b452 --- /dev/null +++ b/charts/self-host/templates/web.yaml @@ -0,0 +1,94 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "bitwarden.web" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "bitwarden.web" . }} + app.kubernetes.io/component: web +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.web.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "bitwarden.web" . }} + template: + metadata: + labels: + app: {{ template "bitwarden.web" . }} + app.kubernetes.io/component: web +{{ include "bitwarden.labels" . | indent 8 }} + spec: + {{- if .Values.component.web.podServiceAccount }} + serviceAccount: "{{ .Values.component.web.podServiceAccount }}" + serviceAccountName: "{{ .Values.component.web.podServiceAccount }}" + {{- end }} + containers: + - name: {{ template "bitwarden.web" . }} + image: "{{ .Values.component.web.image.name }}:{{ template "bitwarden.webVersion" }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-config-map + - secretRef: + name: "{{ .Values.secrets.secretName }}" + {{- if .Values.database.enabled }} + - secretRef: + name: {{ .Release.Name }}-sql-connection-string + {{- end }} + env: + - name: ASPNETCORE_URLS + value: http://+:5000 + livenessProbe: + httpGet: + path: / + port: 5000 + initialDelaySeconds: 180 + ports: + - containerPort: 5000 + resources: +{{ toYaml .Values.component.web.resources | indent 10 }} + volumeMounts: + - name: web + mountPath: /etc/bitwarden/web + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + mountPath: "/mnt/secrets-store" + readOnly: true + {{- end }} + securityContext: +{{ toYaml .Values.component.web.securityContext | indent 10 }} + volumes: + - name: web + configMap: + name: {{ .Release.Name }}-config-map-web + {{- if .Values.secrets.secretProviderClass}} + - name: secrets-store-inline + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secrets.secretProviderClass }} + {{- end }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "bitwarden.web" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/component: web +{{ include "bitwarden.labels" . | indent 4 }} +{{- with .Values.component.web.labels }} +{{ toYaml . | indent 4 }} +{{- end }} +spec: + selector: + app: {{ template "bitwarden.web" . }} + ports: + - port: 5000 + targetPort: 5000 diff --git a/charts/self-host/values.yaml b/charts/self-host/values.yaml new file mode 100644 index 00000000..e8223117 --- /dev/null +++ b/charts/self-host/values.yaml @@ -0,0 +1,298 @@ +# Optional +fullnameOverride: "" +nameOverride: "" + +general: + # Domain name for the service + domain: "REPLACE" + ingress: + # Set to false if using a custom ingress + enabled: true + # Current supported values for ingress type include: nginx + className: "nginx" + ## - Annotations to add to the Ingress resource + annotations: + # nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + # nginx.ingress.kubernetes.io/use-regex: "true" + # nginx.ingress.kubernetes.io/proxy-read-timeout: "300" + # nginx.ingress.kubernetes.io/rewrite-target: /$1 + ## - Labels to add to the Ingress resource + labels: {} + # Certificate options + tls: + # TLS certificate secret name + name: + # Cluster cert issuer (ex. Let's Encrypt) name if one exists + clusterIssuer: + paths: + web: + path: /(.*) + pathType: Prefix + attachments: + path: /attachments[/|$](.*) + pathType: Prefix + api: + path: /api[/|$](.*) + pathType: Prefix + icons: + path: /icons[/|$](.*) + pathType: Prefix + notifications: + path: /notifications[/|$](.*) + pathType: Prefix + events: + path: /events[/|$](.*) + pathType: Prefix + sso: + path: /sso[/|$](.*) + pathType: Prefix + identity: + path: /identity[/|$](.*) + pathType: Prefix + admin: + path: /(admin[/|$]?.*) + pathType: Prefix + + # Override application container version tags. Theses will be versioned with the chart and need not be changed in most circumstances. + coreVersionOverride: "" + webVersionOverride: "" + disableUserRegistration: "false" + hibpApiKey: "false" + admins: "false" + email: + # Email address used for invitations, typically no-reply@smtp-host + replyToEmail: "no-reply@bitwarden.localhost" + # Your SMTP server hostname (recommended) or IP address + smtpHost: "smtp.gmail.com" + # The SMTP port used by the SMTP server + smtpPort: "587" + # Whether your SMTP server uses an encryption protocol, "true" for SSL, "false" for TLS + smtpSsl: "false" + labels: {} + +# Specify the name of the shared storage class +# This storage class requires ReadWriteMany. You will need to provide your own storage class. Storage classes with automatic volume previsioners are recommended. +sharedStorageClassName: "shared-storage" + +secrets: + secretName: custom-secret + secretProviderClass: + +component: + # The Admin component + admin: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/admin + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: + api: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/api + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: + attachments: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/attachments + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: + events: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/events + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: + icons: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/icons + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: + identity: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/identity + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: + notifications: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/notifications + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: + scim: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/scim + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: + sso: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/sso + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: + web: + # Additional deployment labels + labels: {} + # Image name, tag, and pull policy + image: + name: bitwarden/web + resources: + requests: + memory: "64Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: +volume: + dataprotection: + size: "1Gi" + labels: {} + attachments: + size: 1Gi + labels: {} + licenses: + size: 1Gi + labels: {} + +# +# Configure service account for pre- and post-install hooks +# +serviceAccount: service-account + +# +# Configure database +# +database: + # deploy the database pod? if false, a connection string to a SQL Server will need to be provided through one of the configuration providers. + enabled: true + # Labels to add to the MSSQL deployment + labels: {} + # Image name, tag, and pull policy + image: + name: mcr.microsoft.com/mssql/server + # Tag of the image to use. (Defaults to general.coreVersion) + tag: 2019-CU17-ubuntu-20.04 + # The containers are limited to the resources below + resources: + requests: + memory: "2G" + cpu: "100m" + limits: + memory: "2G" + cpu: "500m" + + # The MSSQL volumes + volume: + backups: + # Storage size + size: 1Gi + data: + # Storage size + size: 10Gi + log: + # Storage size + size: 10Gi + securityContext: + # Run the pod under a service account you create. This is especially useful for OpenShift deployments + podServiceAccount: + +rawManifests: + preInstall: [] + postInstall: [] diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..203efa66 --- /dev/null +++ b/renovate.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base", + "helpers:pinGitHubActionDigests" + ], + "schedule": ["after 10pm and before 5am every weekday", "every weekend"] +}