Skip to content

Commit

Permalink
Merge pull request #7 from etcd-io/api_group_20241122
Browse files Browse the repository at this point in the history
Change the api group from `clusters.etcd.io` to `operator.etcd.io`
  • Loading branch information
ahrtr authored Nov 26, 2024
2 parents ccbf648 + 83bbf01 commit df5acd2
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 81 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint

## Tool Versions
KUSTOMIZE_VERSION ?= v5.4.3
KUSTOMIZE_VERSION ?= v5.5.0
CONTROLLER_TOOLS_VERSION ?= v0.16.4
ENVTEST_VERSION ?= release-0.19
GOLANGCI_LINT_VERSION ?= v1.59.1
GOLANGCI_LINT_VERSION ?= v1.61.0

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resources:
namespaced: true
controller: true
domain: etcd.io
group: clusters
group: operator
kind: EtcdCluster
path: go.etcd.io/etcd-operator/api/v1alpha1
version: v1alpha1
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the clusters v1alpha1 API group.
// Package v1alpha1 contains API Schema definitions for the operator v1alpha1 API group.
// +kubebuilder:object:generate=true
// +groupName=clusters.etcd.io
// +groupName=operator.etcd.io
package v1alpha1

import (
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "clusters.etcd.io", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "operator.etcd.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
20 changes: 9 additions & 11 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

clustersv1alpha1 "go.etcd.io/etcd-operator/api/v1alpha1"
operatorv1alpha1 "go.etcd.io/etcd-operator/api/v1alpha1"
"go.etcd.io/etcd-operator/internal/controller"
// +kubebuilder:scaffold:imports
)
Expand All @@ -48,7 +48,7 @@ var (
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(clustersv1alpha1.AddToScheme(scheme))
utilruntime.Must(operatorv1alpha1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
}

Expand Down Expand Up @@ -98,26 +98,24 @@ func main() {

// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
// More info:
// - https://pkg.go.dev/sigs.k8s.io/[email protected].0/pkg/metrics/server
// - https://pkg.go.dev/sigs.k8s.io/[email protected].1/pkg/metrics/server
// - https://book.kubebuilder.io/reference/metrics.html
metricsServerOptions := metricsserver.Options{
BindAddress: metricsAddr,
SecureServing: secureMetrics,
// TODO(user): TLSOpts is used to allow configuring the TLS config used for the server. If certificates are
// not provided, self-signed certificates will be generated by default. This option is not recommended for
// production environments as self-signed certificates do not offer the same level of trust and security
// as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing
// unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName
// to provide certificates, ensuring the server communicates using trusted and secure certificates.
TLSOpts: tlsOpts,
TLSOpts: tlsOpts,
}

if secureMetrics {
// FilterProvider is used to protect the metrics endpoint with authn/authz.
// These configurations ensure that only authorized users and service accounts
// can access the metrics endpoint. The RBAC are configured in 'config/rbac/kustomization.yaml'. More info:
// https://pkg.go.dev/sigs.k8s.io/[email protected].0/pkg/metrics/filters#WithAuthenticationAndAuthorization
// https://pkg.go.dev/sigs.k8s.io/[email protected].1/pkg/metrics/filters#WithAuthenticationAndAuthorization
metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization

// TODO(user): If CertDir, CertName, and KeyName are not specified, controller-runtime will automatically
// generate self-signed certificates for the metrics server. While convenient for development and testing,
// this setup is not recommended for production.
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.4
name: etcdclusters.clusters.etcd.io
name: etcdclusters.operator.etcd.io
spec:
group: clusters.etcd.io
group: operator.etcd.io
names:
kind: EtcdCluster
listKind: EtcdClusterList
Expand Down
4 changes: 1 addition & 3 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/clusters.etcd.io_etcdclusters.yaml
- bases/operator.etcd.io_etcdclusters.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patches:
Expand All @@ -12,11 +12,9 @@ patches:

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- path: patches/cainjection_in_etcdclusters.yaml
# +kubebuilder:scaffold:crdkustomizecainjectionpatch

# [WEBHOOK] To enable webhook, uncomment the following section
# the following config is for teaching kustomize how to do kustomization for CRDs.

#configurations:
#- kustomizeconfig.yaml
70 changes: 35 additions & 35 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,41 @@ patches:
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
# Uncomment the following replacements to add the cert-manager CA injection annotations
#replacements:
# - source: # Uncomment the following block if you have any webhook
# kind: Service
# version: v1
# name: webhook-service
# fieldPath: .metadata.name # Name of the service
# targets:
# - select:
# kind: Certificate
# group: cert-manager.io
# version: v1
# fieldPaths:
# - .spec.dnsNames.0
# - .spec.dnsNames.1
# options:
# delimiter: '.'
# index: 0
# create: true
# - source:
# kind: Service
# version: v1
# name: webhook-service
# fieldPath: .metadata.namespace # Namespace of the service
# targets:
# - select:
# kind: Certificate
# group: cert-manager.io
# version: v1
# fieldPaths:
# - .spec.dnsNames.0
# - .spec.dnsNames.1
# options:
# delimiter: '.'
# index: 1
# create: true
#
# - source: # Uncomment the following block if you have a ValidatingWebhook (--programmatic-validation)
# kind: Certificate
# group: cert-manager.io
Expand Down Expand Up @@ -140,38 +175,3 @@ patches:
# delimiter: '/'
# index: 1
# create: true
#
# - source: # Uncomment the following block if you enable cert-manager
# kind: Service
# version: v1
# name: webhook-service
# fieldPath: .metadata.name # Name of the service
# targets:
# - select:
# kind: Certificate
# group: cert-manager.io
# version: v1
# fieldPaths:
# - .spec.dnsNames.0
# - .spec.dnsNames.1
# options:
# delimiter: '.'
# index: 0
# create: true
# - source:
# kind: Service
# version: v1
# name: webhook-service
# fieldPath: .metadata.namespace # Namespace of the service
# targets:
# - select:
# kind: Certificate
# group: cert-manager.io
# version: v1
# fieldPaths:
# - .spec.dnsNames.0
# - .spec.dnsNames.1
# options:
# delimiter: '.'
# index: 1
# create: true
4 changes: 2 additions & 2 deletions config/rbac/etcdcluster_editor_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
name: etcdcluster-editor-role
rules:
- apiGroups:
- clusters.etcd.io
- operator.etcd.io
resources:
- etcdclusters
verbs:
Expand All @@ -20,7 +20,7 @@ rules:
- update
- watch
- apiGroups:
- clusters.etcd.io
- operator.etcd.io
resources:
- etcdclusters/status
verbs:
Expand Down
4 changes: 2 additions & 2 deletions config/rbac/etcdcluster_viewer_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ metadata:
name: etcdcluster-viewer-role
rules:
- apiGroups:
- clusters.etcd.io
- operator.etcd.io
resources:
- etcdclusters
verbs:
- get
- list
- watch
- apiGroups:
- clusters.etcd.io
- operator.etcd.io
resources:
- etcdclusters/status
verbs:
Expand Down
6 changes: 3 additions & 3 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: manager-role
rules:
- apiGroups:
- clusters.etcd.io
- operator.etcd.io
resources:
- etcdclusters
verbs:
Expand All @@ -17,13 +17,13 @@ rules:
- update
- watch
- apiGroups:
- clusters.etcd.io
- operator.etcd.io
resources:
- etcdclusters/finalizers
verbs:
- update
- apiGroups:
- clusters.etcd.io
- operator.etcd.io
resources:
- etcdclusters/status
verbs:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Append samples of your project ##
resources:
- clusters_v1alpha1_etcdcluster.yaml
- operator_v1alpha1_etcdcluster.yaml
# +kubebuilder:scaffold:manifestskustomizesamples
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: clusters.etcd.io/v1alpha1
apiVersion: operator.etcd.io/v1alpha1
kind: EtcdCluster
metadata:
labels:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/onsi/gomega v1.33.1
k8s.io/apimachinery v0.31.0
k8s.io/client-go v0.31.0
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/controller-runtime v0.19.1
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 h1:2770sDpzrjjsAtVhSeUFseziht227YAWYHLGNM8QPwY=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q=
sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
sigs.k8s.io/controller-runtime v0.19.1 h1:Son+Q40+Be3QWb+niBXAg2vFiYWolDjjRfO8hn/cxOk=
sigs.k8s.io/controller-runtime v0.19.1/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
Expand Down
12 changes: 6 additions & 6 deletions internal/controller/etcdcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"

clustersv1alpha1 "go.etcd.io/etcd-operator/api/v1alpha1"
operatorv1alpha1 "go.etcd.io/etcd-operator/api/v1alpha1"
)

// EtcdClusterReconciler reconciles a EtcdCluster object
Expand All @@ -33,9 +33,9 @@ type EtcdClusterReconciler struct {
Scheme *runtime.Scheme
}

// +kubebuilder:rbac:groups=clusters.etcd.io,resources=etcdclusters,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=clusters.etcd.io,resources=etcdclusters/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=clusters.etcd.io,resources=etcdclusters/finalizers,verbs=update
// +kubebuilder:rbac:groups=operator.etcd.io,resources=etcdclusters,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=operator.etcd.io,resources=etcdclusters/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=operator.etcd.io,resources=etcdclusters/finalizers,verbs=update

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand All @@ -45,7 +45,7 @@ type EtcdClusterReconciler struct {
// the user.
//
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/[email protected].0/pkg/reconcile
// - https://pkg.go.dev/sigs.k8s.io/[email protected].1/pkg/reconcile
func (r *EtcdClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
_ = log.FromContext(ctx)

Expand All @@ -57,7 +57,7 @@ func (r *EtcdClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
// SetupWithManager sets up the controller with the Manager.
func (r *EtcdClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&clustersv1alpha1.EtcdCluster{}).
For(&operatorv1alpha1.EtcdCluster{}).
Named("etcdcluster").
Complete(r)
}
8 changes: 4 additions & 4 deletions internal/controller/etcdcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clustersv1alpha1 "go.etcd.io/etcd-operator/api/v1alpha1"
operatorv1alpha1 "go.etcd.io/etcd-operator/api/v1alpha1"
)

var _ = Describe("EtcdCluster Controller", func() {
Expand All @@ -40,13 +40,13 @@ var _ = Describe("EtcdCluster Controller", func() {
Name: resourceName,
Namespace: "default", // TODO(user):Modify as needed
}
etcdcluster := &clustersv1alpha1.EtcdCluster{}
etcdcluster := &operatorv1alpha1.EtcdCluster{}

BeforeEach(func() {
By("creating the custom resource for the Kind EtcdCluster")
err := k8sClient.Get(ctx, typeNamespacedName, etcdcluster)
if err != nil && errors.IsNotFound(err) {
resource := &clustersv1alpha1.EtcdCluster{
resource := &operatorv1alpha1.EtcdCluster{
ObjectMeta: metav1.ObjectMeta{
Name: resourceName,
Namespace: "default",
Expand All @@ -59,7 +59,7 @@ var _ = Describe("EtcdCluster Controller", func() {

AfterEach(func() {
// TODO(user): Cleanup logic after each test, like removing the resource instance.
resource := &clustersv1alpha1.EtcdCluster{}
resource := &operatorv1alpha1.EtcdCluster{}
err := k8sClient.Get(ctx, typeNamespacedName, resource)
Expect(err).NotTo(HaveOccurred())

Expand Down
4 changes: 2 additions & 2 deletions internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

clustersv1alpha1 "go.etcd.io/etcd-operator/api/v1alpha1"
operatorv1alpha1 "go.etcd.io/etcd-operator/api/v1alpha1"
// +kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -77,7 +77,7 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

err = clustersv1alpha1.AddToScheme(scheme.Scheme)
err = operatorv1alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

// +kubebuilder:scaffold:scheme
Expand Down

0 comments on commit df5acd2

Please sign in to comment.