GithubHelp home page GithubHelp logo

isabella232 / csi-driver-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cert-manager/csi-driver

0.0 0.0 0.0 706 KB

A Kubernetes CSI plugin to automatically mount signed certificates to Pods using ephemeral volumes

Home Page: https://cert-manager.io

License: Apache License 2.0

Go 86.58% Dockerfile 0.87% Makefile 1.78% Python 5.72% Shell 4.41% Mustache 0.64%

csi-driver-1's Introduction

cert-manager project logo

csi-driver godoc Go Report Card Artifact Hub

csi-driver

csi-driver is a Container Storage Interface (CSI) driver plugin for Kubernetes to work along cert-manager. The goal for this plugin is to facilitate requesting and mounting certificate key pairs to pods seamlessly. This is useful for facilitating mTLS, or otherwise securing connections of pods with guaranteed present certificates whilst having all of the features that cert-manager provides.

Why a CSI Driver?

  • Ensure private keys never leave the node and are never sent over the network. All private keys are stored locally on the node.
  • Unique key and certificate per application replica with a grantee to be present on application run time.
  • Reduce resource management overhead by defining certificate request spec in-line of the Kubernetes Pod template.
  • Automatic renewal of certificates based on expiry of each individual certificate.
  • Keys and certificates are destroyed during application termination.
  • Scope for extending plugin behaviour with visibility on each replica's certificate request and termination.

Requirements and Installation

This CSI driver plugin makes use of the 'CSI inline volume' feature - Alpha as of v1.15 and beta in v1.16. Kubernetes versions v1.16 and higher require no extra configuration however v1.15 requires the following feature gate set:

--feature-gates=CSIInlineVolume=true

You must have a working installation of cert-manager present on the cluster. Instructions on how to install cert-manager can be found here.

To install the csi-driver, use helm install:

 $ helm repo add jetstack https://charts.jetstack.io --force-update
 $ helm upgrade -i -n cert-manager cert-manager-csi-driver jetstack/cert-manager-csi-driver --wait

Or apply the static manifests to your cluster:

 $ helm template ./deploy/charts/csi-driver | kubectl apply -n cert-manager -f -

You can verify the installation has completed correctly by checking the presence of the CSIDriver resource as well as a CSINode resource present for each node, referencing csi.cert-manager.io.

$ kubectl get csidrivers
NAME                     CREATED AT
csi.cert-manager.io   2019-09-06T16:55:19Z

$ kubectl get csinodes -o yaml
apiVersion: v1
items:
- apiVersion: storage.k8s.io/v1beta1
  kind: CSINode
  metadata:
    name: kind-control-plane
    ownerReferences:
    - apiVersion: v1
      kind: Node
      name: kind-control-plane
...
  spec:
    drivers:
    - name: csi.cert-manager.io
      nodeID: kind-control-plane
      topologyKeys: null
...

The CSI driver is now installed and is ready to be used for pods in the cluster.

Requesting and Mounting Certificates

To request certificates from cert-manager, simply define a volume mount where the key and certificate will be written to, along with a volume with attributes that define the cert-manager request. The following is a dummy app that mounts a key certificate pair to /tls and has been signed by the ca-issuer with a DNS name valid for my-service.sandbox.svc.cluster.local.

apiVersion: v1
kind: Pod
metadata:
  name: my-csi-app
  namespace: sandbox
  labels:
    app: my-csi-app
spec:
  containers:
    - name: my-frontend
      image: busybox
      volumeMounts:
      - mountPath: "/tls"
        name: tls
      command: [ "sleep", "1000000" ]
  volumes:
    - name: tls
      csi:
        driver: csi.cert-manager.io
        volumeAttributes:
              csi.cert-manager.io/issuer-name: ca-issuer
              csi.cert-manager.io/dns-names: my-service.sandbox.svc.cluster.local

Once created, the CSI driver will generate a private key locally, request a certificate from cert-manager based on the given attributes, then store both locally to be mounted to the pod. The pod will remain in a pending state until this process has been completed.

For more information on how to set up issuers for your cluster, refer to the cert-manager documentation here. Note it is not possible to use SelfSigned Issuers with the CSI Driver. In order for cert-manager to self sign a certificate, it needs access to the secret containing the private key that signed the certificate request to sign the end certificate. This secret is not used and so not available in the CSI driver use case.

Supported Volume Attributes

The csi-driver driver aims to have complete feature parity with all possible values available through the cert-manager API however currently supports the following values;

Attribute Description Default Example
csi.cert-manager.io/issuer-name The Issuer name to sign the certificate request. ca-issuer
csi.cert-manager.io/issuer-kind The Issuer kind to sign the certificate request. Issuer ClusterIssuer
csi.cert-manager.io/issuer-group The group name the Issuer belongs to. cert-manager.io out.of.tree.foo
csi.cert-manager.io/common-name Certificate common name. my-cert.foo
csi.cert-manager.io/dns-names DNS names the certificate will be requested for. At least a DNS Name, IP or URI name must be present. a.b.foo.com,c.d.foo.com
csi.cert-manager.io/ip-sans IP addresses the certificate will be requested for. 192.0.0.1,192.0.0.2
csi.cert-manager.io/uri-sans URI names the certificate will be requested for. spiffe://foo.bar.cluster.local
csi.cert-manager.io/duration Requested duration the signed certificate will be valid for. 720h 1880h
csi.cert-manager.io/is-ca Mark the certificate as a certificate authority. false true
csi.cert-manager.io/key-usages Set the key usages on the certificate request. digital signature,key encipherment server auth,client auth
csi.cert-manager.io/key-encoding Set the key encoding format (PKCS1 or PKCS8). PKCS1 PKCS8
csi.cert-manager.io/certificate-file File name to store the certificate file at. tls.crt bar/foo.crt
csi.cert-manager.io/ca-file File name to store the ca certificate file at. ca.crt bar/foo.ca
csi.cert-manager.io/privatekey-file File name to store the key file at. tls.key bar/foo.key
csi.cert-manager.io/fs-group Set the FS Group of written files. Should be paired with and match the value of the consuming container runAsGroup. 2000
csi.cert-manager.io/renew-before The time to renew the certificate before expiry. Defaults to a third of the requested duration. $CERT_DURATION/3 72h
csi.cert-manager.io/reuse-private-key Re-use the same private when when renewing certificates. false true

Design Documents

csi-driver-1's People

Contributors

joshvanl avatar jetstack-bot avatar munnerz avatar basert avatar jakexks avatar irbekrm avatar charlieegan3 avatar gtaylor avatar sgtcodfish avatar rcanderson23 avatar mattiasgees avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.