Skip to content

Commit 2470bb1

Browse files
committed
Removed TokenClient and use CSI token propagation
1 parent 41bb914 commit 2470bb1

31 files changed

+284
-1425
lines changed

Makefile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ e2e-deploy-manifest:
401401
kubectl apply -f manifest_staging/deploy/rbac-secretproviderclass.yaml
402402
kubectl apply -f manifest_staging/deploy/rbac-secretproviderrotation.yaml
403403
kubectl apply -f manifest_staging/deploy/rbac-secretprovidersyncing.yaml
404-
kubectl apply -f manifest_staging/deploy/rbac-secretprovidertokenrequest.yaml
405404
kubectl apply -f manifest_staging/deploy/secrets-store.csi.x-k8s.io_secretproviderclasses.yaml
406405
kubectl apply -f manifest_staging/deploy/secrets-store.csi.x-k8s.io_secretproviderclasspodstatuses.yaml
407406
kubectl apply -f manifest_staging/deploy/role-secretproviderclasses-admin.yaml
@@ -429,6 +428,7 @@ e2e-helm-deploy:
429428
--set syncSecret.enabled=true \
430429
--set enableSecretRotation=true \
431430
--set rotationPollInterval=30s \
431+
--set requiresRepublish=true \
432432
--set tokenRequests[0].audience="aud1" \
433433
--set tokenRequests[1].audience="aud2" \
434434
--set tokenRequests[2].audience="conjur" \
@@ -533,16 +533,6 @@ manifests: $(CONTROLLER_GEN) $(KUSTOMIZE) ## Generate manifests e.g. CRD, RBAC
533533
@sed -i '1s/^/{{ if .Values.enableSecretRotation }}\n/gm; s/namespace: .*/namespace: {{ .Release.Namespace }}/gm; $$s/$$/\n{{ end }}/gm' manifest_staging/charts/secrets-store-csi-driver/templates/role-rotation_binding.yaml
534534
@sed -i '/^roleRef:/i \ \ labels:\n{{ include \"sscd.labels\" . | indent 4 }}' manifest_staging/charts/secrets-store-csi-driver/templates/role-rotation_binding.yaml
535535

536-
# Generate token requests specific RBAC
537-
$(CONTROLLER_GEN) rbac:roleName=secretprovidertokenrequest-role paths="./controllers/tokenrequest" output:dir=config/rbac-tokenrequest
538-
$(KUSTOMIZE) build config/rbac-tokenrequest -o manifest_staging/deploy/rbac-secretprovidertokenrequest.yaml
539-
cp config/rbac-tokenrequest/role.yaml manifest_staging/charts/secrets-store-csi-driver/templates/role-tokenrequest.yaml
540-
cp config/rbac-tokenrequest/role_binding.yaml manifest_staging/charts/secrets-store-csi-driver/templates/role-tokenrequest_binding.yaml
541-
@sed -i '1s/^/{{ if .Values.tokenRequests }}\n/gm; $$s/$$/\n{{ end }}/gm' manifest_staging/charts/secrets-store-csi-driver/templates/role-tokenrequest.yaml
542-
@sed -i '/^rules:/i \ \ labels:\n{{ include \"sscd.labels\" . | indent 4 }}' manifest_staging/charts/secrets-store-csi-driver/templates/role-tokenrequest.yaml
543-
@sed -i '1s/^/{{ if .Values.tokenRequests }}\n/gm; s/namespace: .*/namespace: {{ .Release.Namespace }}/gm; $$s/$$/\n{{ end }}/gm' manifest_staging/charts/secrets-store-csi-driver/templates/role-tokenrequest_binding.yaml
544-
@sed -i '/^roleRef:/i \ \ labels:\n{{ include \"sscd.labels\" . | indent 4 }}' manifest_staging/charts/secrets-store-csi-driver/templates/role-tokenrequest_binding.yaml
545-
546536
.PHONY: generate-protobuf
547537
generate-protobuf: $(PROTOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) # generates protobuf
548538
@PATH=$(PATH):$(TOOLS_BIN_DIR) $(PROTOC) -I . provider/v1alpha1/service.proto --go-grpc_out=require_unimplemented_servers=false:. --go_out=.

cmd/secrets-store-csi-driver/main.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,26 +203,24 @@ func mainErr() error {
203203
reconciler.RunPatcher(ctx)
204204
}()
205205

206-
// token request client
207206
kubeClient := kubernetes.NewForConfigOrDie(cfg)
208-
tokenClient := k8s.NewTokenClient(kubeClient, *driverName, 10*time.Minute)
207+
driverClient := k8s.NewDriverClient(kubeClient, *driverName, 10*time.Minute)
209208

210-
if err = tokenClient.Run(ctx.Done()); err != nil {
211-
klog.ErrorS(err, "failed to run token client")
209+
if err = driverClient.Run(ctx.Done()); err != nil {
210+
klog.ErrorS(err, "failed to run driver client")
212211
return err
213212
}
214-
215213
// Secret rotation
216214
if *enableSecretRotation {
217-
rec, err := rotation.NewReconciler(*driverName, mgr.GetCache(), scheme, *rotationPollInterval, providerClients, tokenClient)
215+
rec, err := rotation.NewReconciler(*driverName, mgr.GetCache(), scheme, *rotationPollInterval, providerClients)
218216
if err != nil {
219217
klog.ErrorS(err, "failed to initialize rotation reconciler")
220218
return err
221219
}
222220
go rec.Run(ctx.Done())
223221
}
224222

225-
driver := secretsstore.NewSecretsStoreDriver(*driverName, *nodeID, *endpoint, providerClients, mgr.GetClient(), mgr.GetAPIReader(), tokenClient)
223+
driver := secretsstore.NewSecretsStoreDriver(*driverName, *nodeID, *endpoint, providerClients, mgr.GetClient(), mgr.GetAPIReader(), driverClient)
226224
driver.Run(ctx)
227225

228226
return nil

config/rbac-tokenrequest/kustomization.yaml

Lines changed: 0 additions & 3 deletions
This file was deleted.

config/rbac-tokenrequest/role.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

config/rbac-tokenrequest/role_binding.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

deploy/rbac-secretprovidertokenrequest.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
ARG BASEIMAGE=registry.k8s.io/build-image/debian-base:bookworm-v1.0.4
1616

17-
FROM golang:1.22 as builder
17+
FROM golang:1.23 as builder
1818
WORKDIR /go/src/sigs.k8s.io/secrets-store-csi-driver
1919
ADD . .
2020
ARG TARGETARCH

docs/book/src/getting-started/installation.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ kubectl apply -f deploy/rbac-secretprovidersyncing.yaml
5050
# required to enable this feature
5151
kubectl apply -f deploy/rbac-secretproviderrotation.yaml
5252

53-
# If using the CSI Driver token requests feature (https://kubernetes-csi.github.io/docs/token-requests.html) to use
54-
# pod/workload identity to request a token and use with providers
55-
kubectl apply -f deploy/rbac-secretprovidertokenrequest.yaml
56-
5753
# [OPTIONAL] To deploy driver on windows nodes
5854
kubectl apply -f deploy/secrets-store-csi-driver-windows.yaml
5955
```

manifest_staging/charts/secrets-store-csi-driver/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,5 @@ The following table lists the configurable parameters of the csi-secrets-store-p
115115
| `providerHealthCheck` | Enable health check for configured providers | `false` |
116116
| `providerHealthCheckInterval` | Provider healthcheck interval duration | `2m` |
117117
| `imagePullSecrets` | One or more secrets to be used when pulling images | `""` |
118-
| `tokenRequests` | Token requests configuration for the csi driver. Refer to [doc](https://kubernetes-csi.github.io/docs/token-requests.html) for more info. Supported only for Kubernetes v1.20+ | `""` |
118+
| `tokenRequests` | Token requests configuration for the csi driver. Refer to [doc](https://kubernetes-csi.github.io/docs/token-requests.html) for more info. Supported only for Kubernetes v1.20+ | `[]` |
119+
| `requiresRepublish` | Setting this to `true` will enable propagation of refreshed Service Account tokens to secret plugins, allowing plugins to update the contents of a mount. `tokenRequests` must be populated for this to succeed. | `false` |

manifest_staging/charts/secrets-store-csi-driver/templates/csidriver.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ metadata:
77
spec:
88
podInfoOnMount: true
99
attachRequired: false
10+
{{- if .Values.requiresRepublish }}
11+
requiresRepublish: true
12+
{{- end }}
1013
# Added in Kubernetes 1.16 with default mode of Persistent. Secrets store csi driver needs Ephermeral to be set.
1114
volumeLifecycleModes:
1215
- Ephemeral

0 commit comments

Comments
 (0)