deploy: add CSIDriver for NFS

The API is extended for generation of the NFS CSIDriver object. The
YAML file under deploy/ was created by `yamlgen`.

The contents of the csidriver.yaml file is heavily based on the upstream
CSIDriver from the Kubernetes csi-driver-nfs project.

Because ./tools/yamlgen uses the API, it gets copied under vendor/ .
This causes two copies of the API to be included in the repository, but
that can not be prevented, it seems.

See-also: https://github.com/kubernetes-csi/csi-driver-nfs/blob/master/deploy/csi-nfs-driverinfo.yaml
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2022-03-02 09:32:01 +01:00
committed by mergify[bot]
parent 984119b30d
commit 87f87141be
9 changed files with 241 additions and 0 deletions

View File

@ -19,8 +19,10 @@ package main
import (
"fmt"
"os"
"path"
"reflect"
"github.com/ceph/ceph-csi/api/deploy/kubernetes/nfs"
"github.com/ceph/ceph-csi/api/deploy/kubernetes/rbd"
"github.com/ceph/ceph-csi/api/deploy/ocp"
)
@ -46,6 +48,11 @@ var yamlArtifacts = []deploymentArtifact{
reflect.ValueOf(ocp.NewSecurityContextConstraintsYAML),
reflect.ValueOf(ocp.SecurityContextConstraintsDefaults),
},
{
"../deploy/nfs/kubernetes/csidriver.yaml",
reflect.ValueOf(nfs.NewCSIDriverYAML),
reflect.ValueOf(nfs.CSIDriverDefaults),
},
{
"../deploy/rbd/kubernetes/csidriver.yaml",
reflect.ValueOf(rbd.NewCSIDriverYAML),
@ -67,6 +74,15 @@ func main() {
func writeArtifact(artifact deploymentArtifact) {
fmt.Printf("creating %q...", artifact.filename)
dir := path.Dir(artifact.filename)
_, err := os.Stat(dir)
if os.IsNotExist(err) {
err = os.MkdirAll(dir, 0o775)
if err != nil {
panic(fmt.Sprintf("failed to create directory %q: %v", dir, err))
}
}
f, err := os.Create(artifact.filename)
if err != nil {
panic(fmt.Sprintf("failed to create file %q: %v", artifact.filename, err))