Skip to content

Commit

Permalink
fix: kubectl plugin updates (#472)
Browse files Browse the repository at this point in the history
Fix Tenant creation to include Users field & update the
Statik file. Also other community bug fixes.

Fixes #467
Fixes #462
  • Loading branch information
nitisht authored Feb 18, 2021
1 parent 830b2dc commit 666c527
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/minio/controller-tools v0.4.7 // indirect
github.com/minio/minio v0.0.0-20210128013121-e79829b5b368
github.com/minio/minio-go/v7 v7.0.8-0.20210127003153-c40722862654
github.com/rakyll/statik v0.1.7 // indirect
github.com/secure-io/sio-go v0.3.1 // indirect
github.com/stretchr/testify v1.6.1
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,8 @@ github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI=
github.com/quasilyte/go-ruleguard v0.1.2-0.20200318202121-b00d7a75d3d8/go.mod h1:CGFX09Ci3pq9QZdj86B+VGIdNj4VyCo2iPOGS9esB/k=
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
Expand Down
12 changes: 6 additions & 6 deletions kubectl-minio/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,20 @@ func (o *deleteCmd) run() error {
// Load Resources
emfs, decode := resources.GetFSAndDecoder()
crdObj := resources.LoadTenantCRD(emfs, decode)
if err := extclient.ApiextensionsV1().CustomResourceDefinitions().Delete(context.Background(), crdObj.Name, v1.DeleteOptions{}); err != nil {
if err := client.CoreV1().ServiceAccounts(o.operatorOpts.Namespace).Delete(context.Background(), helpers.DefaultServiceAccount, v1.DeleteOptions{}); err != nil {
return err
}
crObj := resources.LoadClusterRole(emfs, decode)
if err := client.RbacV1().ClusterRoles().Delete(context.Background(), crObj.Name, v1.DeleteOptions{}); err != nil {
if err := client.AppsV1().Deployments(o.operatorOpts.Namespace).Delete(context.Background(), helpers.DeploymentName, v1.DeleteOptions{}); err != nil {
return err
}
if err := client.CoreV1().ServiceAccounts(o.operatorOpts.Namespace).Delete(context.Background(), helpers.DefaultServiceAccount, v1.DeleteOptions{}); err != nil {
if err := extclient.ApiextensionsV1().CustomResourceDefinitions().Delete(context.Background(), crdObj.Name, v1.DeleteOptions{}); err != nil {
return err
}
if err := client.RbacV1().ClusterRoleBindings().Delete(context.Background(), helpers.ClusterRoleBindingName, v1.DeleteOptions{}); err != nil {
crObj := resources.LoadClusterRole(emfs, decode)
if err := client.RbacV1().ClusterRoles().Delete(context.Background(), crObj.Name, v1.DeleteOptions{}); err != nil {
return err
}
if err := client.AppsV1().Deployments(o.operatorOpts.Namespace).Delete(context.Background(), helpers.DeploymentName, v1.DeleteOptions{}); err != nil {
if err := client.RbacV1().ClusterRoleBindings().Delete(context.Background(), helpers.ClusterRoleBindingName, v1.DeleteOptions{}); err != nil {
return err
}
consoleResources := resources.LoadConsoleUI(emfs, decode, &o.operatorOpts)
Expand Down
15 changes: 15 additions & 0 deletions kubectl-minio/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (o *operatorInitCmd) run() error {
crb := resources.NewCluterRoleBindingForOperator(helpers.DefaultServiceAccount, o.operatorOpts.Namespace)
d := resources.NewDeploymentForOperator(o.operatorOpts)
svc := resources.NewServiceForOperator(o.operatorOpts)
ns := resources.NewNamespaceForOperator(o.operatorOpts.Namespace)
// Load Resources
emfs, decode := resources.GetFSAndDecoder()
crdObj := resources.LoadTenantCRD(emfs, decode)
Expand All @@ -115,6 +116,9 @@ func (o *operatorInitCmd) run() error {
if err != nil {
return err
}
if err = createNamespace(client, ns); err != nil {
return err
}
if err = createCRD(extclient, crdObj); err != nil {
return err
}
Expand Down Expand Up @@ -292,3 +296,14 @@ func createService(client *kubernetes.Clientset, svc *corev1.Service) error {
fmt.Printf("MinIO Operator Service %s: created\n", svc.ObjectMeta.Name)
return nil
}

func createNamespace(client *kubernetes.Clientset, ns *corev1.Namespace) error {
_, err := client.CoreV1().Namespaces().Create(context.Background(), ns, v1.CreateOptions{})
if err != nil {
if !k8serrors.IsAlreadyExists(err) {
return err
}
}
fmt.Printf("MinIO Operator Namespace %s: created\n", ns.ObjectMeta.Name)
return nil
}
1 change: 1 addition & 0 deletions kubectl-minio/cmd/resources/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func NewTenant(opts *TenantOptions) (*miniov2.Tenant, error) {
CredsSecret: &v1.LocalObjectReference{
Name: opts.SecretName,
},
Users: []v1.LocalObjectReference{},
Pools: []miniov2.Pool{Pool(opts.Servers, volumesPerServer, *capacityPerVolume, opts.StorageClass)},
RequestAutoCert: &autoCert,
CertConfig: &miniov2.CertificateConfig{
Expand Down
1 change: 1 addition & 0 deletions kubectl-minio/cmd/tenant-expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func newTenantExpandCmd(out io.Writer, errOut io.Writer) *cobra.Command {
f.Int32Var(&v.tenantOpts.Volumes, "volumes", 0, "total number of volumes to add to tenant")
f.StringVar(&v.tenantOpts.Capacity, "capacity", "", "total raw capacity to add to tenant, e.g. 16Ti")
f.StringVarP(&v.tenantOpts.NS, "namespace", "n", helpers.DefaultNamespace, "namespace scope for this request")
f.StringVarP(&v.tenantOpts.StorageClass, "storage-class", "s", helpers.DefaultStorageclass, "storage class for this MinIO tenant")
f.BoolVarP(&v.output, "output", "o", false, "dry run this command and generate requisite yaml")

cmd.MarkFlagRequired("servers")
Expand Down
2 changes: 1 addition & 1 deletion kubectl-minio/statik/statik.go

Large diffs are not rendered by default.

0 comments on commit 666c527

Please sign in to comment.