mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-11 22:10:11 +01:00
Usecase: A node in the Kubernetes cluster is replaced with a new node. The new node gets a different `kubernetes.io/hostname`. The storage devices that were attached to the old node are re-attached to the new node. Fix: Instead of using the default `kubenetes.io/hostname` as the node affinity label, this commit changes to use `openebs.io/nodeid`. The ZFS LocalPV driver will pick the value from the nodes and set the affinity. Once the old node is removed from the cluster, the K8s scheduler will continue to schedule applications on the old node only. User can now modify the value of `openebs.io/nodeid` on the new node to the same value that was available on the old node. This will make sure the pods/volumes are scheduled to the node now. Note: Now to migrate the PV to the other node, we have to move the disks to the other node and remove the old node from the cluster and set the same label on the new node using the same key, which will let k8s scheduler to schedule the pods to that node. Other updates: * adding faq doc * renaming the config variable to nodename Signed-off-by: Pawan <pawan@mayadata.io> Co-authored-by: Akhil Mohan <akhilerm@gmail.com> * Update docs/faq.md Co-authored-by: Akhil Mohan <akhilerm@gmail.com>
103 lines
2.6 KiB
Go
103 lines
2.6 KiB
Go
/*
|
|
Copyright © 2020 The OpenEBS 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 (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
config "github.com/openebs/zfs-localpv/pkg/config"
|
|
"github.com/openebs/zfs-localpv/pkg/driver"
|
|
"github.com/openebs/zfs-localpv/pkg/version"
|
|
zfs "github.com/openebs/zfs-localpv/pkg/zfs"
|
|
"github.com/spf13/cobra"
|
|
"k8s.io/klog"
|
|
)
|
|
|
|
/*
|
|
* main routine to start the zfs-driver. The same
|
|
* binary is used to controller and agent deployment.
|
|
* they both are differentiated via plugin command line
|
|
* argument. To start the controller, we have to pass
|
|
* --plugin=controller and to start it as agent, we have
|
|
* to pass --plugin=agent.
|
|
*/
|
|
func main() {
|
|
_ = flag.CommandLine.Parse([]string{})
|
|
var config = config.Default()
|
|
|
|
cmd := &cobra.Command{
|
|
Use: "zfs-driver",
|
|
Short: "driver for provisioning zfs volume",
|
|
Long: `provisions and deprovisions the volume
|
|
on the node which has zfs pool configured.`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
run(config)
|
|
},
|
|
}
|
|
|
|
cmd.Flags().AddGoFlagSet(flag.CommandLine)
|
|
|
|
cmd.PersistentFlags().StringVar(
|
|
&config.Nodename, "nodename", zfs.NodeID, "Nodename to identify the node running this driver",
|
|
)
|
|
|
|
cmd.PersistentFlags().StringVar(
|
|
&config.Version, "version", "", "Displays driver version",
|
|
)
|
|
|
|
cmd.PersistentFlags().StringVar(
|
|
&config.Endpoint, "endpoint", "unix://csi/csi.sock", "CSI endpoint",
|
|
)
|
|
|
|
cmd.PersistentFlags().StringVar(
|
|
&config.DriverName, "name", "zfs.csi.openebs.io", "Name of this driver",
|
|
)
|
|
|
|
cmd.PersistentFlags().StringVar(
|
|
&config.PluginType, "plugin", "csi-plugin", "Type of this driver i.e. controller or node",
|
|
)
|
|
|
|
err := cmd.Execute()
|
|
if err != nil {
|
|
_, _ = fmt.Fprintf(os.Stderr, "%s", err.Error())
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func run(config *config.Config) {
|
|
if config.Version == "" {
|
|
config.Version = version.Current()
|
|
}
|
|
|
|
klog.Infof("ZFS Driver Version :- %s - commit :- %s", version.Current(), version.GetGitCommit())
|
|
klog.Infof(
|
|
"DriverName: %s Plugin: %s EndPoint: %s Node Name: %s",
|
|
config.DriverName,
|
|
config.PluginType,
|
|
config.Endpoint,
|
|
config.Nodename,
|
|
)
|
|
|
|
err := driver.New(config).Run()
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
os.Exit(0)
|
|
}
|