From 4fa1c02dd9f5125cbb585f2eaee6b49d73e977d5 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Thu, 30 Apr 2020 22:19:03 +0530 Subject: [PATCH] fix: cleanup MinIOInstance Controller (#85) - Update k8s.io/client-go version to v0.18.2 - Add MirrorInstance Controller --- README.md | 24 ++- .../minioinstance-with-external-service.yaml | 137 ------------ examples/minioinstance.yaml | 22 +- examples/patch.yaml | 6 +- go.mod | 30 +-- go.sum | 189 ++++++++++++++--- main.go | 21 +- minio-operator.yaml | 23 +- .../register.go | 4 +- .../v1beta1/doc.go | 6 +- .../v1beta1/helper.go | 11 +- .../v1beta1/helper_test.go | 0 .../v1beta1/register.go | 12 +- .../v1beta1/types.go | 99 ++++----- .../v1beta1/zz_generated.deepcopy.go | 72 ++++--- pkg/client/clientset/versioned/clientset.go | 25 ++- .../versioned/fake/clientset_generated.go | 10 +- .../clientset/versioned/fake/register.go | 4 +- .../clientset/versioned/scheme/register.go | 4 +- .../v1beta1/fake/fake_mirror.go | 140 ------------- .../typed/miniocontroller/v1beta1/mirror.go | 191 ----------------- .../v1beta1/doc.go | 0 .../v1beta1/fake/doc.go | 0 .../v1beta1/fake/fake_minioinstance.go | 30 +-- .../fake/fake_miniooperator.min.io_client.go} | 12 +- .../v1beta1/fake/fake_mirrorinstance.go | 130 ++++++++++++ .../v1beta1/generated_expansion.go | 2 +- .../v1beta1/minioinstance.go | 76 +++---- .../v1beta1/miniooperator.min.io_client.go} | 37 ++-- .../v1beta1/mirrorinstance.go | 178 ++++++++++++++++ .../informers/externalversions/factory.go | 8 +- .../informers/externalversions/generic.go | 10 +- .../interface.go | 4 +- .../v1beta1/interface.go | 10 +- .../v1beta1/minioinstance.go | 13 +- .../v1beta1/mirrorinstance.go} | 43 ++-- .../listers/miniocontroller/v1beta1/mirror.go | 94 --------- .../v1beta1/expansion_generated.go | 12 +- .../v1beta1/minioinstance.go | 7 +- .../v1beta1/mirrorinstance.go | 99 +++++++++ pkg/constants/constants.go | 5 +- pkg/controller/cluster/csr.go | 30 +-- .../{controller.go => main_controller.go} | 37 ++-- pkg/controller/mirror/mirror_controller.go | 196 ++++++------------ pkg/resources/deployments/deployment.go | 54 +++++ pkg/resources/jobs/job.go | 18 -- pkg/resources/services/service.go | 4 +- pkg/resources/statefulsets/statefulset.go | 5 +- 48 files changed, 1067 insertions(+), 1077 deletions(-) delete mode 100644 examples/minioinstance-with-external-service.yaml rename pkg/apis/{miniocontroller => miniooperator.min.io}/register.go (91%) rename pkg/apis/{miniocontroller => miniooperator.min.io}/v1beta1/doc.go (80%) rename pkg/apis/{miniocontroller => miniooperator.min.io}/v1beta1/helper.go (92%) rename pkg/apis/{miniocontroller => miniooperator.min.io}/v1beta1/helper_test.go (100%) rename pkg/apis/{miniocontroller => miniooperator.min.io}/v1beta1/register.go (86%) rename pkg/apis/{miniocontroller => miniooperator.min.io}/v1beta1/types.go (80%) rename pkg/apis/{miniocontroller => miniooperator.min.io}/v1beta1/zz_generated.deepcopy.go (85%) delete mode 100644 pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/fake_mirror.go delete mode 100644 pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/mirror.go rename pkg/client/clientset/versioned/typed/{miniocontroller => miniooperator.min.io}/v1beta1/doc.go (100%) rename pkg/client/clientset/versioned/typed/{miniocontroller => miniooperator.min.io}/v1beta1/fake/doc.go (100%) rename pkg/client/clientset/versioned/typed/{miniocontroller => miniooperator.min.io}/v1beta1/fake/fake_minioinstance.go (71%) rename pkg/client/clientset/versioned/typed/{miniocontroller/v1beta1/fake/fake_miniocontroller_client.go => miniooperator.min.io/v1beta1/fake/fake_miniooperator.min.io_client.go} (71%) create mode 100644 pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/fake_mirrorinstance.go rename pkg/client/clientset/versioned/typed/{miniocontroller => miniooperator.min.io}/v1beta1/generated_expansion.go (94%) rename pkg/client/clientset/versioned/typed/{miniocontroller => miniooperator.min.io}/v1beta1/minioinstance.go (60%) rename pkg/client/clientset/versioned/typed/{miniocontroller/v1beta1/miniocontroller_client.go => miniooperator.min.io/v1beta1/miniooperator.min.io_client.go} (57%) create mode 100644 pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/mirrorinstance.go rename pkg/client/informers/externalversions/{miniocontroller => miniooperator.min.io}/interface.go (95%) rename pkg/client/informers/externalversions/{miniocontroller => miniooperator.min.io}/v1beta1/interface.go (83%) rename pkg/client/informers/externalversions/{miniocontroller => miniooperator.min.io}/v1beta1/minioinstance.go (87%) rename pkg/client/informers/externalversions/{miniocontroller/v1beta1/mirror.go => miniooperator.min.io/v1beta1/mirrorinstance.go} (54%) delete mode 100644 pkg/client/listers/miniocontroller/v1beta1/mirror.go rename pkg/client/listers/{miniocontroller => miniooperator.min.io}/v1beta1/expansion_generated.go (75%) rename pkg/client/listers/{miniocontroller => miniooperator.min.io}/v1beta1/minioinstance.go (90%) create mode 100644 pkg/client/listers/miniooperator.min.io/v1beta1/mirrorinstance.go rename pkg/controller/cluster/{controller.go => main_controller.go} (94%) create mode 100644 pkg/resources/deployments/deployment.go delete mode 100644 pkg/resources/jobs/job.go diff --git a/README.md b/README.md index 1160c45d431..da326aec314 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ MinIO is a high performance distributed object storage server, designed for larg ### Prerequisites -- Kubernetes version v1.15.5 and above. +- Kubernetes version v1.17.0 and above for compatibility. MinIO Operator uses `k8s/client-go` v0.18.0. - `kubectl` configured to refer to a Kubernetes cluster. ### Create Operator and related resources @@ -26,7 +26,7 @@ kubectl create -f https://raw.githubusercontent.com/minio/minio-operator/master/ This will create all relevant resources required for the Operator to work. Here is a list of resources created by above `yaml` file: - `Namespace`: Custom namespace for MinIO-Operator. By default it is named as `minio-operator-ns`. -- `CustomResourceDefinition`: Custom resource definition named as `minioinstances.miniocontroller.min.io`. +- `CustomResourceDefinition`: Custom resource definition named as `minioinstances.miniooperator.min.io`. - `ClusterRole`: A cluster wide role for the controller. It is named as `minio-operator-role`. This is used for RBAC. - `ServiceAccount`: Service account is used by the custom controller to access the cluster. Account name by default is `minio-operator-sa`. - `ClusterRoleBinding`: This cluster wide binding binds the service account `minio-operator-sa` to cluster role `minio-operator-role`. @@ -36,10 +36,10 @@ This will create all relevant resources required for the Operator to work. Here These variables may be passed to operator Deployment in order to modify some of its parameters -| name | default | description | +| Name | Default | Description | | --- | --- | --- | | `WATCHED_NAMESPACE` | | If set, the operator will watch only MinIO resources deployed in the specified namespace. All namespaces are watched if empty | -| `CLUSTER_DOMAIN` | cluster.local | "cluster domain" of the kubernetes cluster the operator is to be installed on | +| `CLUSTER_DOMAIN` | cluster.local | Cluster Domain of the Kubernetes cluster | ### Create a MinIO instance @@ -51,13 +51,21 @@ kubectl create -f https://raw.githubusercontent.com/minio/minio-operator/master/ ### Expand a MinIO cluster -After you have a distributed MinIO Cluster running (zones.server > 3), you can expand the MinIO cluster using +After you have a distributed MinIO Cluster running (zones.server >= 4), you can expand the MinIO cluster using ``` -kubectl patch minioinstances.miniocontroller.min.io minio --patch "$(cat examples/patch.yaml)" --type=merge +kubectl patch minioinstances.miniooperator.min.io minio --patch "$(cat examples/patch.yaml)" --type=merge ``` -You can further keep adding new zones in the `patch.yaml` file and apply the patch, to add new nodes to existing cluster. +You can expand an existing cluster by adding new zones to the `patch.yaml` and run the above `kubectl-patch` command. + +**NOTE**: Important point to consider _before_ using cluster expansion: + +During cluster expansion, MinIO Operator removes the existing StatefulSet and creates a new StatefulSet with required number of Pods. This means, there is a short downtime during expansion, as the pods are terminated and created again. + +As existing StatefulSet pods are terminated, its PVCs are also deleted. It is _very important_ to ensure PVs bound to MinIO StatefulSet PVCs are not deleted at this time to avoid data loss. We recommend configuring every PV with reclaim policy [`retain`](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#retain), to ensure the PV is not deleted. + +If you attempt cluster expansion while the PV reclaim policy is set to something else, it may lead to data loss. If you have the reclaim policy set to something else, change it as explained in [Kubernetes documents](https://kubernetes.io/docs/tasks/administer-cluster/change-pv-reclaim-policy/). ## Features @@ -71,8 +79,6 @@ Refer [`minioinstance.yaml`](https://raw.githubusercontent.com/minio/minio-opera ## Upcoming features -- Bucket Expansion Support -- Federation and CoreDNS - Continuous remote site mirroring with [`mc mirror`](https://docs.minio.io/docs/minio-client-complete-guide.html#mirror) ## Explore Further diff --git a/examples/minioinstance-with-external-service.yaml b/examples/minioinstance-with-external-service.yaml deleted file mode 100644 index 3d3e02117f7..00000000000 --- a/examples/minioinstance-with-external-service.yaml +++ /dev/null @@ -1,137 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: minio-creds-secret -type: Opaque -data: - accesskey: bWluaW8= # base 64 encoded "minio" (echo -n 'minio' | base64) - secretkey: bWluaW8xMjM= # based 64 encoded "minio123" (echo -n 'minio123' | base64) ---- -apiVersion: v1 -kind: Service -metadata: - name: minio-service -spec: - type: ClusterIP - ports: - - port: 9000 - targetPort: 9000 - protocol: TCP - selector: - app: minio ---- -apiVersion: miniocontroller.min.io/v1beta1 -kind: MinIOInstance -metadata: - name: minio -## If specified, MinIOInstance pods will be dispatched by specified scheduler. -## If not specified, the pod will be dispatched by default scheduler. -# scheduler: -# name: my-custom-scheduler -spec: - selector: - matchLabels: - app: minio # Should match spec.metadata.labels - ## Add metadata to the all pods created by the StatefulSet - metadata: - labels: - app: minio # Should match spec.selector.matchLabels - annotations: - prometheus.io/path: /minio/prometheus/metrics - prometheus.io/port: "9000" - prometheus.io/scrape: "true" - ## Registry location and Tag to download MinIO Server image - image: minio/minio:RELEASE.2020-04-15T00-39-01Z - zones: - - name: "zone-0" - ## Number of MinIO servers/pods in this zone. - ## For standalone mode, supply 1. For distributed mode, supply 4 or more. - ## Note that the operator does not support upgrading from standalone to distributed mode. - servers: 4 - ## Supply number of volumes to be mounted per MinIO server instance. - volumesPerServer: 1 - ## Mount path where PV will be mounted inside container(s). Defaults to "/export". - mountPath: /export - ## Sub path inside Mount path where MinIO starts. Defaults to "". - # subPath: /data - ## This VolumeClaimTemplate is used across all the volumes provisioned for MinIO cluster. - ## Please do not change the volumeClaimTemplate field while expanding the cluster, this may - ## lead to unbound PVCs and missing data - volumeClaimTemplate: - metadata: - name: data - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 10Gi - ## Secret with credentials to be used by MinIO instance. - credsSecret: - name: minio-creds-secret - ## PodManagement policy for pods created by StatefulSet. Can be "OrderedReady" or "Parallel" - ## Refer https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#pod-management-policy - ## for details. Defaults to "Parallel" - ## If set to "OrderedReady", then disable Readiness checks below. Readiness check will only - ## work if PodManagementPolicy is set to "Parallel". - podManagementPolicy: Parallel - ## Secret with certificates to configure TLS for MinIO certs. Create secrets as explained - ## here: https://github.com/minio/minio/tree/master/docs/tls/kubernetes#2-create-kubernetes-secret - # externalCertSecret: - # name: tls-ssl-minio - ## Enable Kubernetes based certificate generation and signing as explained in - ## https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster - requestAutoCert: false - ## Used when "requestAutoCert" is set to true. Set CommonName for the auto-generated certificate. - ## Internal DNS name for the pod will be used if CommonName is not provided. - ## DNS name format is minio-{0...3}.minio.default.svc.cluster.local - certConfig: - commonName: "" - organizationName: [] - dnsNames: [] - ## Used to specify a toleration for a pod - # tolerations: - # - effect: NoSchedule - # key: dedicated - # operator: Equal - # value: storage - ## Add environment variables to be set in MinIO container (https://github.com/minio/minio/tree/master/docs/config) - env: - - name: MINIO_BROWSER - value: "on" - # - name: MINIO_STORAGE_CLASS_RRS - # value: "EC:2" - ## Configure resource requests and limits for MinIO containers - resources: - requests: - memory: 512Mi - cpu: 250m - ## Liveness probe detects situations where MinIO server instance - ## is not working properly and needs restart. Kubernetes automatically - ## restarts the pods if liveness checks fail. - liveness: - httpGet: - path: /minio/health/live - port: 9000 - initialDelaySeconds: 120 - periodSeconds: 20 - ## Readiness probe detects situations when MinIO server instance - ## is not ready to accept traffic. Kubernetes doesn't forward - ## traffic to the pod while readiness checks fail. - ## Readiness check will only work if PodManagementPolicy is set to "Parallel". - ## Disable this check if you're setting PodManagementPolicy to "OrderedReady". - readiness: - httpGet: - path: /minio/health/ready - port: 9000 - initialDelaySeconds: 120 - periodSeconds: 20 - ## nodeSelector parameters for MinIO Pods. It specifies a map of key-value pairs. For the pod to be - ## eligible to run on a node, the node must have each of the - ## indicated key-value pairs as labels. - ## Read more here: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ - # nodeSelector: - # disktype: ssd - ## Affinity settings for MinIO pods. Read more about affinity - ## here: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity. - # affinity: diff --git a/examples/minioinstance.yaml b/examples/minioinstance.yaml index 43d61f75695..08a09fe535e 100644 --- a/examples/minioinstance.yaml +++ b/examples/minioinstance.yaml @@ -7,7 +7,20 @@ data: accesskey: bWluaW8= # base 64 encoded "minio" (echo -n 'minio' | base64) secretkey: bWluaW8xMjM= # based 64 encoded "minio123" (echo -n 'minio123' | base64) --- -apiVersion: miniocontroller.min.io/v1beta1 +apiVersion: v1 +kind: Service +metadata: + name: minio-service +spec: + type: ClusterIP + ports: + - port: 9000 + targetPort: 9000 + protocol: TCP + selector: + app: minio +--- +apiVersion: miniooperator.min.io/v1beta1 kind: MinIOInstance metadata: name: minio @@ -28,7 +41,7 @@ spec: prometheus.io/port: "9000" prometheus.io/scrape: "true" ## Registry location and Tag to download MinIO Server image - image: minio/minio:RELEASE.2020-04-15T00-39-01Z + image: minio/minio:RELEASE.2020-04-23T00-58-49Z zones: - name: "zone-0" ## Number of MinIO servers/pods in this zone. @@ -101,7 +114,7 @@ spec: path: /minio/health/live port: 9000 initialDelaySeconds: 120 - periodSeconds: 20 + periodSeconds: 60 ## Readiness probe detects situations when MinIO server instance ## is not ready to accept traffic. Kubernetes doesn't forward ## traffic to the pod while readiness checks fail. @@ -112,7 +125,7 @@ spec: path: /minio/health/ready port: 9000 initialDelaySeconds: 120 - periodSeconds: 20 + periodSeconds: 60 ## nodeSelector parameters for MinIO Pods. It specifies a map of key-value pairs. For the pod to be ## eligible to run on a node, the node must have each of the ## indicated key-value pairs as labels. @@ -122,4 +135,3 @@ spec: ## Affinity settings for MinIO pods. Read more about affinity ## here: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity. # affinity: - \ No newline at end of file diff --git a/examples/patch.yaml b/examples/patch.yaml index df033ddbf32..94f3d4a8450 100644 --- a/examples/patch.yaml +++ b/examples/patch.yaml @@ -1,11 +1,7 @@ -apiVersion: miniocontroller.min.io/v1beta1 +apiVersion: miniooperator.min.io/v1beta1 kind: MinIOInstance metadata: name: minio -## If specified, MinIOInstance pods will be dispatched by specified scheduler. -## If not specified, the pod will be dispatched by default scheduler. -# scheduler: -# name: my-custom-scheduler spec: zones: - name: "zone-0" diff --git a/go.mod b/go.mod index d1b8907618c..91767e5e436 100644 --- a/go.mod +++ b/go.mod @@ -3,33 +3,15 @@ module github.com/minio/minio-operator go 1.13 require ( - github.com/davecgh/go-spew v1.1.1 // indirect github.com/evanphx/json-patch v4.5.0+incompatible // indirect - github.com/ghodss/yaml v0.0.0-20180820084758-c7ce16629ff4 // indirect - github.com/gogo/protobuf v0.0.0-20170702163824-dda3e8acadcc // indirect github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/groupcache v0.0.0-20180924190550-6f2cf27854a4 // indirect - github.com/google/btree v1.0.0 // indirect - github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect - github.com/googleapis/gnostic v0.0.0-20180520015035-48a0ecefe2e4 // indirect - github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect - github.com/hashicorp/golang-lru v0.5.0 // indirect + github.com/golang/protobuf v1.3.3 // indirect github.com/imdario/mergo v0.3.6 // indirect - github.com/json-iterator/go v1.1.5 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.1 // indirect - github.com/onsi/ginkgo v1.10.1 // indirect - github.com/onsi/gomega v1.7.0 // indirect - github.com/peterbourgon/diskv v0.0.0-20180312054125-0646ccaebea1 // indirect github.com/pkg/errors v0.8.1 // indirect - github.com/spf13/pflag v1.0.3 // indirect - github.com/stretchr/testify v1.3.0 - golang.org/x/crypto v0.0.0-20180808211826-de0752318171 // indirect - golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect - golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - k8s.io/api v0.0.0-20181014053814-bbf5c193d86c - k8s.io/apimachinery v0.0.0-20181015213631-60666be32c5d - k8s.io/client-go v0.0.0-20181016014101-70926af6e803 - k8s.io/kube-openapi v0.0.0-20180719232738-d8ea2fe547a4 // indirect + github.com/stretchr/testify v1.4.0 + k8s.io/api v0.18.0 + k8s.io/apimachinery v0.18.0 + k8s.io/client-go v0.18.0 + k8s.io/kube-openapi v0.0.0-20200316234421-82d701f24f9d // indirect ) diff --git a/go.sum b/go.sum index 8eb6235ac15..67d5b1d7cb4 100644 --- a/go.sum +++ b/go.sum @@ -1,78 +1,191 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= +github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= +github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= +github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/ghodss/yaml v0.0.0-20180820084758-c7ce16629ff4 h1:bRzFpEzvausOAt4va+I/22BZ1vXDtERngp0BNYDKej0= -github.com/ghodss/yaml v0.0.0-20180820084758-c7ce16629ff4/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gogo/protobuf v0.0.0-20170702163824-dda3e8acadcc h1:GvfI9UViag4LjQk95XUXCywcUNxbMEQEQqe/BgaFEig= -github.com/gogo/protobuf v0.0.0-20170702163824-dda3e8acadcc/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= +github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= +github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= +github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= +github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= +github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20180924190550-6f2cf27854a4 h1:6UVLWz0fIIrv0UVj6t0A7cL48n8IyAdLVQqAYzEfsKI= github.com/golang/groupcache v0.0.0-20180924190550-6f2cf27854a4/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= -github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= -github.com/googleapis/gnostic v0.0.0-20180520015035-48a0ecefe2e4 h1:yxHFSapGMUoyn+3v6LiJJxoJhvbDqIq8me0gAWehnSU= -github.com/googleapis/gnostic v0.0.0-20180520015035-48a0ecefe2e4/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= +github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/googleapis/gnostic v0.1.0 h1:rVsPeBmXbYv4If/cumu1AzZPwV58q433hvONV1UEZoI= +github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.8 h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46Ok= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= +github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= -github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= +github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/peterbourgon/diskv v0.0.0-20180312054125-0646ccaebea1 h1:k/dnb0bixQwWsDLxwr6/w7rtZCVDKdbQnGQkeZGYsws= -github.com/peterbourgon/diskv v0.0.0-20180312054125-0646ccaebea1/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/crypto v0.0.0-20180808211826-de0752318171 h1:vYogbvSFj2YXcjQxFHu/rASSOt9sLytpCaSkiwQ135I= -golang.org/x/crypto v0.0.0-20180808211826-de0752318171/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 h1:/Tl7pH94bvbAAHBdZJT947M/+gp0+CqQXDtMRC0fseo= +golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI= +golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7 h1:HmbHVPwrPEKPGLAcHSrMe6+hqSUlvZU0rab6x5EXfGU= +golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= @@ -81,11 +194,31 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -k8s.io/api v0.0.0-20181014053814-bbf5c193d86c h1:HRWh0qb07rT5MtgZuVqr4hYMhRhNH3FWDxtlBCbNBpE= -k8s.io/api v0.0.0-20181014053814-bbf5c193d86c/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= -k8s.io/apimachinery v0.0.0-20181015213631-60666be32c5d h1:It9QEnTmJaV0JD1PckL64/3zjGwqi96UrI7gK6NlTbY= -k8s.io/apimachinery v0.0.0-20181015213631-60666be32c5d/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= -k8s.io/client-go v0.0.0-20181016014101-70926af6e803 h1:btIbc6nQzMYY+j65qFdnY6mbpeFqH2uwO68fQR7+tso= -k8s.io/client-go v0.0.0-20181016014101-70926af6e803/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= -k8s.io/kube-openapi v0.0.0-20180719232738-d8ea2fe547a4 h1:C8xi0mJeE8wOFsLofmG7JVxRV2ZAgjYftRc9m2ypdmo= -k8s.io/kube-openapi v0.0.0-20180719232738-d8ea2fe547a4/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/api v0.18.0 h1:lwYk8Vt7rsVTwjRU6pzEsa9YNhThbmbocQlKvNBB4EQ= +k8s.io/api v0.18.0/go.mod h1:q2HRQkfDzHMBZL9l/y9rH63PkQl4vae0xRT+8prbrK8= +k8s.io/apimachinery v0.18.0 h1:fuPfYpk3cs1Okp/515pAf0dNhL66+8zk8RLbSX+EgAE= +k8s.io/apimachinery v0.18.0/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= +k8s.io/client-go v0.18.0 h1:yqKw4cTUQraZK3fcVCMeSa+lqKwcjZ5wtcOIPnxQno4= +k8s.io/client-go v0.18.0/go.mod h1:uQSYDYs4WhVZ9i6AIoEZuwUggLVEF64HOD37boKAtF8= +k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= +k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= +k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= +k8s.io/kube-openapi v0.0.0-20200316234421-82d701f24f9d h1:jocF7XFucw2pEiv2wS7wk2FRFCjDFGV1oa4TMs0SAT0= +k8s.io/kube-openapi v0.0.0-20200316234421-82d701f24f9d/go.mod h1:F+5wygcW0wmRTnM3cOgIqGivxkwSWIWT5YdsDbeAOaU= +k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 h1:d4vVOjXm687F1iLSP2q3lyPPuyvTUt3aVoBpi2DqRsU= +k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +sigs.k8s.io/structured-merge-diff/v2 v2.0.1/go.mod h1:Wb7vfKAodbKgf6tn1Kl0VvGj7mRH6DGaRcixXEJXTsE= +sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= +sigs.k8s.io/structured-merge-diff/v3 v3.0.0 h1:dOmIZBMfhcHS09XZkMyUgkq5trg3/jRyJYFZUiaOp8E= +sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= +sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= diff --git a/main.go b/main.go index b3aafaf09a5..92ed4e3b130 100644 --- a/main.go +++ b/main.go @@ -38,6 +38,7 @@ import ( clientset "github.com/minio/minio-operator/pkg/client/clientset/versioned" informers "github.com/minio/minio-operator/pkg/client/informers/externalversions" "github.com/minio/minio-operator/pkg/controller/cluster" + "github.com/minio/minio-operator/pkg/controller/mirror" ) // Version provides the version of this minio-operator @@ -99,6 +100,7 @@ func main() { var kubeInformerFactory kubeinformers.SharedInformerFactory var minioInformerFactory informers.SharedInformerFactory + var mirrorInformerFactory informers.SharedInformerFactory if isNamespaced { kubeInformerFactory = kubeinformers.NewSharedInformerFactoryWithOptions(kubeClient, time.Second*30, kubeinformers.WithNamespace(namespace)) minioInformerFactory = informers.NewSharedInformerFactoryWithOptions(controllerClient, time.Second*30, informers.WithNamespace(namespace)) @@ -107,16 +109,27 @@ func main() { minioInformerFactory = informers.NewSharedInformerFactory(controllerClient, time.Second*30) } - controller := cluster.NewController(kubeClient, controllerClient, *certClient, + mainController := cluster.NewController(kubeClient, controllerClient, *certClient, kubeInformerFactory.Apps().V1().StatefulSets(), - minioInformerFactory.Min().V1beta1().MinIOInstances(), + minioInformerFactory.Miniooperator().V1beta1().MinIOInstances(), kubeInformerFactory.Core().V1().Services()) go kubeInformerFactory.Start(stopCh) go minioInformerFactory.Start(stopCh) - if err = controller.Run(2, stopCh); err != nil { - glog.Fatalf("Error running controller: %s", err.Error()) + if err = mainController.Run(2, stopCh); err != nil { + glog.Fatalf("Error running mainController: %s", err.Error()) + } + + mirrorController := mirror.NewController(kubeClient, controllerClient, + kubeInformerFactory.Apps().V1().Deployments(), + mirrorInformerFactory.Miniooperator().V1beta1().MirrorInstances()) + + go kubeInformerFactory.Start(stopCh) + go minioInformerFactory.Start(stopCh) + + if err = mirrorController.Run(2, stopCh); err != nil { + glog.Fatalf("Error running mirrorController: %s", err.Error()) } } diff --git a/minio-operator.yaml b/minio-operator.yaml index 647bcf7b723..a30270bbfb0 100644 --- a/minio-operator.yaml +++ b/minio-operator.yaml @@ -6,9 +6,9 @@ metadata: apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: - name: minioinstances.miniocontroller.min.io + name: minioinstances.miniooperator.min.io spec: - group: miniocontroller.min.io + group: miniooperator.min.io version: v1beta1 scope: Namespaced names: @@ -41,6 +41,20 @@ spec: type: integer JSONPath: ".spec.replicas" --- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: mirrorinstances.miniooperator.min.io +spec: + group: miniooperator.min.io + version: v1beta1 + scope: Namespaced + names: + kind: MirrorInstance + singular: mirrorinstance + plural: mirrorinstances + preserveUnknownFields: true +--- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRole metadata: @@ -71,6 +85,7 @@ rules: - patch - watch - update + - delete - apiGroups: - "certificates.k8s.io" resources: @@ -82,7 +97,7 @@ rules: - create - get - apiGroups: - - miniocontroller.min.io + - miniooperator.min.io resources: - "*" verbs: @@ -132,7 +147,7 @@ spec: serviceAccountName: minio-operator-sa containers: - name: minio-operator - image: minio/k8s-operator:1.0.8 + image: minio/k8s-operator:1.0.9 imagePullPolicy: IfNotPresent # To specify cluster domain, un comment the following: # env: diff --git a/pkg/apis/miniocontroller/register.go b/pkg/apis/miniooperator.min.io/register.go similarity index 91% rename from pkg/apis/miniocontroller/register.go rename to pkg/apis/miniooperator.min.io/register.go index 015054689de..e539d45c5e9 100644 --- a/pkg/apis/miniocontroller/register.go +++ b/pkg/apis/miniooperator.min.io/register.go @@ -15,9 +15,9 @@ * */ -package miniocontroller +package miniooperator // Controller MinIO group name. const ( - GroupName = "miniocontroller.min.io" + GroupName = "miniooperator.min.io" ) diff --git a/pkg/apis/miniocontroller/v1beta1/doc.go b/pkg/apis/miniooperator.min.io/v1beta1/doc.go similarity index 80% rename from pkg/apis/miniocontroller/v1beta1/doc.go rename to pkg/apis/miniooperator.min.io/v1beta1/doc.go index 0c169b0a371..bcab37fdfc9 100644 --- a/pkg/apis/miniocontroller/v1beta1/doc.go +++ b/pkg/apis/miniooperator.min.io/v1beta1/doc.go @@ -15,8 +15,10 @@ * */ -// +k8s:deepcopy-gen=package +// +k8s:deepcopy-gen=package,register +// go:generate controller-gen crd:trivialVersions=true paths=. output:dir=. // Package v1beta1 is the v1beta1 version of the API. -// +groupName=min.io.io +// +groupName=miniooperator.k8s.io +// +versionName=v1beta1 package v1beta1 diff --git a/pkg/apis/miniocontroller/v1beta1/helper.go b/pkg/apis/miniooperator.min.io/v1beta1/helper.go similarity index 92% rename from pkg/apis/miniocontroller/v1beta1/helper.go rename to pkg/apis/miniooperator.min.io/v1beta1/helper.go index 34bcc5ad9a3..b6e0ad0e434 100644 --- a/pkg/apis/miniocontroller/v1beta1/helper.go +++ b/pkg/apis/miniooperator.min.io/v1beta1/helper.go @@ -157,16 +157,13 @@ func (mi *MinIOInstance) EnsureDefaults() *MinIOInstance { // current MinIOInstance func (mi *MinIOInstance) GetHosts() []string { hosts := make([]string, 0) - var max int32 + var max, index int32 // Create the ellipses style URL // mi.Name is the headless service name - for i, z := range mi.Spec.Zones { + for _, z := range mi.Spec.Zones { max = max + z.Servers - if i == 0 { - hosts = append(hosts, fmt.Sprintf("%s-{0..."+strconv.Itoa(int(max)-1)+"}.%s.%s.svc."+constants.ClusterDomain, mi.Name, mi.GetHeadlessServiceName(), mi.Namespace)) - } else { - hosts = append(hosts, fmt.Sprintf("%s-{"+strconv.Itoa(int(mi.Spec.Zones[i-1].Servers))+"..."+strconv.Itoa(int(max)-1)+"}.%s.%s.svc."+constants.ClusterDomain, mi.Name, mi.GetHeadlessServiceName(), mi.Namespace)) - } + hosts = append(hosts, fmt.Sprintf("%s-{"+strconv.Itoa(int(index))+"..."+strconv.Itoa(int(max)-1)+"}.%s.%s.svc."+constants.ClusterDomain, mi.Name, mi.GetHeadlessServiceName(), mi.Namespace)) + index = max } return hosts } diff --git a/pkg/apis/miniocontroller/v1beta1/helper_test.go b/pkg/apis/miniooperator.min.io/v1beta1/helper_test.go similarity index 100% rename from pkg/apis/miniocontroller/v1beta1/helper_test.go rename to pkg/apis/miniooperator.min.io/v1beta1/helper_test.go diff --git a/pkg/apis/miniocontroller/v1beta1/register.go b/pkg/apis/miniooperator.min.io/v1beta1/register.go similarity index 86% rename from pkg/apis/miniocontroller/v1beta1/register.go rename to pkg/apis/miniooperator.min.io/v1beta1/register.go index 8d4ac9a5aad..db785354499 100644 --- a/pkg/apis/miniocontroller/v1beta1/register.go +++ b/pkg/apis/miniooperator.min.io/v1beta1/register.go @@ -22,11 +22,14 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" - "github.com/minio/minio-operator/pkg/apis/miniocontroller" + "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io" ) +// Version specifies the API Version +const Version = "v1beta1" + // SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: miniocontroller.GroupName, Version: "v1beta1"} +var SchemeGroupVersion = schema.GroupVersion{Group: miniooperator.GroupName, Version: Version} // Kind takes an unqualified kind and returns back a Group qualified GroupKind func Kind(kind string) schema.GroupKind { @@ -47,14 +50,13 @@ var ( AddToScheme = SchemeBuilder.AddToScheme ) -// ClusterCRDResourceKind is the Kind of a Cluster. -const ClusterCRDResourceKind = "MinIOInstance" - // Adds the list of known types to Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &MinIOInstance{}, &MinIOInstanceList{}, + &MirrorInstance{}, + &MirrorInstanceList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/pkg/apis/miniocontroller/v1beta1/types.go b/pkg/apis/miniooperator.min.io/v1beta1/types.go similarity index 80% rename from pkg/apis/miniocontroller/v1beta1/types.go rename to pkg/apis/miniooperator.min.io/v1beta1/types.go index 63864a5853f..c4433fc4bcc 100644 --- a/pkg/apis/miniocontroller/v1beta1/types.go +++ b/pkg/apis/miniooperator.min.io/v1beta1/types.go @@ -25,6 +25,9 @@ import ( // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:defaulter-gen=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Namespaced,shortName=minioinstance,singular=minioinstance // MinIOInstance is a specification for a MinIO resource type MinIOInstance struct { @@ -42,25 +45,6 @@ type MinIOInstanceScheduler struct { Name string `json:"name"` } -// CertificateConfig is a specification for certificate contents -type CertificateConfig struct { - CommonName string `json:"commonName,omitempty"` - OrganizationName []string `json:"organizationName,omitempty"` - DNSNames []string `json:"dnsNames,omitempty"` -} - -// LocalCertificateReference defines the spec for a local certificate -type LocalCertificateReference struct { - Name string `json:"name"` - Type string `json:"type,omitempty"` -} - -// Zone defines the spec for a MinIO Zone -type Zone struct { - Name string `json:"name"` - Servers int32 `json:"servers"` -} - // MinIOInstanceSpec is the spec for a MinIOInstance resource type MinIOInstanceSpec struct { // Image defines the MinIOInstance Docker image. @@ -139,6 +123,25 @@ type MinIOInstanceStatus struct { AvailableReplicas int32 `json:"availableReplicas"` } +// CertificateConfig is a specification for certificate contents +type CertificateConfig struct { + CommonName string `json:"commonName,omitempty"` + OrganizationName []string `json:"organizationName,omitempty"` + DNSNames []string `json:"dnsNames,omitempty"` +} + +// LocalCertificateReference defines the spec for a local certificate +type LocalCertificateReference struct { + Name string `json:"name"` + Type string `json:"type,omitempty"` +} + +// Zone defines the spec for a MinIO Zone +type Zone struct { + Name string `json:"name"` + Servers int32 `json:"servers"` +} + // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // MinIOInstanceList is a list of MinIOInstance resources @@ -151,66 +154,42 @@ type MinIOInstanceList struct { // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:defaulter-gen=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Namespaced,shortName=mirrorinstance,singular=mirrorinstance -// Mirror is a backup of a MinIOInstance. -type Mirror struct { +// MirrorInstance is an instance of mc mirror +// Refer: https://docs.minio.io/docs/minio-client-complete-guide.html#mirror +type MirrorInstance struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` - Spec MirrorSpec `json:"spec"` - Status MirrorStatus `json:"status"` + Spec MirrorInstanceSpec `json:"spec"` } -// MirrorSpec defines the specification for a MinIOInstance backup. This includes the source and +// MirrorInstanceSpec defines the specification for a MinIOInstance backup. This includes the source and // target where the backup should be stored. Note that both source and target are expected to be // AWS S3 API compliant services. -type MirrorSpec struct { +type MirrorInstanceSpec struct { // Version defines the MinIO Client (mc) Docker image version. Version string `json:"version"` - // SourceEndpoint is the endpoint of MinIO instance to backup. - SourceEndpoint string `json:"srcEndpoint"` - // SourceCredsSecret as the credentials for source MinIO instance. - SourceCredsSecret *corev1.LocalObjectReference `json:"srcCredsSecret"` + // Env is used to add alias (source and target MinIO servers) to mc. + Env []corev1.EnvVar `json:"env,omitempty"` // SourceBucket defines the bucket on source MinIO instance - // +optional SourceBucket string `json:"srcBucket,omitempty"` - // Region in which the source S3 compatible bucket is located. - // uses "us-east-1" by default - // +optional - SourceRegion string `json:"srcRegion"` - // Endpoint (hostname only or fully qualified URI) of S3 compatible - // storage service. - TargetEndpoint string `json:"targetEndpoint"` - // CredentialsSecret is a reference to the Secret containing the - // credentials authenticating with the S3 compatible storage service. - TargetCredsSecret *corev1.LocalObjectReference `json:"targetCredsSecret"` - // Bucket in which to store the Backup. + // TargetBucket defines where to store the Backup. TargetBucket string `json:"targetBucket"` - // Region in which the Target S3 compatible bucket is located. - // uses "us-east-1" by default - // +optional - TargetRegion string `json:"targetRegion"` -} - -// MirrorStatus captures the current status of a Mirror operation. -type MirrorStatus struct { - // Outcome holds the results of a Mirror operation. - // +optional - Outcome string `json:"outcome"` - // TimeStarted is the time at which the backup was started. - // +optional - TimeStarted metav1.Time `json:"timeStarted"` - // TimeCompleted is the time at which the backup completed. + // MirrorFlags is a map to add `mc` flags // +optional - TimeCompleted metav1.Time `json:"timeCompleted"` + MirrorFlags map[string]string `json:"mirrorFlags,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// MirrorList is a list of Backups. -type MirrorList struct { +// MirrorInstanceList is a list of MirrorInstance resources +type MirrorInstanceList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata"` - Items []Mirror `json:"items"` + Items []MirrorInstance `json:"items"` } diff --git a/pkg/apis/miniocontroller/v1beta1/zz_generated.deepcopy.go b/pkg/apis/miniooperator.min.io/v1beta1/zz_generated.deepcopy.go similarity index 85% rename from pkg/apis/miniocontroller/v1beta1/zz_generated.deepcopy.go rename to pkg/apis/miniooperator.min.io/v1beta1/zz_generated.deepcopy.go index a96f9018a20..811bd562315 100644 --- a/pkg/apis/miniocontroller/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/miniooperator.min.io/v1beta1/zz_generated.deepcopy.go @@ -149,6 +149,7 @@ func (in *MinIOInstanceScheduler) DeepCopy() *MinIOInstanceScheduler { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MinIOInstanceSpec) DeepCopyInto(out *MinIOInstanceSpec) { *out = *in + out.ImagePullSecret = in.ImagePullSecret if in.Metadata != nil { in, out := &in.Metadata, &out.Metadata *out = new(v1.ObjectMeta) @@ -172,6 +173,11 @@ func (in *MinIOInstanceSpec) DeepCopyInto(out *MinIOInstanceSpec) { *out = new(corev1.PersistentVolumeClaim) (*in).DeepCopyInto(*out) } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } if in.NodeSelector != nil { in, out := &in.NodeSelector, &out.NodeSelector *out = make(map[string]string, len(*in)) @@ -216,6 +222,11 @@ func (in *MinIOInstanceSpec) DeepCopyInto(out *MinIOInstanceSpec) { *out = new(corev1.PodSecurityContext) (*in).DeepCopyInto(*out) } + if in.Zones != nil { + in, out := &in.Zones, &out.Zones + *out = make([]Zone, len(*in)) + copy(*out, *in) + } return } @@ -246,27 +257,26 @@ func (in *MinIOInstanceStatus) DeepCopy() *MinIOInstanceStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Mirror) DeepCopyInto(out *Mirror) { +func (in *MirrorInstance) DeepCopyInto(out *MirrorInstance) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Mirror. -func (in *Mirror) DeepCopy() *Mirror { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MirrorInstance. +func (in *MirrorInstance) DeepCopy() *MirrorInstance { if in == nil { return nil } - out := new(Mirror) + out := new(MirrorInstance) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Mirror) DeepCopyObject() runtime.Object { +func (in *MirrorInstance) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -274,13 +284,13 @@ func (in *Mirror) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MirrorList) DeepCopyInto(out *MirrorList) { +func (in *MirrorInstanceList) DeepCopyInto(out *MirrorInstanceList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]Mirror, len(*in)) + *out = make([]MirrorInstance, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -288,18 +298,18 @@ func (in *MirrorList) DeepCopyInto(out *MirrorList) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MirrorList. -func (in *MirrorList) DeepCopy() *MirrorList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MirrorInstanceList. +func (in *MirrorInstanceList) DeepCopy() *MirrorInstanceList { if in == nil { return nil } - out := new(MirrorList) + out := new(MirrorInstanceList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *MirrorList) DeepCopyObject() runtime.Object { +func (in *MirrorInstanceList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -307,45 +317,47 @@ func (in *MirrorList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MirrorSpec) DeepCopyInto(out *MirrorSpec) { +func (in *MirrorInstanceSpec) DeepCopyInto(out *MirrorInstanceSpec) { *out = *in - if in.SourceCredsSecret != nil { - in, out := &in.SourceCredsSecret, &out.SourceCredsSecret - *out = new(corev1.LocalObjectReference) - **out = **in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]corev1.EnvVar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } - if in.TargetCredsSecret != nil { - in, out := &in.TargetCredsSecret, &out.TargetCredsSecret - *out = new(corev1.LocalObjectReference) - **out = **in + if in.MirrorFlags != nil { + in, out := &in.MirrorFlags, &out.MirrorFlags + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MirrorSpec. -func (in *MirrorSpec) DeepCopy() *MirrorSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MirrorInstanceSpec. +func (in *MirrorInstanceSpec) DeepCopy() *MirrorInstanceSpec { if in == nil { return nil } - out := new(MirrorSpec) + out := new(MirrorInstanceSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MirrorStatus) DeepCopyInto(out *MirrorStatus) { +func (in *Zone) DeepCopyInto(out *Zone) { *out = *in - in.TimeStarted.DeepCopyInto(&out.TimeStarted) - in.TimeCompleted.DeepCopyInto(&out.TimeCompleted) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MirrorStatus. -func (in *MirrorStatus) DeepCopy() *MirrorStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Zone. +func (in *Zone) DeepCopy() *Zone { if in == nil { return nil } - out := new(MirrorStatus) + out := new(Zone) in.DeepCopyInto(out) return out } diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 006425b248e..9277a67d43b 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -19,7 +19,9 @@ limitations under the License. package versioned import ( - minv1beta1 "github.com/minio/minio-operator/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1" + "fmt" + + miniooperatorv1beta1 "github.com/minio/minio-operator/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -27,19 +29,19 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - MinV1beta1() minv1beta1.MinV1beta1Interface + MiniooperatorV1beta1() miniooperatorv1beta1.MiniooperatorV1beta1Interface } // Clientset contains the clients for groups. Each group has exactly one // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient - minV1beta1 *minv1beta1.MinV1beta1Client + miniooperatorV1beta1 *miniooperatorv1beta1.MiniooperatorV1beta1Client } -// MinV1beta1 retrieves the MinV1beta1Client -func (c *Clientset) MinV1beta1() minv1beta1.MinV1beta1Interface { - return c.minV1beta1 +// MiniooperatorV1beta1 retrieves the MiniooperatorV1beta1Client +func (c *Clientset) MiniooperatorV1beta1() miniooperatorv1beta1.MiniooperatorV1beta1Interface { + return c.miniooperatorV1beta1 } // Discovery retrieves the DiscoveryClient @@ -51,14 +53,19 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface { } // NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. func NewForConfig(c *rest.Config) (*Clientset, error) { configShallowCopy := *c if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) } var cs Clientset var err error - cs.minV1beta1, err = minv1beta1.NewForConfig(&configShallowCopy) + cs.miniooperatorV1beta1, err = miniooperatorv1beta1.NewForConfig(&configShallowCopy) if err != nil { return nil, err } @@ -74,7 +81,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset - cs.minV1beta1 = minv1beta1.NewForConfigOrDie(c) + cs.miniooperatorV1beta1 = miniooperatorv1beta1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -83,7 +90,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.minV1beta1 = minv1beta1.New(c) + cs.miniooperatorV1beta1 = miniooperatorv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 11ae0f84e16..07324349484 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -20,8 +20,8 @@ package fake import ( clientset "github.com/minio/minio-operator/pkg/client/clientset/versioned" - minv1beta1 "github.com/minio/minio-operator/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1" - fakeminv1beta1 "github.com/minio/minio-operator/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake" + miniooperatorv1beta1 "github.com/minio/minio-operator/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1" + fakeminiooperatorv1beta1 "github.com/minio/minio-operator/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -76,7 +76,7 @@ func (c *Clientset) Tracker() testing.ObjectTracker { var _ clientset.Interface = &Clientset{} -// MinV1beta1 retrieves the MinV1beta1Client -func (c *Clientset) MinV1beta1() minv1beta1.MinV1beta1Interface { - return &fakeminv1beta1.FakeMinV1beta1{Fake: &c.Fake} +// MiniooperatorV1beta1 retrieves the MiniooperatorV1beta1Client +func (c *Clientset) MiniooperatorV1beta1() miniooperatorv1beta1.MiniooperatorV1beta1Interface { + return &fakeminiooperatorv1beta1.FakeMiniooperatorV1beta1{Fake: &c.Fake} } diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 3352e3c5837..df591f05770 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - minv1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + miniooperatorv1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - minv1beta1.AddToScheme, + miniooperatorv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 2ea7e3abbb5..3e085034494 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -19,7 +19,7 @@ limitations under the License. package scheme import ( - minv1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + miniooperatorv1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - minv1beta1.AddToScheme, + miniooperatorv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/fake_mirror.go b/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/fake_mirror.go deleted file mode 100644 index 6a11206d34e..00000000000 --- a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/fake_mirror.go +++ /dev/null @@ -1,140 +0,0 @@ -/* -Copyright The Kubernetes 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeMirrors implements MirrorInterface -type FakeMirrors struct { - Fake *FakeMinV1beta1 - ns string -} - -var mirrorsResource = schema.GroupVersionResource{Group: "min.io.io", Version: "v1beta1", Resource: "mirrors"} - -var mirrorsKind = schema.GroupVersionKind{Group: "min.io.io", Version: "v1beta1", Kind: "Mirror"} - -// Get takes name of the mirror, and returns the corresponding mirror object, and an error if there is any. -func (c *FakeMirrors) Get(name string, options v1.GetOptions) (result *v1beta1.Mirror, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(mirrorsResource, c.ns, name), &v1beta1.Mirror{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.Mirror), err -} - -// List takes label and field selectors, and returns the list of Mirrors that match those selectors. -func (c *FakeMirrors) List(opts v1.ListOptions) (result *v1beta1.MirrorList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(mirrorsResource, mirrorsKind, c.ns, opts), &v1beta1.MirrorList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1beta1.MirrorList{ListMeta: obj.(*v1beta1.MirrorList).ListMeta} - for _, item := range obj.(*v1beta1.MirrorList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested mirrors. -func (c *FakeMirrors) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(mirrorsResource, c.ns, opts)) - -} - -// Create takes the representation of a mirror and creates it. Returns the server's representation of the mirror, and an error, if there is any. -func (c *FakeMirrors) Create(mirror *v1beta1.Mirror) (result *v1beta1.Mirror, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(mirrorsResource, c.ns, mirror), &v1beta1.Mirror{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.Mirror), err -} - -// Update takes the representation of a mirror and updates it. Returns the server's representation of the mirror, and an error, if there is any. -func (c *FakeMirrors) Update(mirror *v1beta1.Mirror) (result *v1beta1.Mirror, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(mirrorsResource, c.ns, mirror), &v1beta1.Mirror{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.Mirror), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeMirrors) UpdateStatus(mirror *v1beta1.Mirror) (*v1beta1.Mirror, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(mirrorsResource, "status", c.ns, mirror), &v1beta1.Mirror{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.Mirror), err -} - -// Delete takes name of the mirror and deletes it. Returns an error if one occurs. -func (c *FakeMirrors) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(mirrorsResource, c.ns, name), &v1beta1.Mirror{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeMirrors) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(mirrorsResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &v1beta1.MirrorList{}) - return err -} - -// Patch applies the patch and returns the patched mirror. -func (c *FakeMirrors) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Mirror, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(mirrorsResource, c.ns, name, pt, data, subresources...), &v1beta1.Mirror{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.Mirror), err -} diff --git a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/mirror.go b/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/mirror.go deleted file mode 100644 index a06fdd90f5b..00000000000 --- a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/mirror.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright The Kubernetes 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "time" - - v1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" - scheme "github.com/minio/minio-operator/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// MirrorsGetter has a method to return a MirrorInterface. -// A group's client should implement this interface. -type MirrorsGetter interface { - Mirrors(namespace string) MirrorInterface -} - -// MirrorInterface has methods to work with Mirror resources. -type MirrorInterface interface { - Create(*v1beta1.Mirror) (*v1beta1.Mirror, error) - Update(*v1beta1.Mirror) (*v1beta1.Mirror, error) - UpdateStatus(*v1beta1.Mirror) (*v1beta1.Mirror, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.Mirror, error) - List(opts v1.ListOptions) (*v1beta1.MirrorList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Mirror, err error) - MirrorExpansion -} - -// mirrors implements MirrorInterface -type mirrors struct { - client rest.Interface - ns string -} - -// newMirrors returns a Mirrors -func newMirrors(c *MinV1beta1Client, namespace string) *mirrors { - return &mirrors{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the mirror, and returns the corresponding mirror object, and an error if there is any. -func (c *mirrors) Get(name string, options v1.GetOptions) (result *v1beta1.Mirror, err error) { - result = &v1beta1.Mirror{} - err = c.client.Get(). - Namespace(c.ns). - Resource("mirrors"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Mirrors that match those selectors. -func (c *mirrors) List(opts v1.ListOptions) (result *v1beta1.MirrorList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.MirrorList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("mirrors"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested mirrors. -func (c *mirrors) Watch(opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("mirrors"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch() -} - -// Create takes the representation of a mirror and creates it. Returns the server's representation of the mirror, and an error, if there is any. -func (c *mirrors) Create(mirror *v1beta1.Mirror) (result *v1beta1.Mirror, err error) { - result = &v1beta1.Mirror{} - err = c.client.Post(). - Namespace(c.ns). - Resource("mirrors"). - Body(mirror). - Do(). - Into(result) - return -} - -// Update takes the representation of a mirror and updates it. Returns the server's representation of the mirror, and an error, if there is any. -func (c *mirrors) Update(mirror *v1beta1.Mirror) (result *v1beta1.Mirror, err error) { - result = &v1beta1.Mirror{} - err = c.client.Put(). - Namespace(c.ns). - Resource("mirrors"). - Name(mirror.Name). - Body(mirror). - Do(). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *mirrors) UpdateStatus(mirror *v1beta1.Mirror) (result *v1beta1.Mirror, err error) { - result = &v1beta1.Mirror{} - err = c.client.Put(). - Namespace(c.ns). - Resource("mirrors"). - Name(mirror.Name). - SubResource("status"). - Body(mirror). - Do(). - Into(result) - return -} - -// Delete takes name of the mirror and deletes it. Returns an error if one occurs. -func (c *mirrors) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("mirrors"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *mirrors) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("mirrors"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Timeout(timeout). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched mirror. -func (c *mirrors) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Mirror, err error) { - result = &v1beta1.Mirror{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("mirrors"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/doc.go b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/doc.go similarity index 100% rename from pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/doc.go rename to pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/doc.go diff --git a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/doc.go b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/doc.go similarity index 100% rename from pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/doc.go rename to pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/doc.go diff --git a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/fake_minioinstance.go b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/fake_minioinstance.go similarity index 71% rename from pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/fake_minioinstance.go rename to pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/fake_minioinstance.go index 3a16e9430e4..8661688916b 100644 --- a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/fake_minioinstance.go +++ b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/fake_minioinstance.go @@ -19,7 +19,9 @@ limitations under the License. package fake import ( - v1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + "context" + + v1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,16 +32,16 @@ import ( // FakeMinIOInstances implements MinIOInstanceInterface type FakeMinIOInstances struct { - Fake *FakeMinV1beta1 + Fake *FakeMiniooperatorV1beta1 ns string } -var minioinstancesResource = schema.GroupVersionResource{Group: "min.io.io", Version: "v1beta1", Resource: "minioinstances"} +var minioinstancesResource = schema.GroupVersionResource{Group: "miniooperator.k8s.io", Version: "v1beta1", Resource: "minioinstances"} -var minioinstancesKind = schema.GroupVersionKind{Group: "min.io.io", Version: "v1beta1", Kind: "MinIOInstance"} +var minioinstancesKind = schema.GroupVersionKind{Group: "miniooperator.k8s.io", Version: "v1beta1", Kind: "MinIOInstance"} // Get takes name of the minIOInstance, and returns the corresponding minIOInstance object, and an error if there is any. -func (c *FakeMinIOInstances) Get(name string, options v1.GetOptions) (result *v1beta1.MinIOInstance, err error) { +func (c *FakeMinIOInstances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.MinIOInstance, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(minioinstancesResource, c.ns, name), &v1beta1.MinIOInstance{}) @@ -50,7 +52,7 @@ func (c *FakeMinIOInstances) Get(name string, options v1.GetOptions) (result *v1 } // List takes label and field selectors, and returns the list of MinIOInstances that match those selectors. -func (c *FakeMinIOInstances) List(opts v1.ListOptions) (result *v1beta1.MinIOInstanceList, err error) { +func (c *FakeMinIOInstances) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MinIOInstanceList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(minioinstancesResource, minioinstancesKind, c.ns, opts), &v1beta1.MinIOInstanceList{}) @@ -72,14 +74,14 @@ func (c *FakeMinIOInstances) List(opts v1.ListOptions) (result *v1beta1.MinIOIns } // Watch returns a watch.Interface that watches the requested minIOInstances. -func (c *FakeMinIOInstances) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeMinIOInstances) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(minioinstancesResource, c.ns, opts)) } // Create takes the representation of a minIOInstance and creates it. Returns the server's representation of the minIOInstance, and an error, if there is any. -func (c *FakeMinIOInstances) Create(minIOInstance *v1beta1.MinIOInstance) (result *v1beta1.MinIOInstance, err error) { +func (c *FakeMinIOInstances) Create(ctx context.Context, minIOInstance *v1beta1.MinIOInstance, opts v1.CreateOptions) (result *v1beta1.MinIOInstance, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(minioinstancesResource, c.ns, minIOInstance), &v1beta1.MinIOInstance{}) @@ -90,7 +92,7 @@ func (c *FakeMinIOInstances) Create(minIOInstance *v1beta1.MinIOInstance) (resul } // Update takes the representation of a minIOInstance and updates it. Returns the server's representation of the minIOInstance, and an error, if there is any. -func (c *FakeMinIOInstances) Update(minIOInstance *v1beta1.MinIOInstance) (result *v1beta1.MinIOInstance, err error) { +func (c *FakeMinIOInstances) Update(ctx context.Context, minIOInstance *v1beta1.MinIOInstance, opts v1.UpdateOptions) (result *v1beta1.MinIOInstance, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(minioinstancesResource, c.ns, minIOInstance), &v1beta1.MinIOInstance{}) @@ -102,7 +104,7 @@ func (c *FakeMinIOInstances) Update(minIOInstance *v1beta1.MinIOInstance) (resul // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeMinIOInstances) UpdateStatus(minIOInstance *v1beta1.MinIOInstance) (*v1beta1.MinIOInstance, error) { +func (c *FakeMinIOInstances) UpdateStatus(ctx context.Context, minIOInstance *v1beta1.MinIOInstance, opts v1.UpdateOptions) (*v1beta1.MinIOInstance, error) { obj, err := c.Fake. Invokes(testing.NewUpdateSubresourceAction(minioinstancesResource, "status", c.ns, minIOInstance), &v1beta1.MinIOInstance{}) @@ -113,7 +115,7 @@ func (c *FakeMinIOInstances) UpdateStatus(minIOInstance *v1beta1.MinIOInstance) } // Delete takes name of the minIOInstance and deletes it. Returns an error if one occurs. -func (c *FakeMinIOInstances) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeMinIOInstances) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(minioinstancesResource, c.ns, name), &v1beta1.MinIOInstance{}) @@ -121,15 +123,15 @@ func (c *FakeMinIOInstances) Delete(name string, options *v1.DeleteOptions) erro } // DeleteCollection deletes a collection of objects. -func (c *FakeMinIOInstances) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(minioinstancesResource, c.ns, listOptions) +func (c *FakeMinIOInstances) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(minioinstancesResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.MinIOInstanceList{}) return err } // Patch applies the patch and returns the patched minIOInstance. -func (c *FakeMinIOInstances) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.MinIOInstance, err error) { +func (c *FakeMinIOInstances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MinIOInstance, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(minioinstancesResource, c.ns, name, pt, data, subresources...), &v1beta1.MinIOInstance{}) diff --git a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/fake_miniocontroller_client.go b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/fake_miniooperator.min.io_client.go similarity index 71% rename from pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/fake_miniocontroller_client.go rename to pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/fake_miniooperator.min.io_client.go index 3e6d55ba631..93c837c29c0 100644 --- a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/fake/fake_miniocontroller_client.go +++ b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/fake_miniooperator.min.io_client.go @@ -19,26 +19,26 @@ limitations under the License. package fake import ( - v1beta1 "github.com/minio/minio-operator/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1" + v1beta1 "github.com/minio/minio-operator/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) -type FakeMinV1beta1 struct { +type FakeMiniooperatorV1beta1 struct { *testing.Fake } -func (c *FakeMinV1beta1) MinIOInstances(namespace string) v1beta1.MinIOInstanceInterface { +func (c *FakeMiniooperatorV1beta1) MinIOInstances(namespace string) v1beta1.MinIOInstanceInterface { return &FakeMinIOInstances{c, namespace} } -func (c *FakeMinV1beta1) Mirrors(namespace string) v1beta1.MirrorInterface { - return &FakeMirrors{c, namespace} +func (c *FakeMiniooperatorV1beta1) MirrorInstances(namespace string) v1beta1.MirrorInstanceInterface { + return &FakeMirrorInstances{c, namespace} } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FakeMinV1beta1) RESTClient() rest.Interface { +func (c *FakeMiniooperatorV1beta1) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } diff --git a/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/fake_mirrorinstance.go b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/fake_mirrorinstance.go new file mode 100644 index 00000000000..2fe07cd8880 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/fake/fake_mirrorinstance.go @@ -0,0 +1,130 @@ +/* +Copyright The Kubernetes 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeMirrorInstances implements MirrorInstanceInterface +type FakeMirrorInstances struct { + Fake *FakeMiniooperatorV1beta1 + ns string +} + +var mirrorinstancesResource = schema.GroupVersionResource{Group: "miniooperator.k8s.io", Version: "v1beta1", Resource: "mirrorinstances"} + +var mirrorinstancesKind = schema.GroupVersionKind{Group: "miniooperator.k8s.io", Version: "v1beta1", Kind: "MirrorInstance"} + +// Get takes name of the mirrorInstance, and returns the corresponding mirrorInstance object, and an error if there is any. +func (c *FakeMirrorInstances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.MirrorInstance, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(mirrorinstancesResource, c.ns, name), &v1beta1.MirrorInstance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.MirrorInstance), err +} + +// List takes label and field selectors, and returns the list of MirrorInstances that match those selectors. +func (c *FakeMirrorInstances) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MirrorInstanceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(mirrorinstancesResource, mirrorinstancesKind, c.ns, opts), &v1beta1.MirrorInstanceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.MirrorInstanceList{ListMeta: obj.(*v1beta1.MirrorInstanceList).ListMeta} + for _, item := range obj.(*v1beta1.MirrorInstanceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested mirrorInstances. +func (c *FakeMirrorInstances) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(mirrorinstancesResource, c.ns, opts)) + +} + +// Create takes the representation of a mirrorInstance and creates it. Returns the server's representation of the mirrorInstance, and an error, if there is any. +func (c *FakeMirrorInstances) Create(ctx context.Context, mirrorInstance *v1beta1.MirrorInstance, opts v1.CreateOptions) (result *v1beta1.MirrorInstance, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(mirrorinstancesResource, c.ns, mirrorInstance), &v1beta1.MirrorInstance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.MirrorInstance), err +} + +// Update takes the representation of a mirrorInstance and updates it. Returns the server's representation of the mirrorInstance, and an error, if there is any. +func (c *FakeMirrorInstances) Update(ctx context.Context, mirrorInstance *v1beta1.MirrorInstance, opts v1.UpdateOptions) (result *v1beta1.MirrorInstance, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(mirrorinstancesResource, c.ns, mirrorInstance), &v1beta1.MirrorInstance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.MirrorInstance), err +} + +// Delete takes name of the mirrorInstance and deletes it. Returns an error if one occurs. +func (c *FakeMirrorInstances) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(mirrorinstancesResource, c.ns, name), &v1beta1.MirrorInstance{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeMirrorInstances) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(mirrorinstancesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.MirrorInstanceList{}) + return err +} + +// Patch applies the patch and returns the patched mirrorInstance. +func (c *FakeMirrorInstances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MirrorInstance, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(mirrorinstancesResource, c.ns, name, pt, data, subresources...), &v1beta1.MirrorInstance{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.MirrorInstance), err +} diff --git a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/generated_expansion.go b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/generated_expansion.go similarity index 94% rename from pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/generated_expansion.go rename to pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/generated_expansion.go index f637b220a5d..06ff055ab6f 100644 --- a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/generated_expansion.go @@ -20,4 +20,4 @@ package v1beta1 type MinIOInstanceExpansion interface{} -type MirrorExpansion interface{} +type MirrorInstanceExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/minioinstance.go b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/minioinstance.go similarity index 60% rename from pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/minioinstance.go rename to pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/minioinstance.go index deb0671bb79..1e08d9eb688 100644 --- a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/minioinstance.go +++ b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/minioinstance.go @@ -19,9 +19,10 @@ limitations under the License. package v1beta1 import ( + "context" "time" - v1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + v1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" scheme "github.com/minio/minio-operator/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -37,15 +38,15 @@ type MinIOInstancesGetter interface { // MinIOInstanceInterface has methods to work with MinIOInstance resources. type MinIOInstanceInterface interface { - Create(*v1beta1.MinIOInstance) (*v1beta1.MinIOInstance, error) - Update(*v1beta1.MinIOInstance) (*v1beta1.MinIOInstance, error) - UpdateStatus(*v1beta1.MinIOInstance) (*v1beta1.MinIOInstance, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.MinIOInstance, error) - List(opts v1.ListOptions) (*v1beta1.MinIOInstanceList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.MinIOInstance, err error) + Create(ctx context.Context, minIOInstance *v1beta1.MinIOInstance, opts v1.CreateOptions) (*v1beta1.MinIOInstance, error) + Update(ctx context.Context, minIOInstance *v1beta1.MinIOInstance, opts v1.UpdateOptions) (*v1beta1.MinIOInstance, error) + UpdateStatus(ctx context.Context, minIOInstance *v1beta1.MinIOInstance, opts v1.UpdateOptions) (*v1beta1.MinIOInstance, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.MinIOInstance, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.MinIOInstanceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MinIOInstance, err error) MinIOInstanceExpansion } @@ -56,7 +57,7 @@ type minIOInstances struct { } // newMinIOInstances returns a MinIOInstances -func newMinIOInstances(c *MinV1beta1Client, namespace string) *minIOInstances { +func newMinIOInstances(c *MiniooperatorV1beta1Client, namespace string) *minIOInstances { return &minIOInstances{ client: c.RESTClient(), ns: namespace, @@ -64,20 +65,20 @@ func newMinIOInstances(c *MinV1beta1Client, namespace string) *minIOInstances { } // Get takes name of the minIOInstance, and returns the corresponding minIOInstance object, and an error if there is any. -func (c *minIOInstances) Get(name string, options v1.GetOptions) (result *v1beta1.MinIOInstance, err error) { +func (c *minIOInstances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.MinIOInstance, err error) { result = &v1beta1.MinIOInstance{} err = c.client.Get(). Namespace(c.ns). Resource("minioinstances"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of MinIOInstances that match those selectors. -func (c *minIOInstances) List(opts v1.ListOptions) (result *v1beta1.MinIOInstanceList, err error) { +func (c *minIOInstances) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MinIOInstanceList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -88,13 +89,13 @@ func (c *minIOInstances) List(opts v1.ListOptions) (result *v1beta1.MinIOInstanc Resource("minioinstances"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested minIOInstances. -func (c *minIOInstances) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *minIOInstances) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -105,87 +106,90 @@ func (c *minIOInstances) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("minioinstances"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a minIOInstance and creates it. Returns the server's representation of the minIOInstance, and an error, if there is any. -func (c *minIOInstances) Create(minIOInstance *v1beta1.MinIOInstance) (result *v1beta1.MinIOInstance, err error) { +func (c *minIOInstances) Create(ctx context.Context, minIOInstance *v1beta1.MinIOInstance, opts v1.CreateOptions) (result *v1beta1.MinIOInstance, err error) { result = &v1beta1.MinIOInstance{} err = c.client.Post(). Namespace(c.ns). Resource("minioinstances"). + VersionedParams(&opts, scheme.ParameterCodec). Body(minIOInstance). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a minIOInstance and updates it. Returns the server's representation of the minIOInstance, and an error, if there is any. -func (c *minIOInstances) Update(minIOInstance *v1beta1.MinIOInstance) (result *v1beta1.MinIOInstance, err error) { +func (c *minIOInstances) Update(ctx context.Context, minIOInstance *v1beta1.MinIOInstance, opts v1.UpdateOptions) (result *v1beta1.MinIOInstance, err error) { result = &v1beta1.MinIOInstance{} err = c.client.Put(). Namespace(c.ns). Resource("minioinstances"). Name(minIOInstance.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(minIOInstance). - Do(). + Do(ctx). Into(result) return } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *minIOInstances) UpdateStatus(minIOInstance *v1beta1.MinIOInstance) (result *v1beta1.MinIOInstance, err error) { +func (c *minIOInstances) UpdateStatus(ctx context.Context, minIOInstance *v1beta1.MinIOInstance, opts v1.UpdateOptions) (result *v1beta1.MinIOInstance, err error) { result = &v1beta1.MinIOInstance{} err = c.client.Put(). Namespace(c.ns). Resource("minioinstances"). Name(minIOInstance.Name). SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). Body(minIOInstance). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the minIOInstance and deletes it. Returns an error if one occurs. -func (c *minIOInstances) Delete(name string, options *v1.DeleteOptions) error { +func (c *minIOInstances) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("minioinstances"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *minIOInstances) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *minIOInstances) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("minioinstances"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched minIOInstance. -func (c *minIOInstances) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.MinIOInstance, err error) { +func (c *minIOInstances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MinIOInstance, err error) { result = &v1beta1.MinIOInstance{} err = c.client.Patch(pt). Namespace(c.ns). Resource("minioinstances"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/miniocontroller_client.go b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/miniooperator.min.io_client.go similarity index 57% rename from pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/miniocontroller_client.go rename to pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/miniooperator.min.io_client.go index 96d4c4cded0..fdeca19f600 100644 --- a/pkg/client/clientset/versioned/typed/miniocontroller/v1beta1/miniocontroller_client.go +++ b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/miniooperator.min.io_client.go @@ -19,33 +19,32 @@ limitations under the License. package v1beta1 import ( - v1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + v1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" "github.com/minio/minio-operator/pkg/client/clientset/versioned/scheme" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" rest "k8s.io/client-go/rest" ) -type MinV1beta1Interface interface { +type MiniooperatorV1beta1Interface interface { RESTClient() rest.Interface MinIOInstancesGetter - MirrorsGetter + MirrorInstancesGetter } -// MinV1beta1Client is used to interact with features provided by the min.io.io group. -type MinV1beta1Client struct { +// MiniooperatorV1beta1Client is used to interact with features provided by the miniooperator.k8s.io group. +type MiniooperatorV1beta1Client struct { restClient rest.Interface } -func (c *MinV1beta1Client) MinIOInstances(namespace string) MinIOInstanceInterface { +func (c *MiniooperatorV1beta1Client) MinIOInstances(namespace string) MinIOInstanceInterface { return newMinIOInstances(c, namespace) } -func (c *MinV1beta1Client) Mirrors(namespace string) MirrorInterface { - return newMirrors(c, namespace) +func (c *MiniooperatorV1beta1Client) MirrorInstances(namespace string) MirrorInstanceInterface { + return newMirrorInstances(c, namespace) } -// NewForConfig creates a new MinV1beta1Client for the given config. -func NewForConfig(c *rest.Config) (*MinV1beta1Client, error) { +// NewForConfig creates a new MiniooperatorV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*MiniooperatorV1beta1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -54,12 +53,12 @@ func NewForConfig(c *rest.Config) (*MinV1beta1Client, error) { if err != nil { return nil, err } - return &MinV1beta1Client{client}, nil + return &MiniooperatorV1beta1Client{client}, nil } -// NewForConfigOrDie creates a new MinV1beta1Client for the given config and +// NewForConfigOrDie creates a new MiniooperatorV1beta1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *MinV1beta1Client { +func NewForConfigOrDie(c *rest.Config) *MiniooperatorV1beta1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -67,16 +66,16 @@ func NewForConfigOrDie(c *rest.Config) *MinV1beta1Client { return client } -// New creates a new MinV1beta1Client for the given RESTClient. -func New(c rest.Interface) *MinV1beta1Client { - return &MinV1beta1Client{c} +// New creates a new MiniooperatorV1beta1Client for the given RESTClient. +func New(c rest.Interface) *MiniooperatorV1beta1Client { + return &MiniooperatorV1beta1Client{c} } func setConfigDefaults(config *rest.Config) error { gv := v1beta1.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" - config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() if config.UserAgent == "" { config.UserAgent = rest.DefaultKubernetesUserAgent() @@ -87,7 +86,7 @@ func setConfigDefaults(config *rest.Config) error { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *MinV1beta1Client) RESTClient() rest.Interface { +func (c *MiniooperatorV1beta1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/mirrorinstance.go b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/mirrorinstance.go new file mode 100644 index 00000000000..7fa10baa01a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/miniooperator.min.io/v1beta1/mirrorinstance.go @@ -0,0 +1,178 @@ +/* +Copyright The Kubernetes 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + v1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" + scheme "github.com/minio/minio-operator/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// MirrorInstancesGetter has a method to return a MirrorInstanceInterface. +// A group's client should implement this interface. +type MirrorInstancesGetter interface { + MirrorInstances(namespace string) MirrorInstanceInterface +} + +// MirrorInstanceInterface has methods to work with MirrorInstance resources. +type MirrorInstanceInterface interface { + Create(ctx context.Context, mirrorInstance *v1beta1.MirrorInstance, opts v1.CreateOptions) (*v1beta1.MirrorInstance, error) + Update(ctx context.Context, mirrorInstance *v1beta1.MirrorInstance, opts v1.UpdateOptions) (*v1beta1.MirrorInstance, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.MirrorInstance, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.MirrorInstanceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MirrorInstance, err error) + MirrorInstanceExpansion +} + +// mirrorInstances implements MirrorInstanceInterface +type mirrorInstances struct { + client rest.Interface + ns string +} + +// newMirrorInstances returns a MirrorInstances +func newMirrorInstances(c *MiniooperatorV1beta1Client, namespace string) *mirrorInstances { + return &mirrorInstances{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the mirrorInstance, and returns the corresponding mirrorInstance object, and an error if there is any. +func (c *mirrorInstances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.MirrorInstance, err error) { + result = &v1beta1.MirrorInstance{} + err = c.client.Get(). + Namespace(c.ns). + Resource("mirrorinstances"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of MirrorInstances that match those selectors. +func (c *mirrorInstances) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MirrorInstanceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.MirrorInstanceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("mirrorinstances"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested mirrorInstances. +func (c *mirrorInstances) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("mirrorinstances"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a mirrorInstance and creates it. Returns the server's representation of the mirrorInstance, and an error, if there is any. +func (c *mirrorInstances) Create(ctx context.Context, mirrorInstance *v1beta1.MirrorInstance, opts v1.CreateOptions) (result *v1beta1.MirrorInstance, err error) { + result = &v1beta1.MirrorInstance{} + err = c.client.Post(). + Namespace(c.ns). + Resource("mirrorinstances"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(mirrorInstance). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a mirrorInstance and updates it. Returns the server's representation of the mirrorInstance, and an error, if there is any. +func (c *mirrorInstances) Update(ctx context.Context, mirrorInstance *v1beta1.MirrorInstance, opts v1.UpdateOptions) (result *v1beta1.MirrorInstance, err error) { + result = &v1beta1.MirrorInstance{} + err = c.client.Put(). + Namespace(c.ns). + Resource("mirrorinstances"). + Name(mirrorInstance.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(mirrorInstance). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the mirrorInstance and deletes it. Returns an error if one occurs. +func (c *mirrorInstances) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("mirrorinstances"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *mirrorInstances) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("mirrorinstances"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched mirrorInstance. +func (c *mirrorInstances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MirrorInstance, err error) { + result = &v1beta1.MirrorInstance{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("mirrorinstances"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index c424a112eff..15068f6edf9 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -25,7 +25,7 @@ import ( versioned "github.com/minio/minio-operator/pkg/client/clientset/versioned" internalinterfaces "github.com/minio/minio-operator/pkg/client/informers/externalversions/internalinterfaces" - miniocontroller "github.com/minio/minio-operator/pkg/client/informers/externalversions/miniocontroller" + miniooperatorminio "github.com/minio/minio-operator/pkg/client/informers/externalversions/miniooperator.min.io" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -172,9 +172,9 @@ type SharedInformerFactory interface { ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - Min() miniocontroller.Interface + Miniooperator() miniooperatorminio.Interface } -func (f *sharedInformerFactory) Min() miniocontroller.Interface { - return miniocontroller.New(f, f.namespace, f.tweakListOptions) +func (f *sharedInformerFactory) Miniooperator() miniooperatorminio.Interface { + return miniooperatorminio.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index e8843e165bf..aafc1945d8c 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -21,7 +21,7 @@ package externalversions import ( "fmt" - v1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + v1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -52,11 +52,11 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=min.io.io, Version=v1beta1 + // Group=miniooperator.k8s.io, Version=v1beta1 case v1beta1.SchemeGroupVersion.WithResource("minioinstances"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Min().V1beta1().MinIOInstances().Informer()}, nil - case v1beta1.SchemeGroupVersion.WithResource("mirrors"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Min().V1beta1().Mirrors().Informer()}, nil + return &genericInformer{resource: resource.GroupResource(), informer: f.Miniooperator().V1beta1().MinIOInstances().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("mirrorinstances"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Miniooperator().V1beta1().MirrorInstances().Informer()}, nil } diff --git a/pkg/client/informers/externalversions/miniocontroller/interface.go b/pkg/client/informers/externalversions/miniooperator.min.io/interface.go similarity index 95% rename from pkg/client/informers/externalversions/miniocontroller/interface.go rename to pkg/client/informers/externalversions/miniooperator.min.io/interface.go index 638e32f5583..6603eba7b3c 100644 --- a/pkg/client/informers/externalversions/miniocontroller/interface.go +++ b/pkg/client/informers/externalversions/miniooperator.min.io/interface.go @@ -16,11 +16,11 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package min +package miniooperator import ( internalinterfaces "github.com/minio/minio-operator/pkg/client/informers/externalversions/internalinterfaces" - v1beta1 "github.com/minio/minio-operator/pkg/client/informers/externalversions/miniocontroller/v1beta1" + v1beta1 "github.com/minio/minio-operator/pkg/client/informers/externalversions/miniooperator.min.io/v1beta1" ) // Interface provides access to each of this group's versions. diff --git a/pkg/client/informers/externalversions/miniocontroller/v1beta1/interface.go b/pkg/client/informers/externalversions/miniooperator.min.io/v1beta1/interface.go similarity index 83% rename from pkg/client/informers/externalversions/miniocontroller/v1beta1/interface.go rename to pkg/client/informers/externalversions/miniooperator.min.io/v1beta1/interface.go index f373dfdc8cb..40a2e0f5396 100644 --- a/pkg/client/informers/externalversions/miniocontroller/v1beta1/interface.go +++ b/pkg/client/informers/externalversions/miniooperator.min.io/v1beta1/interface.go @@ -26,8 +26,8 @@ import ( type Interface interface { // MinIOInstances returns a MinIOInstanceInformer. MinIOInstances() MinIOInstanceInformer - // Mirrors returns a MirrorInformer. - Mirrors() MirrorInformer + // MirrorInstances returns a MirrorInstanceInformer. + MirrorInstances() MirrorInstanceInformer } type version struct { @@ -46,7 +46,7 @@ func (v *version) MinIOInstances() MinIOInstanceInformer { return &minIOInstanceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } -// Mirrors returns a MirrorInformer. -func (v *version) Mirrors() MirrorInformer { - return &mirrorInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +// MirrorInstances returns a MirrorInstanceInformer. +func (v *version) MirrorInstances() MirrorInstanceInformer { + return &mirrorInstanceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } diff --git a/pkg/client/informers/externalversions/miniocontroller/v1beta1/minioinstance.go b/pkg/client/informers/externalversions/miniooperator.min.io/v1beta1/minioinstance.go similarity index 87% rename from pkg/client/informers/externalversions/miniocontroller/v1beta1/minioinstance.go rename to pkg/client/informers/externalversions/miniooperator.min.io/v1beta1/minioinstance.go index d60837550b5..ea0edc0c2d8 100644 --- a/pkg/client/informers/externalversions/miniocontroller/v1beta1/minioinstance.go +++ b/pkg/client/informers/externalversions/miniooperator.min.io/v1beta1/minioinstance.go @@ -19,12 +19,13 @@ limitations under the License. package v1beta1 import ( + "context" time "time" - miniocontrollerv1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + miniooperatorminiov1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" versioned "github.com/minio/minio-operator/pkg/client/clientset/versioned" internalinterfaces "github.com/minio/minio-operator/pkg/client/informers/externalversions/internalinterfaces" - v1beta1 "github.com/minio/minio-operator/pkg/client/listers/miniocontroller/v1beta1" + v1beta1 "github.com/minio/minio-operator/pkg/client/listers/miniooperator.min.io/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -61,16 +62,16 @@ func NewFilteredMinIOInstanceInformer(client versioned.Interface, namespace stri if tweakListOptions != nil { tweakListOptions(&options) } - return client.MinV1beta1().MinIOInstances(namespace).List(options) + return client.MiniooperatorV1beta1().MinIOInstances(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MinV1beta1().MinIOInstances(namespace).Watch(options) + return client.MiniooperatorV1beta1().MinIOInstances(namespace).Watch(context.TODO(), options) }, }, - &miniocontrollerv1beta1.MinIOInstance{}, + &miniooperatorminiov1beta1.MinIOInstance{}, resyncPeriod, indexers, ) @@ -81,7 +82,7 @@ func (f *minIOInstanceInformer) defaultInformer(client versioned.Interface, resy } func (f *minIOInstanceInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&miniocontrollerv1beta1.MinIOInstance{}, f.defaultInformer) + return f.factory.InformerFor(&miniooperatorminiov1beta1.MinIOInstance{}, f.defaultInformer) } func (f *minIOInstanceInformer) Lister() v1beta1.MinIOInstanceLister { diff --git a/pkg/client/informers/externalversions/miniocontroller/v1beta1/mirror.go b/pkg/client/informers/externalversions/miniooperator.min.io/v1beta1/mirrorinstance.go similarity index 54% rename from pkg/client/informers/externalversions/miniocontroller/v1beta1/mirror.go rename to pkg/client/informers/externalversions/miniooperator.min.io/v1beta1/mirrorinstance.go index 6f43ff9170a..ee5ee1b4107 100644 --- a/pkg/client/informers/externalversions/miniocontroller/v1beta1/mirror.go +++ b/pkg/client/informers/externalversions/miniooperator.min.io/v1beta1/mirrorinstance.go @@ -19,71 +19,72 @@ limitations under the License. package v1beta1 import ( + "context" time "time" - miniocontrollerv1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + miniooperatorminiov1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" versioned "github.com/minio/minio-operator/pkg/client/clientset/versioned" internalinterfaces "github.com/minio/minio-operator/pkg/client/informers/externalversions/internalinterfaces" - v1beta1 "github.com/minio/minio-operator/pkg/client/listers/miniocontroller/v1beta1" + v1beta1 "github.com/minio/minio-operator/pkg/client/listers/miniooperator.min.io/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" cache "k8s.io/client-go/tools/cache" ) -// MirrorInformer provides access to a shared informer and lister for -// Mirrors. -type MirrorInformer interface { +// MirrorInstanceInformer provides access to a shared informer and lister for +// MirrorInstances. +type MirrorInstanceInformer interface { Informer() cache.SharedIndexInformer - Lister() v1beta1.MirrorLister + Lister() v1beta1.MirrorInstanceLister } -type mirrorInformer struct { +type mirrorInstanceInformer struct { factory internalinterfaces.SharedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc namespace string } -// NewMirrorInformer constructs a new informer for Mirror type. +// NewMirrorInstanceInformer constructs a new informer for MirrorInstance type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewMirrorInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredMirrorInformer(client, namespace, resyncPeriod, indexers, nil) +func NewMirrorInstanceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredMirrorInstanceInformer(client, namespace, resyncPeriod, indexers, nil) } -// NewFilteredMirrorInformer constructs a new informer for Mirror type. +// NewFilteredMirrorInstanceInformer constructs a new informer for MirrorInstance type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredMirrorInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +func NewFilteredMirrorInstanceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MinV1beta1().Mirrors(namespace).List(options) + return client.MiniooperatorV1beta1().MirrorInstances(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.MinV1beta1().Mirrors(namespace).Watch(options) + return client.MiniooperatorV1beta1().MirrorInstances(namespace).Watch(context.TODO(), options) }, }, - &miniocontrollerv1beta1.Mirror{}, + &miniooperatorminiov1beta1.MirrorInstance{}, resyncPeriod, indexers, ) } -func (f *mirrorInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredMirrorInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +func (f *mirrorInstanceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredMirrorInstanceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) } -func (f *mirrorInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&miniocontrollerv1beta1.Mirror{}, f.defaultInformer) +func (f *mirrorInstanceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&miniooperatorminiov1beta1.MirrorInstance{}, f.defaultInformer) } -func (f *mirrorInformer) Lister() v1beta1.MirrorLister { - return v1beta1.NewMirrorLister(f.Informer().GetIndexer()) +func (f *mirrorInstanceInformer) Lister() v1beta1.MirrorInstanceLister { + return v1beta1.NewMirrorInstanceLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/listers/miniocontroller/v1beta1/mirror.go b/pkg/client/listers/miniocontroller/v1beta1/mirror.go deleted file mode 100644 index 48ea1acae6e..00000000000 --- a/pkg/client/listers/miniocontroller/v1beta1/mirror.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright The Kubernetes 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. -*/ - -// Code generated by lister-gen. DO NOT EDIT. - -package v1beta1 - -import ( - v1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// MirrorLister helps list Mirrors. -type MirrorLister interface { - // List lists all Mirrors in the indexer. - List(selector labels.Selector) (ret []*v1beta1.Mirror, err error) - // Mirrors returns an object that can list and get Mirrors. - Mirrors(namespace string) MirrorNamespaceLister - MirrorListerExpansion -} - -// mirrorLister implements the MirrorLister interface. -type mirrorLister struct { - indexer cache.Indexer -} - -// NewMirrorLister returns a new MirrorLister. -func NewMirrorLister(indexer cache.Indexer) MirrorLister { - return &mirrorLister{indexer: indexer} -} - -// List lists all Mirrors in the indexer. -func (s *mirrorLister) List(selector labels.Selector) (ret []*v1beta1.Mirror, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Mirror)) - }) - return ret, err -} - -// Mirrors returns an object that can list and get Mirrors. -func (s *mirrorLister) Mirrors(namespace string) MirrorNamespaceLister { - return mirrorNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// MirrorNamespaceLister helps list and get Mirrors. -type MirrorNamespaceLister interface { - // List lists all Mirrors in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1beta1.Mirror, err error) - // Get retrieves the Mirror from the indexer for a given namespace and name. - Get(name string) (*v1beta1.Mirror, error) - MirrorNamespaceListerExpansion -} - -// mirrorNamespaceLister implements the MirrorNamespaceLister -// interface. -type mirrorNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Mirrors in the indexer for a given namespace. -func (s mirrorNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Mirror, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Mirror)) - }) - return ret, err -} - -// Get retrieves the Mirror from the indexer for a given namespace and name. -func (s mirrorNamespaceLister) Get(name string) (*v1beta1.Mirror, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("mirror"), name) - } - return obj.(*v1beta1.Mirror), nil -} diff --git a/pkg/client/listers/miniocontroller/v1beta1/expansion_generated.go b/pkg/client/listers/miniooperator.min.io/v1beta1/expansion_generated.go similarity index 75% rename from pkg/client/listers/miniocontroller/v1beta1/expansion_generated.go rename to pkg/client/listers/miniooperator.min.io/v1beta1/expansion_generated.go index bf597b06ccb..8fe93f15a8e 100644 --- a/pkg/client/listers/miniocontroller/v1beta1/expansion_generated.go +++ b/pkg/client/listers/miniooperator.min.io/v1beta1/expansion_generated.go @@ -26,10 +26,10 @@ type MinIOInstanceListerExpansion interface{} // MinIOInstanceNamespaceLister. type MinIOInstanceNamespaceListerExpansion interface{} -// MirrorListerExpansion allows custom methods to be added to -// MirrorLister. -type MirrorListerExpansion interface{} +// MirrorInstanceListerExpansion allows custom methods to be added to +// MirrorInstanceLister. +type MirrorInstanceListerExpansion interface{} -// MirrorNamespaceListerExpansion allows custom methods to be added to -// MirrorNamespaceLister. -type MirrorNamespaceListerExpansion interface{} +// MirrorInstanceNamespaceListerExpansion allows custom methods to be added to +// MirrorInstanceNamespaceLister. +type MirrorInstanceNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/miniocontroller/v1beta1/minioinstance.go b/pkg/client/listers/miniooperator.min.io/v1beta1/minioinstance.go similarity index 90% rename from pkg/client/listers/miniocontroller/v1beta1/minioinstance.go rename to pkg/client/listers/miniooperator.min.io/v1beta1/minioinstance.go index f570dcb86cd..34eea8d74f3 100644 --- a/pkg/client/listers/miniocontroller/v1beta1/minioinstance.go +++ b/pkg/client/listers/miniooperator.min.io/v1beta1/minioinstance.go @@ -19,15 +19,17 @@ limitations under the License. package v1beta1 import ( - v1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + v1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" ) // MinIOInstanceLister helps list MinIOInstances. +// All objects returned here must be treated as read-only. type MinIOInstanceLister interface { // List lists all MinIOInstances in the indexer. + // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*v1beta1.MinIOInstance, err error) // MinIOInstances returns an object that can list and get MinIOInstances. MinIOInstances(namespace string) MinIOInstanceNamespaceLister @@ -58,10 +60,13 @@ func (s *minIOInstanceLister) MinIOInstances(namespace string) MinIOInstanceName } // MinIOInstanceNamespaceLister helps list and get MinIOInstances. +// All objects returned here must be treated as read-only. type MinIOInstanceNamespaceLister interface { // List lists all MinIOInstances in the indexer for a given namespace. + // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []*v1beta1.MinIOInstance, err error) // Get retrieves the MinIOInstance from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. Get(name string) (*v1beta1.MinIOInstance, error) MinIOInstanceNamespaceListerExpansion } diff --git a/pkg/client/listers/miniooperator.min.io/v1beta1/mirrorinstance.go b/pkg/client/listers/miniooperator.min.io/v1beta1/mirrorinstance.go new file mode 100644 index 00000000000..bd4d61116fc --- /dev/null +++ b/pkg/client/listers/miniooperator.min.io/v1beta1/mirrorinstance.go @@ -0,0 +1,99 @@ +/* +Copyright The Kubernetes 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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// MirrorInstanceLister helps list MirrorInstances. +// All objects returned here must be treated as read-only. +type MirrorInstanceLister interface { + // List lists all MirrorInstances in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.MirrorInstance, err error) + // MirrorInstances returns an object that can list and get MirrorInstances. + MirrorInstances(namespace string) MirrorInstanceNamespaceLister + MirrorInstanceListerExpansion +} + +// mirrorInstanceLister implements the MirrorInstanceLister interface. +type mirrorInstanceLister struct { + indexer cache.Indexer +} + +// NewMirrorInstanceLister returns a new MirrorInstanceLister. +func NewMirrorInstanceLister(indexer cache.Indexer) MirrorInstanceLister { + return &mirrorInstanceLister{indexer: indexer} +} + +// List lists all MirrorInstances in the indexer. +func (s *mirrorInstanceLister) List(selector labels.Selector) (ret []*v1beta1.MirrorInstance, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.MirrorInstance)) + }) + return ret, err +} + +// MirrorInstances returns an object that can list and get MirrorInstances. +func (s *mirrorInstanceLister) MirrorInstances(namespace string) MirrorInstanceNamespaceLister { + return mirrorInstanceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// MirrorInstanceNamespaceLister helps list and get MirrorInstances. +// All objects returned here must be treated as read-only. +type MirrorInstanceNamespaceLister interface { + // List lists all MirrorInstances in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.MirrorInstance, err error) + // Get retrieves the MirrorInstance from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta1.MirrorInstance, error) + MirrorInstanceNamespaceListerExpansion +} + +// mirrorInstanceNamespaceLister implements the MirrorInstanceNamespaceLister +// interface. +type mirrorInstanceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all MirrorInstances in the indexer for a given namespace. +func (s mirrorInstanceNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.MirrorInstance, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.MirrorInstance)) + }) + return ret, err +} + +// Get retrieves the MirrorInstance from the indexer for a given namespace and name. +func (s mirrorInstanceNamespaceLister) Get(name string) (*v1beta1.MirrorInstance, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("mirrorinstance"), name) + } + return obj.(*v1beta1.MirrorInstance), nil +} diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 849952f7392..2aadc888c27 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -45,7 +45,7 @@ const MinIOVolumeMountPath = "/export" const MinIOVolumeSubPath = "" // DefaultMinIOImage specifies the default MinIO Docker hub image -const DefaultMinIOImage = "minio/minio:RELEASE.2020-04-15T00-39-01Z" +const DefaultMinIOImage = "minio/minio:RELEASE.2020-04-23T00-58-49Z" // MinIOServerName specifies the default container name for MinIOInstance const MinIOServerName = "minio" @@ -73,6 +73,9 @@ const HeadlessServiceNameSuffix = "-hl-svc" // CSRNameSuffix specifies the suffix added to MinIOInstance name to create a CSR const CSRNameSuffix = "-csr" +// ClusterCRDResourceKind is the Kind of a Cluster. +const ClusterCRDResourceKind = "MinIOInstance" + // Auto TLS related constants // DefaultEllipticCurve specifies the default elliptic curve to be used for key generation diff --git a/pkg/controller/cluster/csr.go b/pkg/controller/cluster/csr.go index c7adcd4a434..8ca796c958a 100644 --- a/pkg/controller/cluster/csr.go +++ b/pkg/controller/cluster/csr.go @@ -18,6 +18,7 @@ package cluster import ( + "context" "crypto/ecdsa" "crypto/elliptic" "crypto/rand" @@ -32,7 +33,7 @@ import ( "github.com/golang/glog" - miniov1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + miniov1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" "github.com/minio/minio-operator/pkg/constants" certificates "k8s.io/api/certificates/v1beta1" @@ -106,7 +107,7 @@ func generateCryptoData(mi *miniov1beta1.MinIOInstance) ([]byte, []byte, error) // createCSR handles all the steps required to create the CSR: from creation of keys, submitting CSR and // finally creating a secret that MinIO statefulset will use to mount private key and certificate for TLS -func (c *Controller) createCSR(mi *miniov1beta1.MinIOInstance) error { +func (c *Controller) createCSR(ctx context.Context, mi *miniov1beta1.MinIOInstance) error { privKeysBytes, csrBytes, err := generateCryptoData(mi) if err != nil { glog.Errorf("Private Key and CSR generation failed with error: %v", err) @@ -114,7 +115,7 @@ func (c *Controller) createCSR(mi *miniov1beta1.MinIOInstance) error { } glog.V(2).Infof("Creating csr/%s", mi.GetCSRName()) - err = c.submitCSR(mi, csrBytes) + err = c.submitCSR(ctx, mi, csrBytes) if err != nil { glog.Errorf("Unexpected error during the creation of the csr/%s: %v", mi.GetCSRName(), err) return err @@ -122,7 +123,7 @@ func (c *Controller) createCSR(mi *miniov1beta1.MinIOInstance) error { glog.V(0).Infof("Successfully created csr/%s", mi.GetCSRName()) // fetch certificate from CSR - certbytes, err := c.fetchCertificate(mi.GetCSRName()) + certbytes, err := c.fetchCertificate(ctx, mi.GetCSRName()) if err != nil { glog.Errorf("Unexpected error during the creation of the csr/%s: %v", mi.GetCSRName(), err) return err @@ -130,7 +131,7 @@ func (c *Controller) createCSR(mi *miniov1beta1.MinIOInstance) error { // PEM encode private ECDSA key encodedPrivKey := pem.EncodeToMemory(&pem.Block{Type: privateKeyType, Bytes: privKeysBytes}) // Create secret for MinIO Statefulset to use - err = c.createSecret(mi, encodedPrivKey, certbytes) + err = c.createSecret(ctx, mi, encodedPrivKey, certbytes) if err != nil { glog.Errorf("Unexpected error during the creation of the secret/%s: %v", mi.GetTLSSecretName(), err) return err @@ -139,7 +140,7 @@ func (c *Controller) createCSR(mi *miniov1beta1.MinIOInstance) error { } // SubmitCSR is equivalent to kubectl create ${CSR}, if the override is configured, it becomes kubectl apply ${CSR} -func (c *Controller) submitCSR(mi *miniov1beta1.MinIOInstance, csrBytes []byte) error { +func (c *Controller) submitCSR(ctx context.Context, mi *miniov1beta1.MinIOInstance, csrBytes []byte) error { encodedBytes := pem.EncodeToMemory(&pem.Block{Type: csrType, Bytes: csrBytes}) kubeCSR := &certificates.CertificateSigningRequest{ @@ -155,7 +156,7 @@ func (c *Controller) submitCSR(mi *miniov1beta1.MinIOInstance, csrBytes []byte) *metav1.NewControllerRef(mi, schema.GroupVersionKind{ Group: miniov1beta1.SchemeGroupVersion.Group, Version: miniov1beta1.SchemeGroupVersion.Version, - Kind: miniov1beta1.ClusterCRDResourceKind, + Kind: constants.ClusterCRDResourceKind, }), }, }, @@ -169,8 +170,8 @@ func (c *Controller) submitCSR(mi *miniov1beta1.MinIOInstance, csrBytes []byte) }, }, } - - _, err := c.certClient.CertificateSigningRequests().Create(kubeCSR) + cOpts := metav1.CreateOptions{} + _, err := c.certClient.CertificateSigningRequests().Create(ctx, kubeCSR, cOpts) if err != nil { return err } @@ -178,7 +179,7 @@ func (c *Controller) submitCSR(mi *miniov1beta1.MinIOInstance, csrBytes []byte) } // FetchCertificate fetches the generated certificate from the CSR -func (c *Controller) fetchCertificate(csrName string) ([]byte, error) { +func (c *Controller) fetchCertificate(ctx context.Context, csrName string) ([]byte, error) { glog.V(0).Infof("Start polling for certificate of csr/%s, every %s, timeout after %s", csrName, constants.DefaultQueryInterval, constants.DefaultQueryTimeout) @@ -199,7 +200,7 @@ func (c *Controller) fetchCertificate(csrName string) ([]byte, error) { return nil, fmt.Errorf("%s", s.String()) case <-tick.C: - r, err := c.certClient.CertificateSigningRequests().Get(csrName, v1.GetOptions{}) + r, err := c.certClient.CertificateSigningRequests().Get(ctx, csrName, v1.GetOptions{}) if err != nil { glog.Errorf("Unexpected error during certificate fetching of csr/%s: %s", csrName, err) return nil, err @@ -223,7 +224,7 @@ func (c *Controller) fetchCertificate(csrName string) ([]byte, error) { } } -func (c *Controller) createSecret(mi *miniov1beta1.MinIOInstance, pkBytes, certBytes []byte) error { +func (c *Controller) createSecret(ctx context.Context, mi *miniov1beta1.MinIOInstance, pkBytes, certBytes []byte) error { secret := &corev1.Secret{ Type: "Opaque", TypeMeta: metav1.TypeMeta{ @@ -238,7 +239,7 @@ func (c *Controller) createSecret(mi *miniov1beta1.MinIOInstance, pkBytes, certB *metav1.NewControllerRef(mi, schema.GroupVersionKind{ Group: miniov1beta1.SchemeGroupVersion.Group, Version: miniov1beta1.SchemeGroupVersion.Version, - Kind: miniov1beta1.ClusterCRDResourceKind, + Kind: constants.ClusterCRDResourceKind, }), }, }, @@ -247,7 +248,8 @@ func (c *Controller) createSecret(mi *miniov1beta1.MinIOInstance, pkBytes, certB "public.crt": certBytes, }, } - _, err := c.kubeClientSet.CoreV1().Secrets(mi.Namespace).Create(secret) + cOpts := metav1.CreateOptions{} + _, err := c.kubeClientSet.CoreV1().Secrets(mi.Namespace).Create(ctx, secret, cOpts) if err != nil { return err } diff --git a/pkg/controller/cluster/controller.go b/pkg/controller/cluster/main_controller.go similarity index 94% rename from pkg/controller/cluster/controller.go rename to pkg/controller/cluster/main_controller.go index 2ad339f3ab2..b5c198d9b29 100644 --- a/pkg/controller/cluster/controller.go +++ b/pkg/controller/cluster/main_controller.go @@ -18,6 +18,7 @@ package cluster import ( + "context" "fmt" "time" @@ -43,11 +44,11 @@ import ( "k8s.io/client-go/tools/record" queue "k8s.io/client-go/util/workqueue" - miniov1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + miniov1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" clientset "github.com/minio/minio-operator/pkg/client/clientset/versioned" minioscheme "github.com/minio/minio-operator/pkg/client/clientset/versioned/scheme" - informers "github.com/minio/minio-operator/pkg/client/informers/externalversions/miniocontroller/v1beta1" - listers "github.com/minio/minio-operator/pkg/client/listers/miniocontroller/v1beta1" + informers "github.com/minio/minio-operator/pkg/client/informers/externalversions/miniooperator.min.io/v1beta1" + listers "github.com/minio/minio-operator/pkg/client/listers/miniooperator.min.io/v1beta1" "github.com/minio/minio-operator/pkg/resources/services" "github.com/minio/minio-operator/pkg/resources/statefulsets" ) @@ -266,6 +267,10 @@ func (c *Controller) processNextWorkItem() bool { // converge the two. It then updates the Status block of the MinIOInstance resource // with the current status of the resource. func (c *Controller) syncHandler(key string) error { + ctx := context.Background() + cOpts := metav1.CreateOptions{} + uOpts := metav1.UpdateOptions{} + // Convert the namespace/name string into a distinct namespace and name namespace, name, err := cache.SplitMetaNamespaceKey(key) glog.V(2).Infof("Key after splitting, namespace: %s, name: %s", namespace, name) @@ -294,7 +299,7 @@ func (c *Controller) syncHandler(key string) error { if apierrors.IsNotFound(err) { glog.V(2).Infof("Creating a new Headless Service for cluster %q", nsName) svc = services.NewForCluster(mi) - _, err = c.kubeClientSet.CoreV1().Services(svc.Namespace).Create(svc) + _, err = c.kubeClientSet.CoreV1().Services(svc.Namespace).Create(ctx, svc, cOpts) } // If an error occurs during Get/Create, we'll requeue the item so we can @@ -313,13 +318,13 @@ func (c *Controller) syncHandler(key string) error { } if mi.RequiresAutoCertSetup() { - _, err := c.certClient.CertificateSigningRequests().Get(mi.GetCSRName(), metav1.GetOptions{}) + _, err := c.certClient.CertificateSigningRequests().Get(ctx, mi.GetCSRName(), metav1.GetOptions{}) if err != nil { // If the CSR doesn't exist, we'll create it if apierrors.IsNotFound(err) { glog.V(2).Infof("Creating a new Certificate Signing Request for cluster %q", nsName) // create CSR here - c.createCSR(mi) + c.createCSR(ctx, mi) } else { return err } @@ -331,7 +336,7 @@ func (c *Controller) syncHandler(key string) error { // If the resource doesn't exist, we'll create it if apierrors.IsNotFound(err) { ss = statefulsets.NewForCluster(mi, svc.Name) - _, err = c.kubeClientSet.AppsV1().StatefulSets(mi.Namespace).Create(ss) + _, err = c.kubeClientSet.AppsV1().StatefulSets(mi.Namespace).Create(ctx, ss, cOpts) } // If an error occurs during Get/Create, we'll requeue the item so we can @@ -355,7 +360,14 @@ func (c *Controller) syncHandler(key string) error { if mi.GetReplicas() != *ss.Spec.Replicas { glog.V(4).Infof("MinIOInstance %s replicas: %d, StatefulSet replicas: %d", name, mi.GetReplicas(), *ss.Spec.Replicas) ss = statefulsets.NewForCluster(mi, svc.Name) - _, err = c.kubeClientSet.AppsV1().StatefulSets(mi.Namespace).Update(ss) + err = c.kubeClientSet.AppsV1().StatefulSets(mi.Namespace).Delete(ctx, ss.Name, metav1.DeleteOptions{}) + if err != nil { + return err + } + _, err = c.kubeClientSet.AppsV1().StatefulSets(mi.Namespace).Create(ctx, ss, cOpts) + if err != nil { + return err + } } // If this container version on the MinIOInstance resource is specified, and the @@ -364,7 +376,7 @@ func (c *Controller) syncHandler(key string) error { if mi.Spec.Image != ss.Spec.Template.Spec.Containers[0].Image { glog.V(4).Infof("Updating MinIOInstance %s MinIO server version %s, to: %s", name, mi.Spec.Image, ss.Spec.Template.Spec.Containers[0].Image) ss = statefulsets.NewForCluster(mi, svc.Name) - _, err = c.kubeClientSet.AppsV1().StatefulSets(mi.Namespace).Update(ss) + _, err = c.kubeClientSet.AppsV1().StatefulSets(mi.Namespace).Update(ctx, ss, uOpts) } // If an error occurs during Update, we'll requeue the item so we can @@ -376,7 +388,7 @@ func (c *Controller) syncHandler(key string) error { // Finally, we update the status block of the MinIOInstance resource to reflect the // current state of the world - err = c.updateMinIOInstanceStatus(mi, ss) + err = c.updateMinIOInstanceStatus(ctx, mi, ss) if err != nil { return err } @@ -384,7 +396,8 @@ func (c *Controller) syncHandler(key string) error { return nil } -func (c *Controller) updateMinIOInstanceStatus(minioInstance *miniov1beta1.MinIOInstance, statefulSet *appsv1.StatefulSet) error { +func (c *Controller) updateMinIOInstanceStatus(ctx context.Context, minioInstance *miniov1beta1.MinIOInstance, statefulSet *appsv1.StatefulSet) error { + opts := metav1.UpdateOptions{} // NEVER modify objects from the store. It's a read-only, local cache. // You can use DeepCopy() to make a deep copy of original object and modify this copy // Or create a copy manually for better performance @@ -394,7 +407,7 @@ func (c *Controller) updateMinIOInstanceStatus(minioInstance *miniov1beta1.MinIO // we must use Update instead of UpdateStatus to update the Status block of the MinIOInstance resource. // UpdateStatus will not allow changes to the Spec of the resource, // which is ideal for ensuring nothing other than resource status has been updated. - _, err := c.minioClientSet.MinV1beta1().MinIOInstances(minioInstance.Namespace).Update(minioInstanceCopy) + _, err := c.minioClientSet.MiniooperatorV1beta1().MinIOInstances(minioInstance.Namespace).Update(ctx, minioInstanceCopy, opts) return err } diff --git a/pkg/controller/mirror/mirror_controller.go b/pkg/controller/mirror/mirror_controller.go index 10c52833bfc..7455cc0e087 100644 --- a/pkg/controller/mirror/mirror_controller.go +++ b/pkg/controller/mirror/mirror_controller.go @@ -27,72 +27,59 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" appsinformers "k8s.io/client-go/informers/apps/v1" - coreinformers "k8s.io/client-go/informers/core/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" appslisters "k8s.io/client-go/listers/apps/v1" - corelisters "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" queue "k8s.io/client-go/util/workqueue" - miniov1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" clientset "github.com/minio/minio-operator/pkg/client/clientset/versioned" minioscheme "github.com/minio/minio-operator/pkg/client/clientset/versioned/scheme" - informers "github.com/minio/minio-operator/pkg/client/informers/externalversions/miniocontroller/v1beta1" - listers "github.com/minio/minio-operator/pkg/client/listers/miniocontroller/v1beta1" - "github.com/minio/minio-operator/pkg/resources/services" - "github.com/minio/minio-operator/pkg/resources/statefulsets" + informers "github.com/minio/minio-operator/pkg/client/informers/externalversions/miniooperator.min.io/v1beta1" + listers "github.com/minio/minio-operator/pkg/client/listers/miniooperator.min.io/v1beta1" ) const controllerAgentName = "minio-operator" const ( - // SuccessSynced is used as part of the Event 'reason' when a MinIOInstance is synced + // SuccessSynced is used as part of the Event 'reason' when a MirrorInstace is synced SuccessSynced = "Synced" - // ErrResourceExists is used as part of the Event 'reason' when a MinIOInstance fails + // ErrResourceExists is used as part of the Event 'reason' when a MirrorInstace fails // to sync due to a StatefulSet of the same name already existing. ErrResourceExists = "ErrResourceExists" - // MessageResourceExists is the message used for Events when a MinIOInstance + // MessageResourceExists is the message used for Events when a MirrorInstace // fails to sync due to a StatefulSet already existing MessageResourceExists = "Resource %q already exists and is not managed by MinIO" - // MessageResourceSynced is the message used for an Event fired when a MinIOInstance + // MessageResourceSynced is the message used for an Event fired when a MirrorInstace // is synced successfully - MessageResourceSynced = "MinIOInstance synced successfully" + MessageResourceSynced = "MirrorInstace synced successfully" ) -// Controller struct watches the Kubernetes API for changes to MinIOInstance resources +// Controller struct watches the Kubernetes API for changes to MirrorInstace resources type Controller struct { // kubeClientSet is a standard kubernetes clientset kubeClientSet kubernetes.Interface // minioClientSet is a clientset for our own API group minioClientSet clientset.Interface - // statefulSetLister is able to list/get StatefulSets from a shared + // delpoymentLister is able to list/get Deployments from a shared // informer's store. - statefulSetLister appslisters.StatefulSetLister - // statefulSetListerSynced returns true if the StatefulSet shared informer + delpoymentLister appslisters.DeploymentLister + // deploymentListerSynced returns true if the Deployment shared informer // has synced at least once. - statefulSetListerSynced cache.InformerSynced + deploymentListerSynced cache.InformerSynced - // minioInstancesLister lists MinIOInstance from a shared informer's + // mirrorLister lists MirrorInstance from a shared informer's // store. - minioInstancesLister listers.MinIOInstanceLister - // minioInstancesSynced returns true if the StatefulSet shared informer + mirrorLister listers.MirrorInstanceLister + // mirrorListerSynced returns true if the StatefulSet shared informer // has synced at least once. - minioInstancesSynced cache.InformerSynced - - // serviceLister is able to list/get Services from a shared informer's - // store. - serviceLister corelisters.ServiceLister - // serviceListerSynced returns true if the Service shared informer - // has synced at least once. - serviceListerSynced cache.InformerSynced + mirrorListerSynced cache.InformerSynced // queue is a rate limited work queue. This is used to queue work to be // processed instead of performing it as soon as a change happens. This @@ -103,19 +90,15 @@ type Controller struct { // recorder is an event recorder for recording Event resources to the // Kubernetes API. recorder record.EventRecorder - - // minio image - imagePath string } // NewController returns a new sample controller func NewController( kubeClientSet kubernetes.Interface, minioClientSet clientset.Interface, - statefulSetInformer appsinformers.StatefulSetInformer, - minioInstanceInformer informers.MinIOInstanceInformer, - serviceInformer coreinformers.ServiceInformer, - imagePath string) *Controller { + deploymentInformer appsinformers.DeploymentInformer, + mirrorInformer informers.MirrorInstanceInformer, +) *Controller { // Create event broadcaster // Add minio-controller types to the default Kubernetes Scheme so Events can be @@ -128,34 +111,31 @@ func NewController( recorder := eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: controllerAgentName}) controller := &Controller{ - kubeClientSet: kubeClientSet, - minioClientSet: minioClientSet, - statefulSetLister: statefulSetInformer.Lister(), - statefulSetListerSynced: statefulSetInformer.Informer().HasSynced, - minioInstancesLister: minioInstanceInformer.Lister(), - minioInstancesSynced: minioInstanceInformer.Informer().HasSynced, - serviceLister: serviceInformer.Lister(), - serviceListerSynced: serviceInformer.Informer().HasSynced, - workqueue: queue.NewNamedRateLimitingQueue(queue.DefaultControllerRateLimiter(), "MinIOInstances"), - recorder: recorder, - imagePath: imagePath, + kubeClientSet: kubeClientSet, + minioClientSet: minioClientSet, + delpoymentLister: deploymentInformer.Lister(), + deploymentListerSynced: deploymentInformer.Informer().HasSynced, + mirrorLister: mirrorInformer.Lister(), + mirrorListerSynced: mirrorInformer.Informer().HasSynced, + workqueue: queue.NewNamedRateLimitingQueue(queue.DefaultControllerRateLimiter(), "MinIOInstances"), + recorder: recorder, } glog.Info("Setting up event handlers") - // Set up an event handler for when MinIOInstance resources change - minioInstanceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: controller.enqueueMinIOInstance, + // Set up an event handler for when MirrorInstace resources change + mirrorInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: controller.enqueueMirrorInstance, UpdateFunc: func(old, new interface{}) { - controller.enqueueMinIOInstance(new) + controller.enqueueMirrorInstance(new) }, }) - // Set up an event handler for when StatefulSet resources change. This - // handler will lookup the owner of the given StatefulSet, and if it is - // owned by a MinIOInstance resource will enqueue that MinIOInstance resource for + // Set up an event handler for when Deployment resources change. This + // handler will lookup the owner of the given Deployment, and if it is + // owned by a MirrorInstance resource will enqueue that MirrorInstance resource for // processing. This way, we don't need to implement custom logic for - // handling StatefulSet resources. More info on this pattern: + // handling Deployment resources. More info on this pattern: // https://github.com/kubernetes/community/blob/8cafef897a22026d42f5e5bb3f104febe7e29830/contributors/devel/controllers.md - statefulSetInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ + deploymentInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: controller.handleObject, UpdateFunc: func(old, new interface{}) { newDepl := new.(*appsv1.StatefulSet) @@ -181,16 +161,16 @@ func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error { defer c.workqueue.ShutDown() // Start the informer factories to begin populating the informer caches - glog.Info("Starting MinIOInstance controller") + glog.Info("Starting MirrorInstace controller") // Wait for the caches to be synced before starting workers glog.Info("Waiting for informer caches to sync") - if ok := cache.WaitForCacheSync(stopCh, c.statefulSetListerSynced, c.minioInstancesSynced); !ok { + if ok := cache.WaitForCacheSync(stopCh, c.deploymentListerSynced, c.mirrorListerSynced); !ok { return fmt.Errorf("failed to wait for caches to sync") } glog.Info("Starting workers") - // Launch two workers to process MinIOInstance resources + // Launch two workers to process MirrorInstace resources for i := 0; i < threadiness; i++ { go wait.Until(c.runWorker, time.Second, stopCh) } @@ -243,7 +223,7 @@ func (c *Controller) processNextWorkItem() bool { return nil } // Run the syncHandler, passing it the namespace/name string of the - // MinIOInstance resource to be synced. + // MirrorInstace resource to be synced. if err := c.syncHandler(key); err != nil { return fmt.Errorf("error syncing '%s': %s", key, err.Error()) } @@ -262,7 +242,7 @@ func (c *Controller) processNextWorkItem() bool { } // syncHandler compares the actual state with the desired, and attempts to -// converge the two. It then updates the Status block of the MinIOInstance resource +// converge the two. It then updates the Status block of the MirrorInstace resource // with the current status of the resource. func (c *Controller) syncHandler(key string) error { // Convert the namespace/name string into a distinct namespace and name @@ -272,29 +252,19 @@ func (c *Controller) syncHandler(key string) error { return nil } - nsName := types.NamespacedName{Namespace: namespace, Name: name} + // nsName := types.NamespacedName{Namespace: namespace, Name: name} - // Get the MinIOInstance resource with this namespace/name - mi, err := c.minioInstancesLister.MinIOInstances(namespace).Get(name) + // Get the MirrorInstace resource with this namespace/name + mi, err := c.mirrorLister.MirrorInstances(namespace).Get(name) if err != nil { - // The MinIOInstance resource may no longer exist, in which case we stop processing. + // The MirrorInstace resource may no longer exist, in which case we stop processing. if errors.IsNotFound(err) { - runtime.HandleError(fmt.Errorf("MinIOInstance '%s' in work queue no longer exists", key)) + runtime.HandleError(fmt.Errorf("MirrorInstace '%s' in work queue no longer exists", key)) return nil } return err } - mi.EnsureDefaults() - - svc, err := c.serviceLister.Services(mi.Namespace).Get(mi.Name) - // If the resource doesn't exist, we'll create it - if errors.IsNotFound(err) { - glog.V(2).Infof("Creating a new Service for cluster %q", nsName) - svc = services.NewForCluster(mi) - _, err = c.kubeClientSet.CoreV1().Services(svc.Namespace).Create(svc) - } - // If an error occurs during Get/Create, we'll requeue the item so we can // attempt processing again later. This could have been caused by a // temporary network failure, or any other transient reason. @@ -302,12 +272,12 @@ func (c *Controller) syncHandler(key string) error { return err } - // Get the StatefulSet with the name specified in MinIOInstance.spec - ss, err := c.statefulSetLister.StatefulSets(mi.Namespace).Get(mi.Name) + // Get the Deployment with the name specified in MirrorInstace.spec + //d, err := c.delpoymentLister.Deployments(mi.Namespace).Get(mi.Name) // If the resource doesn't exist, we'll create it if errors.IsNotFound(err) { - ss = statefulsets.NewForCluster(mi, svc.Name) - _, err = c.kubeClientSet.AppsV1().StatefulSets(mi.Namespace).Create(ss) + //d = deployments.NewForCluster(mi) + //_, err = c.kubeClientSet.AppsV1().Deployments(mi.Namespace).Create(d) } // If an error occurs during Get/Create, we'll requeue the item so we can @@ -317,33 +287,6 @@ func (c *Controller) syncHandler(key string) error { return err } - // If the StatefulSet is not controlled by this MinIOInstance resource, we should log - // a warning to the event recorder and ret - if !metav1.IsControlledBy(ss, mi) { - msg := fmt.Sprintf(MessageResourceExists, ss.Name) - c.recorder.Event(mi, corev1.EventTypeWarning, ErrResourceExists, msg) - return fmt.Errorf(msg) - } - - // If this number of the replicas on the MinIOInstance resource is specified, and the - // number does not equal the current desired replicas on the StatefulSet, we - // should update the StatefulSet resource. - if mi.GetReplicas() != *ss.Spec.Replicas { - glog.V(4).Infof("MinIOInstance %s replicas: %d, StatefulSet replicas: %d", name, mi.GetReplicas(), *ss.Spec.Replicas) - ss = statefulsets.NewForCluster(mi, svc.Name) - _, err = c.kubeClientSet.AppsV1().StatefulSets(mi.Namespace).Update(ss) - } - - // If this container version on the MinIOInstance resource is specified, and the - // version does not equal the current desired version in the StatefulSet, we - // should update the StatefulSet resource. - currentImage := ss.Spec.Template.Spec.Containers[0].Image - if mi.Spec.Image != currentImage { - glog.V(4).Infof("Updating MinIOInstance %s MinIO server from %s, to: %s", name, currentImage, mi.Spec.Image) - ss = statefulsets.NewForCluster(mi, svc.Name) - _, err = c.kubeClientSet.AppsV1().StatefulSets(mi.Namespace).Update(ss) - } - // If an error occurs during Update, we'll requeue the item so we can // attempt processing again later. This could have been caused by a // temporary network failure, or any other transient reason. @@ -351,35 +294,14 @@ func (c *Controller) syncHandler(key string) error { return err } - // Finally, we update the status block of the MinIOInstance resource to reflect the - // current state of the world - err = c.updateMinIOInstanceStatus(mi, ss) - if err != nil { - return err - } - c.recorder.Event(mi, corev1.EventTypeNormal, SuccessSynced, MessageResourceSynced) return nil } -func (c *Controller) updateMinIOInstanceStatus(minioInstance *miniov1beta1.MinIOInstance, statefulSet *appsv1.StatefulSet) error { - // NEVER modify objects from the store. It's a read-only, local cache. - // You can use DeepCopy() to make a deep copy of original object and modify this copy - // Or create a copy manually for better performance - minioInstanceCopy := minioInstance.DeepCopy() - minioInstanceCopy.Status.AvailableReplicas = statefulSet.Status.Replicas - // If the CustomResourceSubresources feature gate is not enabled, - // we must use Update instead of UpdateStatus to update the Status block of the MinIOInstance resource. - // UpdateStatus will not allow changes to the Spec of the resource, - // which is ideal for ensuring nothing other than resource status has been updated. - _, err := c.minioClientSet.MinV1beta1().MinIOInstances(minioInstance.Namespace).Update(minioInstanceCopy) - return err -} - -// enqueueMinIOInstance takes a MinIOInstance resource and converts it into a namespace/name +// enqueueMinIOInstance takes a MirrorInstace resource and converts it into a namespace/name // string which is then put onto the work queue. This method should *not* be -// passed resources of any type other than MinIOInstance. -func (c *Controller) enqueueMinIOInstance(obj interface{}) { +// passed resources of any type other than MirrorInstace. +func (c *Controller) enqueueMirrorInstance(obj interface{}) { var key string var err error if key, err = cache.MetaNamespaceKeyFunc(obj); err != nil { @@ -390,9 +312,9 @@ func (c *Controller) enqueueMinIOInstance(obj interface{}) { } // handleObject will take any resource implementing metav1.Object and attempt -// to find the MinIOInstance resource that 'owns' it. It does this by looking at the +// to find the MirrorInstace resource that 'owns' it. It does this by looking at the // objects metadata.ownerReferences field for an appropriate OwnerReference. -// It then enqueues that MinIOInstance resource to be processed. If the object does not +// It then enqueues that MirrorInstace resource to be processed. If the object does not // have an appropriate OwnerReference, it will simply be skipped. func (c *Controller) handleObject(obj interface{}) { var object metav1.Object @@ -412,19 +334,19 @@ func (c *Controller) handleObject(obj interface{}) { } glog.V(4).Infof("Processing object: %s", object.GetName()) if ownerRef := metav1.GetControllerOf(object); ownerRef != nil { - // If this object is not owned by a MinIOInstance, we should not do anything more + // If this object is not owned by a MirrorInstace, we should not do anything more // with it. - if ownerRef.Kind != "MinIOInstance" { + if ownerRef.Kind != "MirrorInstance" { return } - minioInstance, err := c.minioInstancesLister.MinIOInstances(object.GetNamespace()).Get(ownerRef.Name) + mirrorInstance, err := c.mirrorLister.MirrorInstances(object.GetNamespace()).Get(ownerRef.Name) if err != nil { glog.V(4).Infof("ignoring orphaned object '%s' of minioInstance '%s'", object.GetSelfLink(), ownerRef.Name) return } - c.enqueueMinIOInstance(minioInstance) + c.enqueueMirrorInstance(mirrorInstance) return } } diff --git a/pkg/resources/deployments/deployment.go b/pkg/resources/deployments/deployment.go new file mode 100644 index 00000000000..3836aac3a09 --- /dev/null +++ b/pkg/resources/deployments/deployment.go @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2019, MinIO, Inc. + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +package deployments + +import ( + miniov1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" + "github.com/minio/minio-operator/pkg/constants" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// NewForCluster creates a new Deployment for the given mirror instance. +func NewForCluster(mi *miniov1beta1.MirrorInstance) *appsv1.Deployment { + + //containers := []corev1.Container{minioServerContainer(mi, serviceName)} + var replicas int32 = 1 + + d := &appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: mi.Namespace, + Name: mi.Name, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(mi, schema.GroupVersionKind{ + Group: miniov1beta1.SchemeGroupVersion.Group, + Version: miniov1beta1.SchemeGroupVersion.Version, + Kind: constants.ClusterCRDResourceKind, + }), + }, + }, + Spec: appsv1.DeploymentSpec{ + Replicas: &replicas, + Template: corev1.PodTemplateSpec{}, + }, + } + + return d +} diff --git a/pkg/resources/jobs/job.go b/pkg/resources/jobs/job.go deleted file mode 100644 index 433417b2adb..00000000000 --- a/pkg/resources/jobs/job.go +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) 2019, MinIO, Inc. - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -package jobs diff --git a/pkg/resources/services/service.go b/pkg/resources/services/service.go index 9510da88005..cc0ad9d9e50 100644 --- a/pkg/resources/services/service.go +++ b/pkg/resources/services/service.go @@ -22,7 +22,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" - miniov1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + miniov1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" constants "github.com/minio/minio-operator/pkg/constants" ) @@ -38,7 +38,7 @@ func NewForCluster(mi *miniov1beta1.MinIOInstance) *corev1.Service { *metav1.NewControllerRef(mi, schema.GroupVersionKind{ Group: miniov1beta1.SchemeGroupVersion.Group, Version: miniov1beta1.SchemeGroupVersion.Version, - Kind: miniov1beta1.ClusterCRDResourceKind, + Kind: constants.ClusterCRDResourceKind, }), }, Annotations: map[string]string{ diff --git a/pkg/resources/statefulsets/statefulset.go b/pkg/resources/statefulsets/statefulset.go index b13a5d9d107..5c3d5843ec7 100644 --- a/pkg/resources/statefulsets/statefulset.go +++ b/pkg/resources/statefulsets/statefulset.go @@ -21,7 +21,7 @@ import ( "fmt" "strconv" - miniov1beta1 "github.com/minio/minio-operator/pkg/apis/miniocontroller/v1beta1" + miniov1beta1 "github.com/minio/minio-operator/pkg/apis/miniooperator.min.io/v1beta1" constants "github.com/minio/minio-operator/pkg/constants" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -267,7 +267,7 @@ func NewForCluster(mi *miniov1beta1.MinIOInstance, serviceName string) *appsv1.S *metav1.NewControllerRef(mi, schema.GroupVersionKind{ Group: miniov1beta1.SchemeGroupVersion.Group, Version: miniov1beta1.SchemeGroupVersion.Version, - Kind: miniov1beta1.ClusterCRDResourceKind, + Kind: constants.ClusterCRDResourceKind, }), }, }, @@ -285,6 +285,7 @@ func NewForCluster(mi *miniov1beta1.MinIOInstance, serviceName string) *appsv1.S Containers: containers, Volumes: podVolumes, ImagePullSecrets: []corev1.LocalObjectReference{mi.Spec.ImagePullSecret}, + RestartPolicy: "Always", Affinity: mi.Spec.Affinity, SchedulerName: mi.Scheduler.Name, Tolerations: minioTolerations(mi),