Compare commits
6 Commits
Lerentis/i
...
2bf13bc8c5
Author | SHA1 | Date | |
---|---|---|---|
2bf13bc8c5 | |||
48754d4578
|
|||
a2186ab3aa | |||
9f4264d355
|
|||
620d0f0b18
|
|||
ac0bc2d89d
|
17
Dockerfile
17
Dockerfile
@ -1,14 +1,15 @@
|
|||||||
FROM alpine:3.18.4
|
FROM alpine:3.19.0
|
||||||
|
|
||||||
LABEL org.opencontainers.image.source=https://github.com/Lerentis/bitwarden-crd-operator
|
LABEL org.opencontainers.image.source=https://github.com/Lerentis/bitwarden-crd-operator
|
||||||
LABEL org.opencontainers.image.description="Kubernetes Operator to create k8s secrets from bitwarden"
|
LABEL org.opencontainers.image.description="Kubernetes Operator to create k8s secrets from bitwarden"
|
||||||
LABEL org.opencontainers.image.licenses=MIT
|
LABEL org.opencontainers.image.licenses=MIT
|
||||||
|
|
||||||
ARG PYTHON_VERSION=3.11.6-r0
|
ARG PYTHON_VERSION=3.11.6-r1
|
||||||
ARG PIP_VERSION=23.1.2-r0
|
ARG PIP_VERSION=23.3.1-r0
|
||||||
ARG GCOMPAT_VERSION=1.1.0-r1
|
ARG GCOMPAT_VERSION=1.1.0-r4
|
||||||
ARG LIBCRYPTO_VERSION=3.1.3-r0
|
ARG LIBCRYPTO_VERSION=3.1.4-r2
|
||||||
ARG BW_VERSION=2023.1.0
|
ARG BW_VERSION=2023.7.0
|
||||||
|
ARG NODE_VERSION=20.10.0-r1
|
||||||
|
|
||||||
COPY requirements.txt /requirements.txt
|
COPY requirements.txt /requirements.txt
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ RUN set -eux; \
|
|||||||
ARCH="$(apk --print-arch)"; \
|
ARCH="$(apk --print-arch)"; \
|
||||||
case "${ARCH}" in \
|
case "${ARCH}" in \
|
||||||
aarch64|arm64) \
|
aarch64|arm64) \
|
||||||
apk add npm; \
|
apk add nodejs=${NODE_VERSION} npm; \
|
||||||
npm install -g @bitwarden/cli@${BW_VERSION}; \
|
npm install -g @bitwarden/cli@${BW_VERSION}; \
|
||||||
;; \
|
;; \
|
||||||
amd64|x86_64) \
|
amd64|x86_64) \
|
||||||
@ -38,7 +39,7 @@ RUN set -eux; \
|
|||||||
mkdir -p /home/bw-operator; \
|
mkdir -p /home/bw-operator; \
|
||||||
chown -R bw-operator /home/bw-operator; \
|
chown -R bw-operator /home/bw-operator; \
|
||||||
apk add gcc musl-dev libstdc++ gcompat=${GCOMPAT_VERSION} python3=${PYTHON_VERSION} py3-pip=${PIP_VERSION} libcrypto3=${LIBCRYPTO_VERSION}; \
|
apk add gcc musl-dev libstdc++ gcompat=${GCOMPAT_VERSION} python3=${PYTHON_VERSION} py3-pip=${PIP_VERSION} libcrypto3=${LIBCRYPTO_VERSION}; \
|
||||||
pip install -r /requirements.txt --no-warn-script-location; \
|
pip install -r /requirements.txt --no-warn-script-location --break-system-packages; \
|
||||||
rm /requirements.txt; \
|
rm /requirements.txt; \
|
||||||
apk del --purge gcc musl-dev libstdc++;
|
apk del --purge gcc musl-dev libstdc++;
|
||||||
|
|
||||||
|
18
README.md
18
README.md
@ -56,7 +56,7 @@ And you are set to create your first secret using this operator. For that you ne
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
apiVersion: "lerentis.uploadfilter24.eu/v1beta4"
|
apiVersion: "lerentis.uploadfilter24.eu/v1beta5"
|
||||||
kind: BitwardenSecret
|
kind: BitwardenSecret
|
||||||
metadata:
|
metadata:
|
||||||
name: name-of-your-management-object
|
name: name-of-your-management-object
|
||||||
@ -73,6 +73,8 @@ spec:
|
|||||||
id: "A Secret ID from bitwarden"
|
id: "A Secret ID from bitwarden"
|
||||||
name: "Name of the secret to be created"
|
name: "Name of the secret to be created"
|
||||||
namespace: "Namespace of the secret to be created"
|
namespace: "Namespace of the secret to be created"
|
||||||
|
labels: # Optional
|
||||||
|
key: value
|
||||||
```
|
```
|
||||||
|
|
||||||
The ID can be extracted from the browser when you open a item the ID is in the URL. The resulting secret looks something like this:
|
The ID can be extracted from the browser when you open a item the ID is in the URL. The resulting secret looks something like this:
|
||||||
@ -87,6 +89,8 @@ metadata:
|
|||||||
annotations:
|
annotations:
|
||||||
managed: bitwarden-secrets.lerentis.uploadfilter24.eu
|
managed: bitwarden-secrets.lerentis.uploadfilter24.eu
|
||||||
managedObject: bw-operator/test
|
managedObject: bw-operator/test
|
||||||
|
labels:
|
||||||
|
key: value
|
||||||
name: name-of-your-management-object
|
name: name-of-your-management-object
|
||||||
namespace: default
|
namespace: default
|
||||||
type: Opaque
|
type: Opaque
|
||||||
@ -98,7 +102,7 @@ For managing registry credentials, or pull secrets, you can create another kind
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
apiVersion: "lerentis.uploadfilter24.eu/v1beta4"
|
apiVersion: "lerentis.uploadfilter24.eu/v1beta5"
|
||||||
kind: RegistryCredential
|
kind: RegistryCredential
|
||||||
metadata:
|
metadata:
|
||||||
name: name-of-your-management-object
|
name: name-of-your-management-object
|
||||||
@ -109,6 +113,8 @@ spec:
|
|||||||
id: "A Secret ID from bitwarden"
|
id: "A Secret ID from bitwarden"
|
||||||
name: "Name of the secret to be created"
|
name: "Name of the secret to be created"
|
||||||
namespace: "Namespace of the secret to be created"
|
namespace: "Namespace of the secret to be created"
|
||||||
|
labels: # Optional
|
||||||
|
key: value
|
||||||
```
|
```
|
||||||
|
|
||||||
The resulting secret looks something like this:
|
The resulting secret looks something like this:
|
||||||
@ -122,6 +128,8 @@ metadata:
|
|||||||
annotations:
|
annotations:
|
||||||
managed: bitwarden-secrets.lerentis.uploadfilter24.eu
|
managed: bitwarden-secrets.lerentis.uploadfilter24.eu
|
||||||
managedObject: bw-operator/test
|
managedObject: bw-operator/test
|
||||||
|
labels:
|
||||||
|
key: value
|
||||||
name: name-of-your-management-object
|
name: name-of-your-management-object
|
||||||
namespace: default
|
namespace: default
|
||||||
type: dockerconfigjson
|
type: dockerconfigjson
|
||||||
@ -133,7 +141,7 @@ One of the more freely defined types that can be used with this operator you can
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
apiVersion: "lerentis.uploadfilter24.eu/v1beta4"
|
apiVersion: "lerentis.uploadfilter24.eu/v1beta5"
|
||||||
kind: BitwardenTemplate
|
kind: BitwardenTemplate
|
||||||
metadata:
|
metadata:
|
||||||
name: name-of-your-management-object
|
name: name-of-your-management-object
|
||||||
@ -141,6 +149,8 @@ spec:
|
|||||||
filename: "Key of the secret to be created"
|
filename: "Key of the secret to be created"
|
||||||
name: "Name of the secret to be created"
|
name: "Name of the secret to be created"
|
||||||
namespace: "Namespace of the secret to be created"
|
namespace: "Namespace of the secret to be created"
|
||||||
|
labels: # Optional
|
||||||
|
key: value
|
||||||
template: |
|
template: |
|
||||||
---
|
---
|
||||||
api:
|
api:
|
||||||
@ -164,6 +174,8 @@ metadata:
|
|||||||
annotations:
|
annotations:
|
||||||
managed: bitwarden-template.lerentis.uploadfilter24.eu
|
managed: bitwarden-template.lerentis.uploadfilter24.eu
|
||||||
managedObject: namespace/name-of-your-management-object
|
managedObject: namespace/name-of-your-management-object
|
||||||
|
labels:
|
||||||
|
key: value
|
||||||
name: Name of the secret to be created
|
name: Name of the secret to be created
|
||||||
namespace: Namespace of the secret to be created
|
namespace: Namespace of the secret to be created
|
||||||
type: Opaque
|
type: Opaque
|
||||||
|
@ -4,9 +4,9 @@ description: Deploy the Bitwarden CRD Operator
|
|||||||
|
|
||||||
type: application
|
type: application
|
||||||
|
|
||||||
version: "v0.11.0"
|
version: "v0.11.1"
|
||||||
|
|
||||||
appVersion: "0.10.0"
|
appVersion: "0.10.1"
|
||||||
|
|
||||||
keywords:
|
keywords:
|
||||||
- operator
|
- operator
|
||||||
@ -101,8 +101,10 @@ annotations:
|
|||||||
artifacthub.io/operator: "true"
|
artifacthub.io/operator: "true"
|
||||||
artifacthub.io/containsSecurityUpdates: "false"
|
artifacthub.io/containsSecurityUpdates: "false"
|
||||||
artifacthub.io/changes: |
|
artifacthub.io/changes: |
|
||||||
|
- kind: fixed
|
||||||
|
description: "Downgrade node to LTS in order to make bw cli work on arm"
|
||||||
- kind: changed
|
- kind: changed
|
||||||
description: "Added the possibility to add labels to generated secrets"
|
description: "Update bw cli to 2023.7.0 for the same reason"
|
||||||
artifacthub.io/images: |
|
artifacthub.io/images: |
|
||||||
- name: bitwarden-crd-operator
|
- name: bitwarden-crd-operator
|
||||||
image: ghcr.io/lerentis/bitwarden-crd-operator:0.10.0
|
image: ghcr.io/lerentis/bitwarden-crd-operator:0.10.1
|
||||||
|
@ -14,8 +14,9 @@ spec:
|
|||||||
- bws
|
- bws
|
||||||
versions:
|
versions:
|
||||||
- name: v1beta4
|
- name: v1beta4
|
||||||
served: false
|
served: true
|
||||||
storage: true
|
storage: false
|
||||||
|
deprecated: true
|
||||||
schema:
|
schema:
|
||||||
openAPIV3Schema:
|
openAPIV3Schema:
|
||||||
type: object
|
type: object
|
||||||
@ -82,21 +83,8 @@ spec:
|
|||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
labels:
|
labels:
|
||||||
type: array
|
type: object
|
||||||
items:
|
x-kubernetes-preserve-unknown-fields: true
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
json:
|
|
||||||
x-kubernetes-preserve-unknown-fields: true
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
spec:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
foo:
|
|
||||||
type: string
|
|
||||||
bar:
|
|
||||||
type: string
|
|
||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
- namespace
|
- namespace
|
||||||
|
@ -14,8 +14,9 @@ spec:
|
|||||||
- bwt
|
- bwt
|
||||||
versions:
|
versions:
|
||||||
- name: v1beta4
|
- name: v1beta4
|
||||||
served: false
|
served: true
|
||||||
storage: true
|
storage: false
|
||||||
|
deprecated: true
|
||||||
schema:
|
schema:
|
||||||
openAPIV3Schema:
|
openAPIV3Schema:
|
||||||
type: object
|
type: object
|
||||||
@ -55,21 +56,8 @@ spec:
|
|||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
labels:
|
labels:
|
||||||
type: array
|
type: object
|
||||||
items:
|
x-kubernetes-preserve-unknown-fields: true
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
json:
|
|
||||||
x-kubernetes-preserve-unknown-fields: true
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
spec:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
foo:
|
|
||||||
type: string
|
|
||||||
bar:
|
|
||||||
type: string
|
|
||||||
required:
|
required:
|
||||||
- filename
|
- filename
|
||||||
- template
|
- template
|
||||||
|
@ -14,8 +14,9 @@ spec:
|
|||||||
- rgc
|
- rgc
|
||||||
versions:
|
versions:
|
||||||
- name: v1beta4
|
- name: v1beta4
|
||||||
served: false
|
served: true
|
||||||
storage: true
|
storage: false
|
||||||
|
deprecated: true
|
||||||
schema:
|
schema:
|
||||||
openAPIV3Schema:
|
openAPIV3Schema:
|
||||||
type: object
|
type: object
|
||||||
@ -65,21 +66,8 @@ spec:
|
|||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
labels:
|
labels:
|
||||||
type: array
|
type: object
|
||||||
items:
|
x-kubernetes-preserve-unknown-fields: true
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
json:
|
|
||||||
x-kubernetes-preserve-unknown-fields: true
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
spec:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
foo:
|
|
||||||
type: string
|
|
||||||
bar:
|
|
||||||
type: string
|
|
||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
- namespace
|
- namespace
|
||||||
|
@ -17,7 +17,8 @@ spec:
|
|||||||
name: "test-secret"
|
name: "test-secret"
|
||||||
namespace: "default"
|
namespace: "default"
|
||||||
labels:
|
labels:
|
||||||
- key: value
|
key: value
|
||||||
|
app: example-app
|
||||||
---
|
---
|
||||||
apiVersion: "lerentis.uploadfilter24.eu/v1beta5"
|
apiVersion: "lerentis.uploadfilter24.eu/v1beta5"
|
||||||
kind: BitwardenSecret
|
kind: BitwardenSecret
|
||||||
@ -32,5 +33,3 @@ spec:
|
|||||||
id: "466fc4b0-ffca-4444-8d88-b59d4de3d928"
|
id: "466fc4b0-ffca-4444-8d88-b59d4de3d928"
|
||||||
name: "test-scope"
|
name: "test-scope"
|
||||||
namespace: "default"
|
namespace: "default"
|
||||||
labels:
|
|
||||||
- key: value
|
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
apiVersion: "lerentis.uploadfilter24.eu/v1beta4"
|
apiVersion: "lerentis.uploadfilter24.eu/v1beta5"
|
||||||
kind: RegistryCredential
|
kind: RegistryCredential
|
||||||
metadata:
|
metadata:
|
||||||
name: test
|
name: test
|
||||||
@ -10,3 +10,6 @@ spec:
|
|||||||
id: "3b249ec7-9ce7-440a-9558-f34f3ab10680"
|
id: "3b249ec7-9ce7-440a-9558-f34f3ab10680"
|
||||||
name: "test-regcred"
|
name: "test-regcred"
|
||||||
namespace: "default"
|
namespace: "default"
|
||||||
|
labels:
|
||||||
|
namespace: default
|
||||||
|
tenant: example-team
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
apiVersion: "lerentis.uploadfilter24.eu/v1beta4"
|
apiVersion: "lerentis.uploadfilter24.eu/v1beta5"
|
||||||
kind: BitwardenTemplate
|
kind: BitwardenTemplate
|
||||||
metadata:
|
metadata:
|
||||||
name: test
|
name: test
|
||||||
@ -7,6 +7,9 @@ spec:
|
|||||||
filename: "config.yaml"
|
filename: "config.yaml"
|
||||||
name: "test-template"
|
name: "test-template"
|
||||||
namespace: "default"
|
namespace: "default"
|
||||||
|
labels:
|
||||||
|
key: value
|
||||||
|
app: example-app
|
||||||
template: |
|
template: |
|
||||||
---
|
---
|
||||||
api:
|
api:
|
||||||
|
@ -96,6 +96,7 @@ def update_managed_registry_secret(
|
|||||||
id = spec.get('id')
|
id = spec.get('id')
|
||||||
secret_name = spec.get('name')
|
secret_name = spec.get('name')
|
||||||
secret_namespace = spec.get('namespace')
|
secret_namespace = spec.get('namespace')
|
||||||
|
labels = spec.get('labels')
|
||||||
|
|
||||||
old_config = None
|
old_config = None
|
||||||
old_secret_name = None
|
old_secret_name = None
|
||||||
@ -132,9 +133,13 @@ def update_managed_registry_secret(
|
|||||||
"managed": "registry-credential.lerentis.uploadfilter24.eu",
|
"managed": "registry-credential.lerentis.uploadfilter24.eu",
|
||||||
"managedObject": f"{namespace}/{name}"
|
"managedObject": f"{namespace}/{name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not labels:
|
||||||
|
labels = {}
|
||||||
|
|
||||||
secret = kubernetes.client.V1Secret()
|
secret = kubernetes.client.V1Secret()
|
||||||
secret.metadata = kubernetes.client.V1ObjectMeta(
|
secret.metadata = kubernetes.client.V1ObjectMeta(
|
||||||
name=secret_name, annotations=annotations)
|
name=secret_name, annotations=annotations, labels=labels)
|
||||||
secret = create_dockerlogin(
|
secret = create_dockerlogin(
|
||||||
logger,
|
logger,
|
||||||
secret,
|
secret,
|
||||||
@ -143,7 +148,7 @@ def update_managed_registry_secret(
|
|||||||
password_ref,
|
password_ref,
|
||||||
registry)
|
registry)
|
||||||
try:
|
try:
|
||||||
obj = api.replace_namespaced_secret(
|
api.replace_namespaced_secret(
|
||||||
name=secret_name,
|
name=secret_name,
|
||||||
body=secret,
|
body=secret,
|
||||||
namespace="{}".format(secret_namespace))
|
namespace="{}".format(secret_namespace))
|
||||||
|
@ -93,6 +93,7 @@ def update_managed_secret(
|
|||||||
old_secret_namespace = old_config['spec'].get('namespace')
|
old_secret_namespace = old_config['spec'].get('namespace')
|
||||||
secret_name = spec.get('name')
|
secret_name = spec.get('name')
|
||||||
secret_namespace = spec.get('namespace')
|
secret_namespace = spec.get('namespace')
|
||||||
|
labels = spec.get('labels')
|
||||||
|
|
||||||
if old_config is not None and (
|
if old_config is not None and (
|
||||||
old_secret_name != secret_name or old_secret_namespace != secret_namespace):
|
old_secret_name != secret_name or old_secret_namespace != secret_namespace):
|
||||||
@ -119,13 +120,16 @@ def update_managed_secret(
|
|||||||
"managedObject": f"{namespace}/{name}"
|
"managedObject": f"{namespace}/{name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not labels:
|
||||||
|
labels = {}
|
||||||
|
|
||||||
secret = kubernetes.client.V1Secret()
|
secret = kubernetes.client.V1Secret()
|
||||||
secret.metadata = kubernetes.client.V1ObjectMeta(
|
secret.metadata = kubernetes.client.V1ObjectMeta(
|
||||||
name=secret_name, annotations=annotations)
|
name=secret_name, annotations=annotations, labels=labels)
|
||||||
secret = create_kv(secret, secret_json_object, content_def)
|
secret = create_kv(secret, secret_json_object, content_def)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj = api.replace_namespaced_secret(
|
api.replace_namespaced_secret(
|
||||||
name=secret_name,
|
name=secret_name,
|
||||||
body=secret,
|
body=secret,
|
||||||
namespace="{}".format(secret_namespace))
|
namespace="{}".format(secret_namespace))
|
||||||
|
@ -52,7 +52,7 @@ def create_managed_secret(spec, name, namespace, logger, body, **kwargs):
|
|||||||
name=secret_name, annotations=annotations, labels=labels)
|
name=secret_name, annotations=annotations, labels=labels)
|
||||||
secret = create_template_secret(logger, secret, filename, template)
|
secret = create_template_secret(logger, secret, filename, template)
|
||||||
|
|
||||||
obj = api.create_namespaced_secret(
|
api.create_namespaced_secret(
|
||||||
secret_namespace, secret
|
secret_namespace, secret
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -74,6 +74,7 @@ def update_managed_secret(
|
|||||||
filename = spec.get('filename')
|
filename = spec.get('filename')
|
||||||
secret_name = spec.get('name')
|
secret_name = spec.get('name')
|
||||||
secret_namespace = spec.get('namespace')
|
secret_namespace = spec.get('namespace')
|
||||||
|
labels = spec.get('labels')
|
||||||
|
|
||||||
old_config = None
|
old_config = None
|
||||||
old_secret_name = None
|
old_secret_name = None
|
||||||
@ -108,13 +109,17 @@ def update_managed_secret(
|
|||||||
"managed": "bitwarden-template.lerentis.uploadfilter24.eu",
|
"managed": "bitwarden-template.lerentis.uploadfilter24.eu",
|
||||||
"managedObject": f"{namespace}/{name}"
|
"managedObject": f"{namespace}/{name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not labels:
|
||||||
|
labels = {}
|
||||||
|
|
||||||
secret = kubernetes.client.V1Secret()
|
secret = kubernetes.client.V1Secret()
|
||||||
secret.metadata = kubernetes.client.V1ObjectMeta(
|
secret.metadata = kubernetes.client.V1ObjectMeta(
|
||||||
name=secret_name, annotations=annotations)
|
name=secret_name, annotations=annotations, labels=labels)
|
||||||
secret = create_template_secret(logger, secret, filename, template)
|
secret = create_template_secret(logger, secret, filename, template)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obj = api.replace_namespaced_secret(
|
api.replace_namespaced_secret(
|
||||||
name=secret_name,
|
name=secret_name,
|
||||||
body=secret,
|
body=secret,
|
||||||
namespace="{}".format(secret_namespace))
|
namespace="{}".format(secret_namespace))
|
||||||
|
Reference in New Issue
Block a user