The Spring Cloud Config provider for Secrets Store CSI driver allows you to get content stored in Spring Cloud Config and use the Secrets Store CSI driver interface to mount them into a Kubernetes pods.
- A running instance of Spring Cloud Config Server
- Secrets Store CSI Driver installed
To install the provider, use the YAML file in the deployment directory:
kubectl apply -f https://raw.githubusercontent.com/freenowtech/secrets-store-csi-driver-provider-spring-cloud-config/master/deployment/provider.yaml
Create a SecretProviderClass
resource to provide Spring-Cloud-Config-specific parameters for the Secrets Store CSI driver.
apiVersion: secrets-store.csi.x-k8s.io/v1alpha1
kind: SecretProviderClass
metadata:
name: spring-cloud-config-example
spec:
provider: spring-cloud-config
parameters:
serverAddress: "http://configserver.example" # this url should point to config server
application: "myapp" # the application you're retrieving the config for
profile: "prod" # the profile for your application to pull
fileName: "application.yaml" # the name of the file to create - supports extensions .yaml, .yml, .json and .properties
Afterward, reference your SecretProviderClass
in your Pod Definition
kind: Pod
apiVersion: v1
metadata:
name: secrets-store-example
spec:
containers:
- image: ubuntu:latest
name: ubuntu
command: ["/bin/bash"]
args:
- "-c"
- "cat /secrets-store/application.yaml && sleep 300"
volumeMounts:
- name: secrets-store-inline
mountPath: "/secrets-store"
readOnly: true
volumes:
- name: secrets-store-inline
csi:
driver: secrets-store.csi.k8s.com
readOnly: true
volumeAttributes:
secretProviderClass: "spring-cloud-config-example"
- Build the binary:
go build
- Start the binary:
./secrets-store-csi-driver-provider-spring-cloud-config
- In a new terminal window, create the directory
.dev
:mkdir -p .dev
- Download the grpc protobuf definitions:
curl -L -o .dev/service.proto https://raw.githubusercontent.com/kubernetes-sigs/secrets-store-csi-driver/main/provider/v1alpha1/service.proto
- Create the payload
.dev/mount.json
:Make sure to replace the placeholders{ "attributes": "{\"serverAddress\":\"<your-server-address>\",\"application\":\"<your application>\",\"profile\":\"<your profile>\",\"fileName\":\"application.yaml\"}", "secrets": "{}", "targetPath": "./.dev", "permission": "420" }
- Send the payload to the provider:
cat ./.dev/mount.json | grpcurl -unix -plaintext -proto ./.dev/service.proto -d @ ./spring-cloud-config.sock v1alpha1.CSIDriverProvider/Mount
- Verify that the file has been created:
cat ./.dev/application.yaml # Should display YAML content
Follow these steps to release a new version:
-
Create a new release via the GitHub UI.
-
Set
v0.x.y
as the tag and the release title.If the release contains at least one feature, increase
x
by one and sety
to0
.If the release contains bug fixes only, increase
y
by one. -
Let GitHub generate the release notes by clicking the "Generate release notes" button.
-
Click the "Publish release" button.