Skip to content

Commit

Permalink
Merge pull request #309 from jacobwolfaws/master
Browse files Browse the repository at this point in the history
Adopting Multiple CSI Driver improvements
  • Loading branch information
k8s-ci-robot committed May 16, 2023
2 parents f911bac + 770a2c6 commit 20d5b32
Show file tree
Hide file tree
Showing 1,202 changed files with 1,674 additions and 639,131 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
*.swp
bin/
*~

# Vendor dir
vendor/

7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION=v0.9.0
VERSION?=v0.9.0

PKG=github.com/kubernetes-sigs/aws-fsx-csi-driver
PKG=sigs.k8s.io/aws-fsx-csi-driver
GIT_COMMIT?=$(shell git rev-parse HEAD)
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")

LDFLAGS?="-X ${PKG}/pkg/driver.driverVersion=${VERSION} -X ${PKG}/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/driver.buildDate=${BUILD_DATE}"
LDFLAGS?="-X ${PKG}/pkg/driver.driverVersion=${VERSION} -X ${PKG}/pkg/cloud.driverVersion=${VERSION} -X ${PKG}/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/driver.buildDate=${BUILD_DATE} -s -w"

GO111MODULE=on
GOPROXY=direct
Expand Down Expand Up @@ -108,6 +108,7 @@ verify:
.PHONY: test
test:
go test -v -race ./pkg/...
go test -v ./cmd/...
go test -v ./tests/sanity/...

.PHONY: test-e2e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ spec:
image: {{ printf "%s:%s" .Values.image.repository (default (printf "v%s" .Chart.AppVersion) (toString .Values.image.tag)) }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- --mode={{ .Values.controller.mode }}
- --endpoint=$(CSI_ENDPOINT)
- --logging-format={{ .Values.controller.loggingFormat }}
- --v={{ .Values.controller.logLevel }}
env:
- name: CSI_ENDPOINT
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
- name: CSI_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
Expand Down Expand Up @@ -87,6 +94,7 @@ spec:
image: {{ printf "%s:%s" .Values.sidecars.provisioner.image.repository .Values.sidecars.provisioner.image.tag }}
args:
- --csi-address=$(ADDRESS)
- --v={{ .Values.sidecars.provisioner.logLevel }}
- --timeout=5m
- --extra-create-metadata
- --leader-election=true
Expand All @@ -104,6 +112,7 @@ spec:
image: {{ printf "%s:%s" .Values.sidecars.resizer.image.repository .Values.sidecars.resizer.image.tag }}
args:
- --csi-address=$(ADDRESS)
- --v={{ .Values.sidecars.resizer.logLevel }}
- --leader-election=true
- --timeout=5m
env:
Expand Down
8 changes: 8 additions & 0 deletions charts/aws-fsx-csi-driver/templates/node-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@ spec:
image: {{ printf "%s:%s" .Values.image.repository (default (printf "v%s" .Chart.AppVersion) (toString .Values.image.tag)) }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- --mode={{ .Values.node.mode }}
- --endpoint=$(CSI_ENDPOINT)
- --logging-format={{ .Values.node.loggingFormat }}
- --v={{ .Values.node.logLevel }}
env:
- name: CSI_ENDPOINT
value: unix:/csi/csi.sock
- name: CSI_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- name: kubelet-dir
mountPath: /var/lib/kubelet
Expand Down Expand Up @@ -89,6 +96,7 @@ spec:
args:
- --csi-address=$(ADDRESS)
- --kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)
- --v={{ .Values.sidecars.nodeDriverRegistrar.logLevel }}
env:
- name: ADDRESS
value: /csi/csi.sock
Expand Down
9 changes: 9 additions & 0 deletions charts/aws-fsx-csi-driver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,26 @@ sidecars:
repository: public.ecr.aws/eks-distro/kubernetes-csi/node-driver-registrar
tag: v2.7.0-eks-1-23-13
pullPolicy: IfNotPresent
logLevel: 2
resources: {}
provisioner:
image:
repository: public.ecr.aws/eks-distro/kubernetes-csi/external-provisioner
tag: v3.4.0-eks-1-23-13
pullPolicy: IfNotPresent
logLevel: 2
resources: {}
resizer:
image:
repository: public.ecr.aws/eks-distro/kubernetes-csi/external-resizer
tag: v1.7.0-eks-1-23-13
pullPolicy: IfNotPresent
logLevel: 2
resources: {}

controller:
mode: controller
loggingFormat: text
nodeSelector: {}
replicaCount: 2
resources: {}
Expand All @@ -48,9 +53,13 @@ controller:
name: fsx-csi-controller-sa
annotations: {}
tolerations: []
logLevel: 2
podAnnotations: {}

node:
mode: node
loggingFormat: text
logLevel: 2
nodeSelector: {}
resources: {}
dnsPolicy: ClusterFirst
Expand Down
39 changes: 20 additions & 19 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,34 @@ limitations under the License.
package main

import (
"flag"
"fmt"
"os"
flag "github.com/spf13/pflag"
logsapi "k8s.io/component-base/logs/api/v1"
json "k8s.io/component-base/logs/json"

"k8s.io/klog/v2"
"sigs.k8s.io/aws-fsx-csi-driver/pkg/driver"
)

func main() {
var (
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI Endpoint")
version = flag.Bool("version", false, "Print the version and exit")
)
klog.InitFlags(nil)
flag.Parse()

if *version {
info, err := driver.GetVersionJSON()
if err != nil {
klog.Fatalln(err)
}
fmt.Println(info)
os.Exit(0)
fs := flag.NewFlagSet("aws-fsx-csi-driver", flag.ExitOnError)

if err := logsapi.RegisterLogFormat(logsapi.JSONLogFormat, json.Factory{}, logsapi.LoggingBetaOptions); err != nil {
klog.ErrorS(err, "failed to register JSON log format")
}

drv := driver.NewDriver(*endpoint)
options := GetOptions(fs)

drv, err := driver.NewDriver(
driver.WithEndpoint(options.ServerOptions.Endpoint),
driver.WithMode(options.ServerOptions.DriverMode),
)

if err != nil {
klog.ErrorS(err, "failed to create driver")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}
if err := drv.Run(); err != nil {
klog.Fatalln(err)
klog.ErrorS(err, "failed to run driver")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}
}
108 changes: 108 additions & 0 deletions cmd/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"fmt"
flag "github.com/spf13/pflag"
"k8s.io/component-base/featuregate"
logsapi "k8s.io/component-base/logs/api/v1"
"k8s.io/klog/v2"
"os"
"sigs.k8s.io/aws-fsx-csi-driver/cmd/options"
"sigs.k8s.io/aws-fsx-csi-driver/pkg/driver"
)

// Options is the combined set of options for all operating modes.
type Options struct {
*options.ServerOptions
*options.ControllerOptions
*options.NodeOptions
}

// used for testing
var osExit = os.Exit

var featureGate = featuregate.NewFeatureGate()

func GetOptions(fs *flag.FlagSet) *Options {
var (
version = fs.Bool("version", false, "Print the version and exit.")
toStderr = fs.Bool("logtostderr", false, "log to standard error instead of files. DEPRECATED: will be removed in a future release.")

args = os.Args[1:]

serverOptions = options.ServerOptions{}
controllerOptions = options.ControllerOptions{}
nodeOptions = options.NodeOptions{}
)

mode := serverOptions.AddFlags(fs)

c := logsapi.NewLoggingConfiguration()

err := logsapi.AddFeatureGates(featureGate)
if err != nil {
klog.ErrorS(err, "failed to add feature gates")
}

logsapi.AddFlags(c, fs)

switch {
case mode == driver.ControllerMode:
controllerOptions.AddFlags(fs)

case mode == driver.NodeMode:
nodeOptions.AddFlags(fs)

case mode == driver.AllMode:
controllerOptions.AddFlags(fs)
nodeOptions.AddFlags(fs)
default:
fmt.Printf("unknown command: %s: expected %q, %q or %q", mode, driver.ControllerMode, driver.NodeMode, driver.AllMode)
os.Exit(1)
}

if err := fs.Parse(args); err != nil {
panic(err)
}

err = logsapi.ValidateAndApply(c, featureGate)
if err != nil {
klog.ErrorS(err, "failed to validate and apply logging configuration")
}

if *version {
versionInfo, err := driver.GetVersionJSON()
if err != nil {
klog.ErrorS(err, "failed to get version")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}
fmt.Println(versionInfo)
osExit(0)
}

if *toStderr {
klog.SetOutput(os.Stderr)
}

return &Options{
ServerOptions: &serverOptions,
ControllerOptions: &controllerOptions,
NodeOptions: &nodeOptions,
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,5 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package exec provides an injectable interface and implementations for running commands.
package exec // import "k8s.io/utils/exec"
package options

import (
flag "github.com/spf13/pflag"
)

// ControllerOptions contains options and configuration settings for the controller service.
type ControllerOptions struct {
}

func (s *ControllerOptions) AddFlags(fs *flag.FlagSet) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright 2011-2016 Canonical Ltd.
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -11,3 +12,13 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package options

import (
"testing"
)

func TestControllerOptions(t *testing.T) {
}
16 changes: 13 additions & 3 deletions vendor/k8s.io/mount-utils/doc.go → cmd/options/node_options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2014 The Kubernetes Authors.
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,5 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package mount defines an interface to mounting filesystems.
package mount // import "k8s.io/mount-utils"
package options

import (
flag "github.com/spf13/pflag"
)

// NodeOptions contains options and configuration settings for the node service.
type NodeOptions struct {
}

func (o *NodeOptions) AddFlags(fs *flag.FlagSet) {
}
Loading

0 comments on commit 20d5b32

Please sign in to comment.