mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-01 20:56:02 +09:00
feat(linstor): run blockstor's snapshot stream on 3372 over mutual TLS
blockstor v0.2.0 moved the stream between satellites from port 9100 to 3372 and runs it over mutual TLS with a CA of its own. The chart issues the stream CA and the satellites' certificate, mounts it into the satellite, and closes 3372 to the world instead of 9100. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
3 files changed
+156
-7
No files matched your search
@@ -12,6 +12,9 @@
|
||||
└─> blockstor-api-ca (CA Issuer)
|
||||
├─> blockstor-apiserver-server (serving cert, Service DNS SANs)
|
||||
└─> blockstor-apiserver-client (client cert for in-cluster consumers)
|
||||
└─> blockstor-stream-ca (CA Certificate, 10y, kept apart from the API CA)
|
||||
└─> blockstor-stream-ca (CA Issuer)
|
||||
└─> blockstor-satellite-stream (one cert for every satellite's snapshot stream)
|
||||
|
||||
The apiserver's TLS listener (RequireAndVerifyClientCert) verifies
|
||||
every client cert against ca.crt of the server Secret, and serves
|
||||
@@ -107,4 +110,68 @@ spec:
|
||||
issuerRef:
|
||||
name: blockstor-api-ca
|
||||
kind: Issuer
|
||||
---
|
||||
{{- /*
|
||||
The snapshot stream between satellites has a CA of its own. A stream
|
||||
certificate is a client certificate, and one from blockstor-api-ca would
|
||||
also be accepted by the apiserver's mutual-TLS listener; keeping the CAs
|
||||
apart keeps a satellite's stream identity off the REST API. */}}
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: blockstor-stream-ca
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
commonName: blockstor-stream-ca
|
||||
secretName: blockstor-stream-ca
|
||||
duration: 87600h # 10 years
|
||||
isCA: true
|
||||
privateKey:
|
||||
rotationPolicy: Never
|
||||
usages:
|
||||
- signing
|
||||
- key encipherment
|
||||
- cert sign
|
||||
issuerRef:
|
||||
name: ca-bootstrapper
|
||||
kind: Issuer
|
||||
---
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Issuer
|
||||
metadata:
|
||||
name: blockstor-stream-ca
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
ca:
|
||||
secretName: blockstor-stream-ca
|
||||
---
|
||||
{{- /*
|
||||
One certificate for every satellite, for both ends of a stream: the
|
||||
satellites dial each other by node address, so the name checked is the
|
||||
fixed blockstor-satellite, not an address. A satellite pod does not
|
||||
start until cert-manager has issued blockstor-satellite-stream-tls. */}}
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: blockstor-satellite-stream
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
secretName: blockstor-satellite-stream-tls
|
||||
commonName: blockstor-satellite
|
||||
duration: 2160h # 90 days
|
||||
renewBefore: 360h # 15 days
|
||||
privateKey:
|
||||
algorithm: ECDSA
|
||||
size: 256
|
||||
rotationPolicy: Always
|
||||
usages:
|
||||
- server auth
|
||||
- client auth
|
||||
- digital signature
|
||||
- key encipherment
|
||||
dnsNames:
|
||||
- blockstor-satellite
|
||||
issuerRef:
|
||||
name: blockstor-stream-ca
|
||||
kind: Issuer
|
||||
{{- end }}
|
||||
@@ -192,6 +192,14 @@ spec:
|
||||
{{- /*
|
||||
Storage pools come from StoragePool objects, not flags. */}}
|
||||
- --health-probe-bind-address=:9101
|
||||
{{- /*
|
||||
Mutual TLS of the snapshot stream between satellites (port
|
||||
3372). Every satellite presents the same certificate, issued
|
||||
by the stream CA in blockstor-apiserver-tls.yaml, and accepts
|
||||
only peers that present one from that CA. */}}
|
||||
- --stream-tls-cert-file=/etc/blockstor/stream-tls/tls.crt
|
||||
- --stream-tls-key-file=/etc/blockstor/stream-tls/tls.key
|
||||
- --stream-tls-ca-file=/etc/blockstor/stream-tls/ca.crt
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom: {fieldRef: {fieldPath: spec.nodeName}}
|
||||
@@ -235,6 +243,7 @@ spec:
|
||||
mountPath: /etc/drbd.d/global_common.conf
|
||||
subPath: global_common.conf
|
||||
readOnly: true
|
||||
- {name: stream-tls, mountPath: /etc/blockstor/stream-tls, readOnly: true}
|
||||
resources:
|
||||
requests: {cpu: 50m, memory: 64Mi}
|
||||
limits: {cpu: 500m, memory: 512Mi}
|
||||
@@ -251,12 +260,18 @@ spec:
|
||||
name: blockstor-satellite-drbd-conf
|
||||
items:
|
||||
- {key: global_common.conf, path: global_common.conf}
|
||||
{{- /*
|
||||
Read on every stream handshake, so a certificate cert-manager
|
||||
rotates is picked up without a restart. */}}
|
||||
- name: stream-tls
|
||||
secret:
|
||||
secretName: blockstor-satellite-stream-tls
|
||||
---
|
||||
{{- /*
|
||||
blockstor-satellite runs on host networking and, in this release, listens
|
||||
on every address without authentication: 9100 serves snapshot streams to
|
||||
other satellites, 9101 its health probes, 8080 controller-runtime's
|
||||
metrics. None of them is for anything outside the cluster, so they are
|
||||
blockstor-satellite runs on host networking and listens on every address:
|
||||
3372 serves snapshot streams to other satellites over mutual TLS, 9101 its
|
||||
health probes and 8080 controller-runtime's metrics, both without
|
||||
authentication. None of them is for anything outside the cluster, so they are
|
||||
closed to the world the way restrict-drbd-reactor closes drbd-reactor's. */}}
|
||||
apiVersion: cilium.io/v2
|
||||
kind: CiliumClusterwideNetworkPolicy
|
||||
@@ -268,7 +283,7 @@ spec:
|
||||
- world
|
||||
toPorts:
|
||||
- ports:
|
||||
- port: "9100"
|
||||
- port: "3372"
|
||||
- port: "9101"
|
||||
- port: "8080"
|
||||
ingress:
|
||||
|
||||
@@ -119,7 +119,7 @@ tests:
|
||||
resources: [leases]
|
||||
verbs: [get, list, watch, create, update, patch, delete]
|
||||
|
||||
- it: closes the satellite's unauthenticated ports to the world
|
||||
- it: closes the satellite's ports to the world
|
||||
template: templates/blockstor-satellite.yaml
|
||||
documentSelector:
|
||||
path: kind
|
||||
@@ -131,10 +131,77 @@ tests:
|
||||
- equal:
|
||||
path: spec.ingressDeny[0].toPorts[0].ports
|
||||
value:
|
||||
- port: "9100"
|
||||
- port: "3372"
|
||||
- port: "9101"
|
||||
- port: "8080"
|
||||
|
||||
# The snapshot stream runs over mutual TLS: without the Secret mounted and
|
||||
# the three flags the satellite serves no stream at all.
|
||||
- it: gives the satellite the snapshot stream's TLS
|
||||
template: templates/blockstor-satellite.yaml
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: DaemonSet
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].args
|
||||
content: --stream-tls-cert-file=/etc/blockstor/stream-tls/tls.crt
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].args
|
||||
content: --stream-tls-key-file=/etc/blockstor/stream-tls/tls.key
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].args
|
||||
content: --stream-tls-ca-file=/etc/blockstor/stream-tls/ca.crt
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
content: {name: stream-tls, mountPath: /etc/blockstor/stream-tls, readOnly: true}
|
||||
- contains:
|
||||
path: spec.template.spec.volumes
|
||||
content:
|
||||
name: stream-tls
|
||||
secret:
|
||||
secretName: blockstor-satellite-stream-tls
|
||||
|
||||
# The stream CA stays apart from the API CA: a stream certificate is a
|
||||
# client certificate the apiserver's mutual-TLS listener would otherwise
|
||||
# accept.
|
||||
- it: issues the satellite stream certificate from its own CA
|
||||
template: templates/blockstor-apiserver-tls.yaml
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: blockstor-satellite-stream
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.secretName
|
||||
value: blockstor-satellite-stream-tls
|
||||
- equal:
|
||||
path: spec.issuerRef.name
|
||||
value: blockstor-stream-ca
|
||||
- equal:
|
||||
path: spec.dnsNames
|
||||
value: [blockstor-satellite]
|
||||
- contains:
|
||||
path: spec.usages
|
||||
content: server auth
|
||||
- contains:
|
||||
path: spec.usages
|
||||
content: client auth
|
||||
|
||||
- it: roots the stream CA in the bootstrapper, not in the API CA
|
||||
template: templates/blockstor-apiserver-tls.yaml
|
||||
documentSelector:
|
||||
path: spec.commonName
|
||||
value: blockstor-stream-ca
|
||||
asserts:
|
||||
- isKind:
|
||||
of: Certificate
|
||||
- equal:
|
||||
path: spec.isCA
|
||||
value: true
|
||||
- equal:
|
||||
path: spec.issuerRef.name
|
||||
value: ca-bootstrapper
|
||||
|
||||
# A kind added to the group later must not be granted by omission, so the
|
||||
# roles are pinned whole: a wildcard or a new kind shows up as a diff here.
|
||||
- it: pins the controller ClusterRole rule by rule
|
||||
|
||||
Reference in new issue
Block a user