Skip to content

Commit

Permalink
Change the api group from clusters.etcd.io to operator.etcd.io
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Nov 22, 2024
1 parent ccbf648 commit 52bf6d7
Show file tree
Hide file tree
Showing 27 changed files with 102 additions and 106 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- $(CONTAINER_TOOL) buildx create --name etcd-operator-builder
$(CONTAINER_TOOL) buildx use etcd-operator-builder
- $(CONTAINER_TOOL) buildx create --name test-operator-builder
$(CONTAINER_TOOL) buildx use test-operator-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx rm etcd-operator-builder
- $(CONTAINER_TOOL) buildx rm test-operator-builder
rm Dockerfile.cross

.PHONY: build-installer
Expand Down 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
4 changes: 2 additions & 2 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
domain: etcd.io
layout:
- go.kubebuilder.io/v4
projectName: etcd-operator
projectName: test-operator
repo: go.etcd.io/etcd-operator
resources:
- api:
crdVersion: v1
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
74 changes: 37 additions & 37 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Adds namespace to all resources.
namespace: etcd-operator-system
namespace: test-operator-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: etcd-operator-
namePrefix: test-operator-

# Labels to add to all resources and selectors.
#labels:
Expand Down 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
2 changes: 1 addition & 1 deletion config/default/metrics_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Service
metadata:
labels:
control-plane: controller-manager
app.kubernetes.io/name: etcd-operator
app.kubernetes.io/name: test-operator
app.kubernetes.io/managed-by: kustomize
name: controller-manager-metrics-service
namespace: system
Expand Down
4 changes: 2 additions & 2 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Namespace
metadata:
labels:
control-plane: controller-manager
app.kubernetes.io/name: etcd-operator
app.kubernetes.io/name: test-operator
app.kubernetes.io/managed-by: kustomize
name: system
---
Expand All @@ -14,7 +14,7 @@ metadata:
namespace: system
labels:
control-plane: controller-manager
app.kubernetes.io/name: etcd-operator
app.kubernetes.io/name: test-operator
app.kubernetes.io/managed-by: kustomize
spec:
selector:
Expand Down
2 changes: 1 addition & 1 deletion config/network-policy/allow-metrics-traffic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
labels:
app.kubernetes.io/name: etcd-operator
app.kubernetes.io/name: test-operator
app.kubernetes.io/managed-by: kustomize
name: allow-metrics-traffic
namespace: system
Expand Down
2 changes: 1 addition & 1 deletion config/prometheus/monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: ServiceMonitor
metadata:
labels:
control-plane: controller-manager
app.kubernetes.io/name: etcd-operator
app.kubernetes.io/name: test-operator
app.kubernetes.io/managed-by: kustomize
name: controller-manager-metrics-monitor
namespace: system
Expand Down
6 changes: 3 additions & 3 deletions config/rbac/etcdcluster_editor_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: etcd-operator
app.kubernetes.io/name: test-operator
app.kubernetes.io/managed-by: kustomize
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
6 changes: 3 additions & 3 deletions config/rbac/etcdcluster_viewer_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: etcd-operator
app.kubernetes.io/name: test-operator
app.kubernetes.io/managed-by: kustomize
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
2 changes: 1 addition & 1 deletion config/rbac/leader_election_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
labels:
app.kubernetes.io/name: etcd-operator
app.kubernetes.io/name: test-operator
app.kubernetes.io/managed-by: kustomize
name: leader-election-role
rules:
Expand Down
2 changes: 1 addition & 1 deletion config/rbac/leader_election_role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
app.kubernetes.io/name: etcd-operator
app.kubernetes.io/name: test-operator
app.kubernetes.io/managed-by: kustomize
name: leader-election-rolebinding
roleRef:
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/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/name: etcd-operator
app.kubernetes.io/name: test-operator
app.kubernetes.io/managed-by: kustomize
name: manager-rolebinding
roleRef:
Expand Down
Loading

0 comments on commit 52bf6d7

Please sign in to comment.