A Kubernetes Operator that uses Bitwarden to provision secrets, written in Rust with kube-rs

Overview

bitwarden-secret-operator-rs

bitwarden-secret-operator-rs is a kubernetes Operator written in Rust thanks to kube-rs.

The goal is to create Kubernetes Secret objects while using Bitwarden as the source of truth for your secret values.

It currently is used in production by OlympusGG, for our GitOps powered cluster management.

bitwarden secret operator logo

DISCLAIMER:
This project wraps the BitWarden CLI as we didn't want to rewrite a client for BitWarden and BitWarden does not offer easy to use public client libraries

If you need multi-line (SSH key, Certificate...) like we did, use secure note until BitWarden implements Multiline support

Features

TODOs

  • Unit testing (partially implemented)
  • More metrics/observability

Getting started

You will need a ClientID and ClientSecret (where to get these) as well as your password. Expose these to the operator as described in this example:

env:
- name: BW_HOST
  value: "https://vaultwarden.yourdomain.ai"
- name: BW_CLIENTID
  value: "user.your-client-id"
- name: BW_CLIENTSECRET
  value: "yourClientSecret"
- name: BW_PASSWORD
  value: "YourSuperSecurePassword"
- name: SECRET_REFRESH_RATE # optional, by default it's 15 seconds, this value is to define how frequently `bw sync` is called
  value: "00:00:30" # TimeSpan (hh:mm:ss)
- name: OPENTELEMETRY_ENDPOINT_URL
  value: "otel-collector.namespace.svc.cluster.local"
- name: METRICS_ENDPOINT
  value: "127.0.0.1:3001"

the helm template will use all environment variables from this secret, so make sure to prepare this secret with the key value pairs as described above.

BW_HOST can be omitted if you are using the Bitwarden SaaS offering.

After that it is a basic helm deployment:

helm repo add bitwarden-operator https://blowaxd.github.io/bitwarden-secret-operator-rs
helm repo update 
kubectl create namespace bw-operator
helm upgrade --install --namespace bw-operator -f values.yaml bw-operator bitwarden-operator/bitwarden-secret-operator-rs

BitwardenSecret

And you are set to create your first secret using this operator. For that you need to add a CRD Object like this to your cluster:

---
apiVersion: bitwarden-secret-operator-rs.io/v1beta1
kind: BitwardenSecret
metadata:
  name: my-secret-from-bitwarden
spec:
  name: "my-secret-from-spec" # optional, will use the same name as CRD if not specified
  namespace: "my-namespace" # optional, will use the same namespace as CRD if not specified
  labels: # optional set of labels
    here-my-label-1: test
  type: "kubernetes.io/tls" # optional, will use `Opaque` by default
  bitwardenId: 00000000-0000-0000-0000-000000000000 # optional, this id applies to all elements without `bitwardenId` specified 
  content: # required, array of objects
  - bitwardenId: d4ff5941-53a4-4622-9385-2fcf910ae7e7 # optional, can be specified for a specific secret
    bitwardenSecretField: myBitwardenField # optional, mutually exclusive with `bitwardenSecretField` but acts as a second choice
    bitwardenUseNote: false # optional, mutually exclusive and prioritized over `bitwardenSecretField`
    kubernetesSecretKey: MY_KUBERNETES_SECRET_KEY # required
    kubernetesSecretValue: value # optional, alternative to stringData
  - bitwardenUseNote: true # boolean, exclusive and prioritized over `bitwardenSecretField`
    kubernetesSecretKey: MY_KUBERNETES_SECRET_KEY # required
  stringData: # optional, string data
    test: hello-world

Generating the CRD

Use this command to output the CRD if you need to modify it

cargo run --example crd

Credits/Thanks

You might also like...
The last kubernetes tool you'll ever need.

Neatkube The last kubernetes tool you'll ever need. Kubernetes is a mess. Everthing ships it's own command line tools that you need to install and tra

Kubernetes + wasmCloud
Kubernetes + wasmCloud

KasmCloud Managing and Running Actors, Providers, and Links in Kubernetes ⚠️ Warning This is a contributor-led experimental project and is not recomme

KFtray - A tray application that manages port forwarding in Kubernetes.
KFtray - A tray application that manages port forwarding in Kubernetes.

Ktray is written in Rust and React, with Tauri framework. The app simplifies the process of starting and stopping multiple port forwarding configurations through a user-friendly interface.

Rust macro that uses GPT3 codex to generate code at compiletime

gpt3_macro Rust macro that uses GPT3 codex to generate code at compiletime. Just describe what you want the function to do and (optionally) define a f

Like jq, but for HTML. Uses CSS selectors to extract bits content from HTML files.

Like jq, but for HTML. Uses CSS selectors to extract bits content from HTML files. Mozilla's MDN has a good reference for CSS selector syntax.

A lightning fast version of tmux-fingers written in Rust, copy/pasting tmux like vimium/vimperator
A lightning fast version of tmux-fingers written in Rust, copy/pasting tmux like vimium/vimperator

tmux-thumbs A lightning fast version of tmux-fingers written in Rust for copy pasting with vimium/vimperator like hints. Usage Press ( prefix + Space

A command-line tool collection to assist development written in RUST

dtool dtool is a command-line tool collection to assist development Table of Contents Description Usage Tips Installation Description Now dtool suppor

Simple ray tracer written in Rust
Simple ray tracer written in Rust

Simple ray tracer written in Rust from scratch I've just finished my first semester at the Faculty of Applied Mathematics and Computer Science at the

BSV stdlib written in Rust and runs in WASM environments

BSV.WASM A Rust/WASM Library to interact with Bitcoin SV Installation NodeJS: npm i bsv-wasm --save Web: npm i bsv-wasm-web --save Rust: https://crate

Comments
  • Bump mikefarah/yq from 4.35.1 to 4.43.1

    Bump mikefarah/yq from 4.35.1 to 4.43.1

    Bumps mikefarah/yq from 4.35.1 to 4.43.1.

    Release notes

    Sourced from mikefarah/yq's releases.

    v4.43.1

    • Added omit operator #1989 thanks @​mbenson!
    • Can now multiply strings by numbers #1988 thanks @​mbenson!
    • Added tostring #72
    • Added string interpolation #1149
    • Can specify parent(n) levels #1970
    • Fixed CSV line break issue #1974
    • Adding a EvaluateAll function to StringEvaluator #1966
    • yqlib, default to colors off when using yaml library #1964
    • Removed JSON output warning
    • Bumped dependencies

    v4.42.1

    • Can execute yq expression files directly with shebang #1851
    • Added --csv-separator flag #1950
    • Added --properties-separator option - thanks @​learnitall #1864
    • Added --properties-array-brackets flag for properties encoder #1933
    • Shell completion improvements - thanks @​scop #1911
    • Bumped dependencies

    v4.41.1

    • Can now comment in yq expressions! #1919
    • Added new CSV option to turn off auto-parsing #1947
    • Can now retrieve the alias names of merge anchors #1942
    • Fixed Toml decoding when table array defined before parent #1922
    • Fixing with_entries context #1925

    v4.40.7

    v4.40.5

    • Fixing seg fault on bad XML #1888
    • Fixed handling of --- #1890, #1896
    • Bumped dependencies

    v4.40.4 - Fixed bug with creating maps with values based off keys

    • Fixed bug with creating maps with values based off keys #1886, #1889
    • Bumped dependencies

    v4.40.3 - Fixes JSON empty array bug

    • Fixed JSON output issue with empty arrays #1880

    v4.40.2 - Official

    Thank you for all your support! I've fixed some of the issues that were kindly raised :) Happy to make the release official!

    ... (truncated)

    Changelog

    Sourced from mikefarah/yq's changelog.

    4.43.1:

    • Added omit operator #1989 thanks @​mbenson!
    • Added tostring #72
    • Added string interpolation #1149
    • Can specify parent(n) levels #1970
    • Can now multiply strings by numbers #1988 thanks @​mbenson!
    • Fixed CSV line break issue #1974
    • Adding a EvaluateAll function to StringEvaluator #1966
    • yqlib, default to colors off when using yaml library #1964
    • Removed JSON output warning
    • Bumped dependencies

    4.42.1:

    • Can execute yq expression files directly with shebang #1851
    • Added --csv-separator flag #1950
    • Added --properties-separator option - thanks @​learnitall #1864
    • Added --properties-array-brackets flag for properties encoder #1933
    • Shell completion improvements - thanks @​scop #1911
    • Bumped dependencies

    4.41.1:

    • Can now comment in yq expressions! #1919
    • Fixed Toml decoding when table array defined before parent #1922
    • Added new CSV option to turn off auto-parsing #1947
    • Fixing with_entries context #1925
    • Can now retrieve the alias names of merge anchors #1942

    4.40.7:

    • Bumped dependencies

    4.40.6:

    • Fix: empty TOML table #1924 - Thanks @​elibroftw
    • Fixed "all" error message #1845
    • Fixed to_entries[]
    • Bumped dependencies

    4.40.5:

    • Fixing seg fault on bad XML #1888
    • Fixed handling of --- #1890, #1896
    • Bumped dependencies

    4.40.4:

    • Fixed bug with creating maps with values based off keys #1886, #1889
    • Bumped dependencies

    4.40.3:

    • Fixed JSON output issue with empty arrays #1880

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 1
  • Bump sigstore/cosign-installer from 3.1.2 to 3.4.0

    Bump sigstore/cosign-installer from 3.1.2 to 3.4.0

    Bumps sigstore/cosign-installer from 3.1.2 to 3.4.0.

    Release notes

    Sourced from sigstore/cosign-installer's releases.

    v3.4.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/sigstore/cosign-installer/compare/v3...v3.4.0

    v3.3.0

    What's Changed

    Full Changelog: https://github.com/sigstore/cosign-installer/compare/v3.2.0...v3.3.0

    v3.2.0

    Note: This release comes with a fix for CVE-2023-46737 described in this Github Security Advisory. Please upgrade to this release ASAP

    see https://github.com/sigstore/cosign/releases/tag/v2.2.1

    What's Changed

    New Contributors

    Full Changelog: https://github.com/sigstore/cosign-installer/compare/v3...v3.2.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 1
  • Bump docker/setup-buildx-action from 3.2.0 to 3.3.0

    Bump docker/setup-buildx-action from 3.2.0 to 3.3.0

    Bumps docker/setup-buildx-action from 3.2.0 to 3.3.0.

    Release notes

    Sourced from docker/setup-buildx-action's releases.

    v3.3.0

    Full Changelog: https://github.com/docker/setup-buildx-action/compare/v3.2.0...v3.3.0

    Commits
    • d70bba7 Merge pull request #307 from crazy-max/bump-toolkit
    • 7638634 chore: update generated content
    • c68420f bump @​docker/actions-toolkit from 0.19.0 to 0.20.0
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 0
  • Bump sigstore/cosign-installer from 3.4.0 to 3.5.0

    Bump sigstore/cosign-installer from 3.4.0 to 3.5.0

    Bumps sigstore/cosign-installer from 3.4.0 to 3.5.0.

    Release notes

    Sourced from sigstore/cosign-installer's releases.

    v3.5.0

    What's Changed

    Full Changelog: https://github.com/sigstore/cosign-installer/compare/v3.4.0...v3.5.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 0
Releases(bitwarden-secret-operator-0.17.1)
Owner
Blowa
Software Engineer Discord : blowa
Blowa
Detects orphan configmaps and secrets in a Kubernetes cluster

KubExplorer Warning: Proof of concept. Feedback is much welcome. Discovers and prints out any Configmaps and Secrets not linked to any of the followin

Pavel Pscheidl 56 Oct 21, 2022
engula-operator creates/configures/manages engula clusters atop Kubernetes

Engula Operator The engula operator manages engula clusters deployed to Kubernetes and automates tasks related to operating an engula cluster. Backgro

小母牛坐飞机 12 Apr 27, 2022
A lambda extension to hot reload parameters from SSM Parameter Store, Secrets Manager, DynamoDB, AppConfig

A lambda extension to hot reload parameters from SSM Parameter Store, Secrets Manager, DynamoDB, AppConfig

Jake Scott 7 Jun 12, 2022
Use enum to filter something, support | and & operator.

Filter Use enum to filter something, support | and & operator. Just need to implement Filter Trait with filter-macros crate. How to work Example #[add

上铺小哥 9 Feb 8, 2022
A crate to implement leader election for Kubernetes workloads in Rust.

Kubernetes Leader Election in Rust This library provides simple leader election for Kubernetes workloads.

Hendrik Maus 33 Dec 29, 2022
💫 Small microservice to handle state changes of Kubernetes pods and post them to Instatus or Statuspages

?? Kanata Small microservice to handle state changes of Kubernetes pods and post to Instatus ?? Why? I don't really want to implement and repeat code

Noel ʕ •ᴥ•ʔ 4 Mar 4, 2022
kubernetes openapi unmangler

kopium A kubernetes openapi unmangler. Creates rust structs from a named crd by converting the live openapi schema. ⚠️ WARNING: ALPHA SOFTWARE ⚠️ Inst

kube-rs 48 Jan 3, 2023
Continuous Delivery for Declarative Kubernetes, Serverless and Infrastructure Applications

Continuous Delivery for Declarative Kubernetes, Serverless and Infrastructure Applications Explore PipeCD docs » Overview PipeCD provides a unified co

PipeCD 650 Dec 29, 2022
Ultralight, security-first service mesh for Kubernetes. Main repo for Linkerd 2.x.

Linkerd ?? Welcome to Linkerd! ?? Linkerd is an ultralight, security-first service mesh for Kubernetes. Linkerd adds critical security, observability,

Linkerd 9.2k Jan 1, 2023
Northstar is a horizontally scalable and multi-tenant Kubernetes cluster provisioner and orchestrator

Northstar Northstar is a horizontally scalable and multi-tenant Kubernetes cluster provisioner and orchestrator. Explore the docs » View Demo · Report

Lucas Clerisse 1 Jan 22, 2022