Skip to content

Commit

Permalink
Reconcile Controller Plugin k8s Deployment
Browse files Browse the repository at this point in the history
Signed-off-by: nb-ohad <[email protected]>
  • Loading branch information
nb-ohad committed Jul 8, 2024
1 parent a2e5feb commit dd95cb8
Show file tree
Hide file tree
Showing 13 changed files with 9,470 additions and 4,825 deletions.
17 changes: 12 additions & 5 deletions api/v1alpha1/driver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ type EncryptionSpec struct {
ConfigMapRef corev1.LocalObjectReference `json:"configMapName,omitempty"`
}

type VolumeSepc struct {
Volume corev1.Volume `json:"volume,omitempty"`
Mount corev1.VolumeMount `json:"mount,omitempty"`
}

type PodCommonSpec struct {
// Pod's user defined priority class name
PrioritylClassName *string `json:"priorityClassName,omitempty"`
Expand All @@ -69,6 +74,12 @@ type PodCommonSpec struct {

// Pod's tolerations list
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// Volume and volume mount definitions to attach to the pod
Volumes []VolumeSepc `json:"volumes,omitempty"`

// To indicate the image pull policy to be applied to all the containers in the csi driver pods.
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy"`
}

type PluginResourcesSpec struct {
Expand All @@ -88,16 +99,11 @@ type PluginSpec struct {
// Resource requirements for plugin's containers
Resources PluginResourcesSpec `json:"resources,omitempty"`

Volumes []corev1.Volume `json:"volumes,omitempty"`

// kubelet directory path, if kubelet configured to use other than /var/lib/kubelet path.
KubeletDirPath string `json:"kubeletDirPath,omitempty"`

// Control the host mount of /etc/selinux for csi plugin pods. Defaults to false
EnableSeLinuxHostMount *bool `json:"EnableSeLinuxHostMount,omitempty"`

// To indicate the image pull policy to be applied to all the containers in the csi driver pods.
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy"`
}

type ProvisionerResourcesSpec struct {
Expand All @@ -107,6 +113,7 @@ type ProvisionerResourcesSpec struct {
Provisioner *corev1.ResourceRequirements `json:"provisioner,omitempty"`
OMapGenerator *corev1.ResourceRequirements `json:"omapGenerator,omitempty"`
Liveness *corev1.ResourceRequirements `json:"liveness,omitempty"`
Addons *corev1.ResourceRequirements `json:"Addons,omitempty"`
Plugin *corev1.ResourceRequirements `json:"plugin,omitempty"`
}

Expand Down
36 changes: 29 additions & 7 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6,651 changes: 4,276 additions & 2,375 deletions config/crd/bases/csi.ceph.io_drivers.yaml

Large diffs are not rendered by default.

6,630 changes: 4,289 additions & 2,341 deletions config/crd/bases/csi.ceph.io_operatorconfigs.yaml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ rules:
- patch
- update
- watch
- apiGroups:
- csi.ceph.io
resources:
- drivers/finalizers
verbs:
- update
- apiGroups:
- csi.ceph.io
resources:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module github.com/ceph/ceph-csi-operator

go 1.21
go 1.22

require (
github.com/go-logr/logr v1.4.1
github.com/onsi/ginkgo/v2 v2.14.0
github.com/onsi/gomega v1.30.0
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
k8s.io/api v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/client-go v0.29.2
Expand Down Expand Up @@ -49,7 +50,6 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sys v0.18.0 // indirect
Expand Down
56 changes: 17 additions & 39 deletions internal/controller/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ package controller
import (
"os"

storagev1 "k8s.io/api/storage/v1"
"k8s.io/utils/ptr"

csiv1a1 "github.com/ceph/ceph-csi-operator/api/v1alpha1"
"github.com/ceph/ceph-csi-operator/internal/utils"
)

var imageDefaults = map[string]string{
Expand All @@ -35,44 +33,24 @@ var imageDefaults = map[string]string{
"addons": "quay.io/csiaddons/k8s-sidecar:v0.8.0",
}

var driverDefaults = csiv1a1.DriverSpec{
EnableMetadata: ptr.To(false),
GRpcTimeout: 150,
SnapshotPolicy: csiv1a1.AutoDetectSnapshotPolicy,
GenerateOMapInfo: ptr.To(false),
FsGroupPolicy: storagev1.FileFSGroupPolicy,
AttachRequired: ptr.To(true),
DeployCsiAddons: ptr.To(false),
CephFsClientType: csiv1a1.KernelCephFsClient,
LeaderElection: &csiv1a1.LeaderElectionSpec{
LeaseDuration: 137,
RenewDeadline: 107,
RetryPeriod: 26,
},
Plugin: &csiv1a1.PluginSpec{
PodCommonSpec: csiv1a1.PodCommonSpec{
PrioritylClassName: ptr.To(""),
},
EnableSeLinuxHostMount: ptr.To(false),
},
Provisioner: &csiv1a1.ProvisionerSpec{
PodCommonSpec: csiv1a1.PodCommonSpec{
PrioritylClassName: ptr.To(""),
},
},
}

var operatorNamespace = ""
var operatorConfigName = ""
const GRpcTimeout = 150
const SnapshotPolicy = csiv1a1.AutoDetectSnapshotPolicy

func init() {
ok := false
var LeaderElectionDefaults = csiv1a1.LeaderElectionSpec{
LeaseDuration: 137,
RenewDeadline: 107,
RetryPeriod: 26,
}

if operatorNamespace, ok = os.LookupEnv("OPERATOR_NAMESPACE"); !ok {
var operatorNamespace = (func() string {
namespace, ok := os.LookupEnv("OPERATOR_NAMESPACE")
if !ok {
panic("Missing required OPERATOR_NAMESPACE environment variable")
}
return namespace
})()

if operatorConfigName, ok = os.LookupEnv("OPERATOR_CONFIG_NAME"); !ok {
operatorConfigName = "ceph-csi-operator-config"
}
}
var operatorConfigName = (func() string {
name, ok := os.LookupEnv("OPERATOR_CONFIG_NAME")
return utils.If(ok, name, "ceph-csi-operator-config")
})()
Loading

0 comments on commit dd95cb8

Please sign in to comment.