Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #267 from cofyc/rbd_provisioner_name
Browse files Browse the repository at this point in the history
RBD provisioner use provisioner name as identitiy by default instead of random string
  • Loading branch information
wongma7 authored Aug 2, 2017
2 parents d2377b0 + 01d0e6d commit a8de80c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
26 changes: 20 additions & 6 deletions ceph/rbd/cmd/rbd-provisioner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package main

import (
"flag"
"os"

"github.com/golang/glog"
"github.com/kubernetes-incubator/external-storage/ceph/rbd/pkg/provision"
"github.com/kubernetes-incubator/external-storage/lib/controller"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
Expand All @@ -35,6 +35,10 @@ var (
id = flag.String("id", "", "Unique provisioner identity")
)

const (
provisionerNameKey = "PROVISIONER_NAME"
)

func main() {
flag.Parse()
flag.Set("logtostderr", "true")
Expand All @@ -46,10 +50,6 @@ func main() {
} else {
config, err = rest.InClusterConfig()
}
prID := string(uuid.NewUUID())
if *id != "" {
prID = *id
}
if err != nil {
glog.Fatalf("Failed to create config: %v", err)
}
Expand All @@ -58,6 +58,20 @@ func main() {
glog.Fatalf("Failed to create client: %v", err)
}

prName := provision.ProvisionerName
prNameFromEnv := os.Getenv(provisionerNameKey)
if prNameFromEnv != "" {
prName = prNameFromEnv
}

// By default, we use provision name as provisioner identity.
// User may specify their own identity with `-id` flag to distinguish each
// others, if they deploy more than one RBD provisioners under same provisioner name.
prID := prName
if *id != "" {
prID = *id
}

// The controller needs to know what the server version is because out-of-tree
// provisioners aren't officially supported until 1.5
serverVersion, err := clientset.Discovery().ServerVersion()
Expand All @@ -74,7 +88,7 @@ func main() {
// PVs
pc := controller.NewProvisionController(
clientset,
provision.ProvisionerName,
prName,
rbdProvisioner,
serverVersion.GitVersion,
)
Expand Down
3 changes: 3 additions & 0 deletions ceph/rbd/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ spec:
containers:
- name: rbd-provisioner
image: "quay.io/external_storage/rbd-provisioner:latest"
env:
- name: PROVISIONER_NAME
value: ceph.com/rbd

0 comments on commit a8de80c

Please sign in to comment.