Documentation
¶
Index ¶
- Variables
- func CreateUpgradeConfig(ctx context.Context, client *k8s.K8sClient, configName string, ...) (*corev1.ConfigMap, error)
- func GenAuthCmd(secrets map[string]string, setting *JfsSetting) (args []string, cmdArgs []string, err error)
- func GenCacheDirs(jfsSetting *JfsSetting, volCtx map[string]string) error
- func GenFormatCmd(secrets map[string]string, noUpdate bool, setting *JfsSetting) (args []string, cmdArgs []string, err error)
- func GenHashOfSetting(log klog.Logger, setting JfsSetting) string
- func GenPodAttrWithCfg(setting *JfsSetting, volCtx map[string]string) error
- func GetDiff(mountPod *corev1.Pod, pvc *corev1.PersistentVolumeClaim, ...) (old *MountPodPatch, oldSetting *JfsSetting, new *MountPodPatch, ...)
- func GetGlobalConfigName() string
- func GetJfsVolUUID(ctx context.Context, s *JfsSetting) (string, error)
- func GetPodLock(podHashVal string) *sync.Mutex
- func GetPodLockKey(pod *corev1.Pod, newHash string) string
- func IsCEMountPod(pod *corev1.Pod) bool
- func IsInterVolume(name string) bool
- func LoadConfig(configPath string) error
- func LoadFromConfigMap(ctx context.Context, client *k8s.K8sClient) error
- func MustGetWebPort() int
- func ParsePodResources(cpuLimit, memoryLimit, cpuRequest, memoryRequest string, ...) (corev1.ResourceRequirements, error)
- func ParseYamlOrJson(source string, dst interface{}) error
- func StartConfigReloader(configPath string) error
- func UpdateUpgradeConfig(ctx context.Context, client *k8s.K8sClient, configName string, ...) (*corev1.ConfigMap, error)
- type AppInfo
- type BatchConfig
- type CacheEmptyDir
- type CacheInlineVolume
- type CachePVC
- type Config
- type JfsSetting
- func GenSettingAttrWithMountPod(ctx context.Context, client *k8sclient.K8sClient, mountPod *corev1.Pod) (*JfsSetting, error)
- func ParseSetting(ctx context.Context, secrets, volCtx map[string]string, options []string, ...) (*JfsSetting, error)
- func RevertSetting(mountPod *corev1.Pod, pvc *corev1.PersistentVolumeClaim, ...) (*JfsSetting, error)
- func (s *JfsSetting) Load(str string) error
- func (s *JfsSetting) ParseFormatOptions() ([][]string, error)
- func (s *JfsSetting) ReNew(mountPod *corev1.Pod, pvc *corev1.PersistentVolumeClaim, ...) error
- func (s *JfsSetting) RepresentFormatOptions(parsedOptions [][]string) []string
- func (s *JfsSetting) Safe() *JfsSetting
- func (s *JfsSetting) SafeString() string
- func (s *JfsSetting) String() string
- func (s *JfsSetting) StripFormatOptions(parsedOptions [][]string, strippedKeys []string) []string
- type MountPatchCacheDir
- type MountPatchCacheDirType
- type MountPodPatch
- type MountPodUpgrade
- type PVCSelector
- type PodAttr
- type UpgradeStatus
Constants ¶
This section is empty.
Variables ¶
var ( WebPort = MustGetWebPort() // web port used by metrics ByProcess = false // csi driver runs juicefs in process or not Provisioner = false // provisioner in controller CacheClientConf = false // cache client config files and use directly in mount containers MountManager = false // manage mount pod in controller (only in k8s) Webhook = false // start webhook server, used in sidecar mode or validating/mutating webhook ValidatingWebhook = false // start validating webhook, applicable to ee only Immutable = false // csi driver is running in an immutable environment AccessToKubelet = false // access kubelet or not DriverName = "csi.juicefs.com" NodeName = "" Namespace = "" PodName = "" HostIp = "" KubeletPort = "" ReconcileTimeout = 5 * time.Minute ReconcilerInterval = 5 SecretReconcilerInterval = 1 * time.Hour CSIPod = corev1.Pod{} MountPointPath = "/var/lib/juicefs/volume" JFSConfigPath = "/var/lib/juicefs/config" JFSMountPriorityName = "system-node-critical" JFSMountPreemptionPolicy = "" TmpPodMountBase = "/tmp" PodMountBase = "/jfs" MountBase = "/var/lib/jfs" FsType = "juicefs" CliPath = "/usr/bin/juicefs" CeCliPath = "/usr/local/bin/juicefs" CeMountPath = "/bin/mount.juicefs" JfsMountPath = "/sbin/mount.juicefs" DefaultClientConfPath = "/root/.juicefs" ROConfPath = "/etc/juicefs" ShutdownSockPath = "/tmp/juicefs-csi-shutdown.sock" JfsFuseFdPathName = "jfs-fuse-fd" DefaultCEMountImage = "juicedata/mount:ce-nightly" // mount pod ce image, override by ENV DefaultEEMountImage = "juicedata/mount:ee-nightly" // mount pod ee image, override by ENV BuiltinCeVersion = "nightly" BuiltinEeVersion = "nightly" )
var CSISetEnvMap = map[string]interface{}{ "_JFS_META_SID": nil, "JFS_NO_UMOUNT": nil, "JFS_NO_UPDATE": nil, "JFS_FOREGROUND": nil, "JFS_SUPER_COMM": nil, "JFS_INSIDE_CONTAINER": nil, "JUICEFS_CLIENT_PATH": nil, "JUICEFS_CLIENT_SIDERCAR_CONTAINER": nil, "JFS_NO_CHECK_OBJECT_STORAGE": nil, }
env auto set by the csi side
var CSISetOptsMap = map[string]interface{}{ "no-update": nil, "foreground": nil, "metrics": nil, "rsa-key": nil, }
opts auto set by the csi side
var GlobalConfig = newCfg()
var PodLocks [1024]sync.Mutex
Functions ¶
func CreateUpgradeConfig ¶ added in v0.26.0
func GenAuthCmd ¶ added in v0.26.0
func GenAuthCmd(secrets map[string]string, setting *JfsSetting) (args []string, cmdArgs []string, err error)
args: the real args running in csi cmdArgs: the args in mount pod which using stripped value with env
func GenCacheDirs ¶ added in v0.25.2
func GenCacheDirs(jfsSetting *JfsSetting, volCtx map[string]string) error
func GenFormatCmd ¶ added in v0.26.0
func GenHashOfSetting ¶ added in v0.26.0
func GenHashOfSetting(log klog.Logger, setting JfsSetting) string
func GenPodAttrWithCfg ¶ added in v0.24.0
func GenPodAttrWithCfg(setting *JfsSetting, volCtx map[string]string) error
func GetDiff ¶ added in v0.26.0
func GetDiff(mountPod *corev1.Pod, pvc *corev1.PersistentVolumeClaim, pv *corev1.PersistentVolume, secret, custSecret *corev1.Secret) (old *MountPodPatch, oldSetting *JfsSetting, new *MountPodPatch, newSetting *JfsSetting, err error)
func GetGlobalConfigName ¶ added in v0.28.0
func GetGlobalConfigName() string
func GetJfsVolUUID ¶ added in v0.27.0
func GetJfsVolUUID(ctx context.Context, s *JfsSetting) (string, error)
GetJfsVolUUID get UUID from result of `juicefs status <volumeName>`
func GetPodLock ¶
func IsCEMountPod ¶ added in v0.24.3
IsCEMountPod check if the pod is a mount pod of CE check mountpod command's has metaurl
func IsInterVolume ¶ added in v0.24.5
func LoadConfig ¶ added in v0.24.0
func LoadFromConfigMap ¶ added in v0.25.0
func MustGetWebPort ¶ added in v0.23.4
func MustGetWebPort() int
func ParsePodResources ¶ added in v0.23.4
func ParsePodResources(cpuLimit, memoryLimit, cpuRequest, memoryRequest string, defaultResources corev1.ResourceRequirements) (corev1.ResourceRequirements, error)
func ParseYamlOrJson ¶ added in v0.23.4
func StartConfigReloader ¶ added in v0.24.0
ConfigReloader reloads config file when it is updated
Types ¶
type BatchConfig ¶ added in v0.26.0
type BatchConfig struct {
Parallel int `json:"parallel"`
IgnoreError bool `json:"ignoreError"`
NoRecreate bool `json:"norecreate,omitempty"`
Node string `json:"node,omitempty"`
UniqueId string `json:"uniqueId,omitempty"`
Batches [][]MountPodUpgrade `json:"batches"`
Status UpgradeStatus `json:"status"`
}
func LoadBatchConfig ¶ added in v0.26.0
func LoadBatchConfig(cm *corev1.ConfigMap) (*BatchConfig, error)
func LoadUpgradeConfig ¶ added in v0.26.0
type CacheEmptyDir ¶ added in v0.23.1
type CacheInlineVolume ¶ added in v0.23.1
type CacheInlineVolume struct {
CSI *corev1.CSIVolumeSource
Path string
}
type Config ¶ added in v0.24.0
type Config struct {
// arrange mount pod to node with node selector instead nodeName
EnableNodeSelector bool `json:"enableNodeSelector,omitempty"`
// in sidecar mode, use k8s native sidecar instead of container
// If the k8s version is 1.29 and later, the default is true.
EnableNativeSidecar *bool `json:"enableNativeSidecar,omitempty"`
// enable set quota in controller (CreateVolume/Provisioner)
// if enabled, SetQuota will be called in controller
// if disabled, SetQuota will be called in node (NodePublishVolume)
EnableControllerSetQuota *bool `json:"enableControllerSetQuota,omitempty"`
MountPodPatch []MountPodPatch `json:"mountPodPatch"`
}
TODO: migrate more config for here
func (*Config) GenMountPodPatch ¶ added in v0.24.0
func (c *Config) GenMountPodPatch(setting JfsSetting) MountPodPatch
GenMountPodPatch generate mount pod patch from jfsSettting 1. match pv selector 2. parse template value 3. return the merged mount pod patch
type JfsSetting ¶
type JfsSetting struct {
HashVal string `json:"-"`
UpgradeUUID string `json:"-"`
JuiceFSSecret *corev1.Secret `json:"-"`
CustomerSecret *corev1.Secret `json:"-"`
IsCe bool
UsePod bool
UUID string
Name string `json:"name"`
MetaUrl string `json:"metaurl"`
Source string `json:"source"`
Storage string `json:"storage"`
FormatOptions string `json:"format-options"`
CachePVCs []CachePVC // PVC using by mount pod
CacheEmptyDir *CacheEmptyDir // EmptyDir using by mount pod
CacheInlineVolumes []*CacheInlineVolume // InlineVolume using by mount pod
CacheDirs []string // hostPath using by mount pod
ClientConfPath string `json:"-"`
// put in secret
SecretKey string `json:"secret-key,omitempty"`
SecretKey2 string `json:"secret-key2,omitempty"`
Token string `json:"token,omitempty"`
Passphrase string `json:"passphrase,omitempty"`
Envs map[string]string `json:"envs_map,omitempty"`
EncryptRsaKey string `json:"encrypt_rsa_key,omitempty"`
InitConfig string `json:"initconfig,omitempty"`
Configs map[string]string `json:"configs_map,omitempty"`
// put in volCtx
DeletedDelay string `json:"deleted_delay"`
CleanCache bool `json:"clean_cache"`
HostPath []string `json:"host_path"`
// mount
VolumeId string // volumeHandle of PV
UniqueId string // mount pod name is generated by uniqueId
MountPath string // mountPath of mount pod or process mount
TargetPath string `json:"-"` // which bind to container path
Options []string // mount options
FormatCmd string // format or auth
SubPath string // subPath which is to be created or deleted
SecretName string // secret with JuiceFS volume credentials
Attr *PodAttr
PV *corev1.PersistentVolume `json:"-"`
PVC *corev1.PersistentVolumeClaim `json:"-"`
}
func GenSettingAttrWithMountPod ¶ added in v0.25.2
func GenSettingAttrWithMountPod(ctx context.Context, client *k8sclient.K8sClient, mountPod *corev1.Pod) (*JfsSetting, error)
GenSettingAttrWithMountPod generate pod attr with mount pod Return the latest pod attributes following the priorities below:
1. original mount pod 2. pvc annotations 3. global config
func ParseSetting ¶
func ParseSetting(ctx context.Context, secrets, volCtx map[string]string, options []string, volumeId, uniqueId, uuid string, pv *corev1.PersistentVolume, pvc *corev1.PersistentVolumeClaim) (*JfsSetting, error)
ParseSetting parse the setting from secrets and volCtx, the original entrance of parsing setting secrets: the customs secrets volCtx: the volume context in pv options: the mount options volumeId: the volumeHandle of PV uniqueId: the uniqueId of mount pod (volumeId or storageClass name) uuid: uuid of juicefs volume (volume name in ee and uuid in ce). if empty, will be generated by `juicefs status <volumeName>` pv: the PersistentVolume pvc: the PersistentVolumeClaim
func RevertSetting ¶ added in v0.27.0
func RevertSetting(mountPod *corev1.Pod, pvc *corev1.PersistentVolumeClaim, pv *corev1.PersistentVolume, pvcSecret, custSecret *corev1.Secret) (*JfsSetting, error)
RevertSetting revert the original jfs setting 1. try to get settings from pv secret 2. try to parse settings from pv, pvc and custom secret 3. if no custom secret or pvc/pv, generate settings from mount pod
func (*JfsSetting) Load ¶ added in v0.26.0
func (s *JfsSetting) Load(str string) error
func (*JfsSetting) ParseFormatOptions ¶ added in v0.17.1
func (s *JfsSetting) ParseFormatOptions() ([][]string, error)
func (*JfsSetting) ReNew ¶ added in v0.27.0
func (s *JfsSetting) ReNew(mountPod *corev1.Pod, pvc *corev1.PersistentVolumeClaim, pv *corev1.PersistentVolume, custSecret *corev1.Secret) error
ReNew update setting with new pod, pvc, pv and customs secret
func (*JfsSetting) RepresentFormatOptions ¶ added in v0.17.1
func (s *JfsSetting) RepresentFormatOptions(parsedOptions [][]string) []string
func (*JfsSetting) Safe ¶ added in v0.26.0
func (s *JfsSetting) Safe() *JfsSetting
func (*JfsSetting) SafeString ¶ added in v0.26.0
func (s *JfsSetting) SafeString() string
func (*JfsSetting) String ¶ added in v0.26.0
func (s *JfsSetting) String() string
func (*JfsSetting) StripFormatOptions ¶ added in v0.17.1
func (s *JfsSetting) StripFormatOptions(parsedOptions [][]string, strippedKeys []string) []string
type MountPatchCacheDir ¶ added in v0.25.1
type MountPatchCacheDir struct {
Type MountPatchCacheDirType `json:"type,omitempty"`
// required for HostPath type
Path string `json:"path,omitempty"`
// required for PVC type
Name string `json:"name,omitempty"`
// Required for EmptyDir type
SizeLimit *resource.Quantity `json:"sizeLimit,omitempty"`
Medium corev1.StorageMedium `json:"medium,omitempty"`
}
type MountPatchCacheDirType ¶ added in v0.25.1
type MountPatchCacheDirType string
var ( MountPatchCacheDirTypeHostPath MountPatchCacheDirType = "HostPath" MountPatchCacheDirTypePVC MountPatchCacheDirType = "PVC" MountPatchCacheDirTypeEmptyDir MountPatchCacheDirType = "EmptyDir" )
type MountPodPatch ¶ added in v0.24.0
type MountPodPatch struct {
// used to specify the selector for the PVC that will be patched
// omit will patch for all PVC
PVCSelector *PVCSelector `json:"pvcSelector,omitempty"`
CEMountImage string `json:"ceMountImage,omitempty"`
EEMountImage string `json:"eeMountImage,omitempty"`
CacheDirs []MountPatchCacheDir `json:"cacheDirs,omitempty"`
Image string `json:"-"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
HostNetwork *bool `json:"hostNetwork,omitempty" `
HostPID *bool `json:"hostPID,omitempty" `
HostnameKey string `json:"hostnameKey,omitempty"`
LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty"`
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty"`
StartupProbe *corev1.Probe `json:"startupProbe,omitempty"`
Lifecycle *corev1.Lifecycle `json:"lifecycle,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
Volumes []corev1.Volume `json:"volumes,omitempty"`
VolumeDevices []corev1.VolumeDevice `json:"volumeDevices,omitempty"`
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
Env []corev1.EnvVar `json:"env,omitempty"`
MountOptions []string `json:"mountOptions,omitempty"`
}
type MountPodUpgrade ¶ added in v0.26.0
type MountPodUpgrade struct {
Name string `json:"name"`
Node string `json:"node"`
CSINodePod string `json:"csiNodePod"`
Status UpgradeStatus `json:"status"`
}
type PVCSelector ¶ added in v0.24.3
type PVCSelector struct {
metav1.LabelSelector
MatchStorageClassName string `json:"matchStorageClassName,omitempty"`
MatchName string `json:"matchName,omitempty"`
}
type PodAttr ¶ added in v0.16.0
type PodAttr struct {
Namespace string
MountPointPath string
JFSConfigPath string
JFSMountPriorityName string
ServiceAccountName string
Resources corev1.ResourceRequirements
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty"`
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty"`
StartupProbe *corev1.Probe `json:"startupProbe,omitempty"`
Lifecycle *corev1.Lifecycle `json:"lifecycle,omitempty"`
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
Volumes []corev1.Volume `json:"volumes,omitempty"`
VolumeDevices []corev1.VolumeDevice `json:"volumeDevices,omitempty"`
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
Env []corev1.EnvVar `json:"env,omitempty"`
CacheDirs []MountPatchCacheDir `json:"cacheDirs,omitempty"`
HostnameKey string `json:"-"`
// inherit from csi
Image string
HostNetwork bool
HostAliases []corev1.HostAlias
HostPID bool
HostIPC bool
DNSConfig *corev1.PodDNSConfig
DNSPolicy corev1.DNSPolicy
ImagePullSecrets []corev1.LocalObjectReference
PreemptionPolicy *corev1.PreemptionPolicy
Tolerations []corev1.Toleration
}
type UpgradeStatus ¶ added in v0.26.0
type UpgradeStatus string
const ( Pending UpgradeStatus = "pending" Running UpgradeStatus = "running" Success UpgradeStatus = "success" Fail UpgradeStatus = "fail" Stop UpgradeStatus = "stop" Pause UpgradeStatus = "pause" )