Skip to content

Commit dffb919

Browse files
authored
Merge branch 'main' into reconcile-refactor
2 parents 2484222 + e1aa5c2 commit dffb919

File tree

10 files changed

+59
-39
lines changed

10 files changed

+59
-39
lines changed

api/v1alpha1/etcdcluster_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ type EtcdClusterSpec struct {
3535
// Size is the expected size of the etcd cluster.
3636
// +kubebuilder:validation:Minimum=1
3737
Size int `json:"size"`
38+
// ImageRegistry specifies the container registry that hosts the etcd images.
39+
// If unset, it defaults to the value provided via the controller's
40+
// --image-registry flag, which itself defaults to "gcr.io/etcd-development/etcd".
41+
ImageRegistry string `json:"imageRegistry,omitempty"`
3842
// Version is the expected version of the etcd container image.
3943
Version string `json:"version"`
4044
// StorageSpec is the name of the StorageSpec to use for the etcd cluster. If not provided, then each POD just uses the temporary storage inside the container.

cmd/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ func init() {
5353
}
5454

5555
func main() {
56+
var imageRegistry string
5657
var metricsAddr string
5758
var enableLeaderElection bool
5859
var probeAddr string
5960
var secureMetrics bool
6061
var enableHTTP2 bool
6162
var tlsOpts []func(*tls.Config)
63+
flag.StringVar(&imageRegistry, "image-registry", "gcr.io/etcd-development/etcd",
64+
"The container registry to pull etcd images from. Defaults to gcr.io/etcd-development/etcd.")
6265
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
6366
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
6467
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -143,8 +146,9 @@ func main() {
143146
}
144147

145148
if err = (&controller.EtcdClusterReconciler{
146-
Client: mgr.GetClient(),
147-
Scheme: mgr.GetScheme(),
149+
Client: mgr.GetClient(),
150+
Scheme: mgr.GetScheme(),
151+
ImageRegistry: imageRegistry,
148152
}).SetupWithManager(mgr); err != nil {
149153
setupLog.Error(err, "unable to create controller", "controller", "EtcdCluster")
150154
os.Exit(1)

config/crd/bases/operator.etcd.io_etcdclusters.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ spec:
4646
items:
4747
type: string
4848
type: array
49+
imageRegistry:
50+
description: |-
51+
ImageRegistry specifies the container registry that hosts the etcd images.
52+
If unset, it defaults to the value provided via the controller's
53+
--image-registry flag, which itself defaults to "gcr.io/etcd-development/etcd".
54+
type: string
4955
size:
5056
description: Size is the expected size of the etcd cluster.
5157
minimum: 1

docs/roadmap.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ The list is based on the survey results and the discussion in wg-etcd-operator.
77
- Users should be able to set at least the etcd version and cluster size
88
- Understand health of a cluster
99
- Scale in and out, e.g 1 -> 3 -> 5 members and vice versa
10+
- Support customizing etcd options (via flags or env vars)
1011

1112
## v0.2.0
1213
- Enabling TLS communication
1314
- Should also support certificate renewal
1415
- Upgrade across patches or one minor version
15-
- Support customizing etcd options (via flags or env vars)
1616

1717
## v0.3.0
1818
- Recover a single failed cluster member (still have quorum)
@@ -23,5 +23,8 @@ The list is based on the survey results and the discussion in wg-etcd-operator.
2323
- Create periodic backup of a cluster
2424
- Create a new cluster from a backup
2525

26+
## v1.0.0
27+
- (TBD) Helm chart distribution
28+
2629
## Future versions
2730
It makes no sense to plan too far ahead because plans can't keep up with changes.

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ require (
1414
go.etcd.io/etcd/client/v3 v3.6.2
1515
go.etcd.io/etcd/server/v3 v3.6.2
1616
go.uber.org/zap v1.27.0
17-
k8s.io/api v0.33.2
18-
k8s.io/apimachinery v0.33.2
19-
k8s.io/client-go v0.33.2
17+
k8s.io/api v0.33.3
18+
k8s.io/apimachinery v0.33.3
19+
k8s.io/client-go v0.33.3
2020
k8s.io/klog/v2 v2.130.1
2121
k8s.io/utils v0.0.0-20241210054802-24370beab758
2222
sigs.k8s.io/controller-runtime v0.21.0
@@ -117,9 +117,9 @@ require (
117117
gopkg.in/inf.v0 v0.9.1 // indirect
118118
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
119119
gopkg.in/yaml.v3 v3.0.1 // indirect
120-
k8s.io/apiextensions-apiserver v0.33.2
121-
k8s.io/apiserver v0.33.2 // indirect
122-
k8s.io/component-base v0.33.2 // indirect
120+
k8s.io/apiextensions-apiserver v0.33.3
121+
k8s.io/apiserver v0.33.3 // indirect
122+
k8s.io/component-base v0.33.3 // indirect
123123
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
124124
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect
125125
sigs.k8s.io/e2e-framework v0.6.0

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,18 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYs
290290
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
291291
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
292292
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
293-
k8s.io/api v0.33.2 h1:YgwIS5jKfA+BZg//OQhkJNIfie/kmRsO0BmNaVSimvY=
294-
k8s.io/api v0.33.2/go.mod h1:fhrbphQJSM2cXzCWgqU29xLDuks4mu7ti9vveEnpSXs=
295-
k8s.io/apiextensions-apiserver v0.33.2 h1:6gnkIbngnaUflR3XwE1mCefN3YS8yTD631JXQhsU6M8=
296-
k8s.io/apiextensions-apiserver v0.33.2/go.mod h1:IvVanieYsEHJImTKXGP6XCOjTwv2LUMos0YWc9O+QP8=
297-
k8s.io/apimachinery v0.33.2 h1:IHFVhqg59mb8PJWTLi8m1mAoepkUNYmptHsV+Z1m5jY=
298-
k8s.io/apimachinery v0.33.2/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
299-
k8s.io/apiserver v0.33.2 h1:KGTRbxn2wJagJowo29kKBp4TchpO1DRO3g+dB/KOJN4=
300-
k8s.io/apiserver v0.33.2/go.mod h1:9qday04wEAMLPWWo9AwqCZSiIn3OYSZacDyu/AcoM/M=
301-
k8s.io/client-go v0.33.2 h1:z8CIcc0P581x/J1ZYf4CNzRKxRvQAwoAolYPbtQes+E=
302-
k8s.io/client-go v0.33.2/go.mod h1:9mCgT4wROvL948w6f6ArJNb7yQd7QsvqavDeZHvNmHo=
303-
k8s.io/component-base v0.33.2 h1:sCCsn9s/dG3ZrQTX/Us0/Sx2R0G5kwa0wbZFYoVp/+0=
304-
k8s.io/component-base v0.33.2/go.mod h1:/41uw9wKzuelhN+u+/C59ixxf4tYQKW7p32ddkYNe2k=
293+
k8s.io/api v0.33.3 h1:SRd5t//hhkI1buzxb288fy2xvjubstenEKL9K51KBI8=
294+
k8s.io/api v0.33.3/go.mod h1:01Y/iLUjNBM3TAvypct7DIj0M0NIZc+PzAHCIo0CYGE=
295+
k8s.io/apiextensions-apiserver v0.33.3 h1:qmOcAHN6DjfD0v9kxL5udB27SRP6SG/MTopmge3MwEs=
296+
k8s.io/apiextensions-apiserver v0.33.3/go.mod h1:oROuctgo27mUsyp9+Obahos6CWcMISSAPzQ77CAQGz8=
297+
k8s.io/apimachinery v0.33.3 h1:4ZSrmNa0c/ZpZJhAgRdcsFcZOw1PQU1bALVQ0B3I5LA=
298+
k8s.io/apimachinery v0.33.3/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
299+
k8s.io/apiserver v0.33.3 h1:Wv0hGc+QFdMJB4ZSiHrCgN3zL3QRatu56+rpccKC3J4=
300+
k8s.io/apiserver v0.33.3/go.mod h1:05632ifFEe6TxwjdAIrwINHWE2hLwyADFk5mBsQa15E=
301+
k8s.io/client-go v0.33.3 h1:M5AfDnKfYmVJif92ngN532gFqakcGi6RvaOF16efrpA=
302+
k8s.io/client-go v0.33.3/go.mod h1:luqKBQggEf3shbxHY4uVENAxrDISLOarxpTKMiUuujg=
303+
k8s.io/component-base v0.33.3 h1:mlAuyJqyPlKZM7FyaoM/LcunZaaY353RXiOd2+B5tGA=
304+
k8s.io/component-base v0.33.3/go.mod h1:ktBVsBzkI3imDuxYXmVxZ2zxJnYTZ4HAsVj9iF09qp4=
305305
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
306306
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
307307
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4=

internal/controller/etcdcluster_controller.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ const (
4242
// EtcdClusterReconciler reconciles a EtcdCluster object
4343
type EtcdClusterReconciler struct {
4444
client.Client
45-
Scheme *runtime.Scheme
46-
Recorder record.EventRecorder
45+
Scheme *runtime.Scheme
46+
Recorder record.EventRecorder
47+
ImageRegistry string
4748
}
4849

4950
// reconcileState holds all transient data for a single reconciliation loop.
@@ -104,6 +105,11 @@ func (r *EtcdClusterReconciler) fetchAndValidateState(ctx context.Context, req c
104105
return nil, ctrl.Result{}, err
105106
}
106107

108+
// Determine desired etcd image registry
109+
if ec.Spec.ImageRegistry == "" {
110+
ec.Spec.ImageRegistry = r.ImageRegistry
111+
}
112+
107113
logger.Info("Reconciling EtcdCluster", "spec", ec.Spec)
108114

109115
sts, err := getStatefulSet(ctx, r.Client, ec.Name, ec.Namespace)

internal/controller/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func createOrPatchStatefulSet(ctx context.Context, logger logr.Logger, ec *ecv1a
159159
Name: "etcd",
160160
Command: []string{"/usr/local/bin/etcd"},
161161
Args: createArgs(ec.Name, ec.Spec.EtcdOptions),
162-
Image: fmt.Sprintf("gcr.io/etcd-development/etcd:%s", ec.Spec.Version),
162+
Image: fmt.Sprintf("%s:%s", ec.Spec.ImageRegistry, ec.Spec.Version),
163163
Env: []corev1.EnvVar{
164164
{
165165
Name: "POD_NAME",

tools/mod/go.mod

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20250106171007-7436275c4311 // @release-0.19
1111
sigs.k8s.io/controller-tools v0.18.0
1212
sigs.k8s.io/kind v0.29.0
13-
sigs.k8s.io/kustomize/kustomize/v5 v5.7.0
13+
sigs.k8s.io/kustomize/kustomize/v5 v5.7.1
1414
)
1515

1616
require (
@@ -47,7 +47,6 @@ require (
4747
github.com/breml/errchkjson v0.4.0 // indirect
4848
github.com/butuzov/ireturn v0.3.1 // indirect
4949
github.com/butuzov/mirror v1.3.0 // indirect
50-
github.com/carapace-sh/carapace-shlex v1.0.1 // indirect
5150
github.com/catenacyber/perfsprint v0.8.2 // indirect
5251
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
5352
github.com/cespare/xxhash/v2 v2.3.0 // indirect
@@ -245,9 +244,9 @@ require (
245244
mvdan.cc/gofumpt v0.7.0 // indirect
246245
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect
247246
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
248-
sigs.k8s.io/kustomize/api v0.20.0 // indirect
249-
sigs.k8s.io/kustomize/cmd/config v0.20.0 // indirect
250-
sigs.k8s.io/kustomize/kyaml v0.20.0 // indirect
247+
sigs.k8s.io/kustomize/api v0.20.1 // indirect
248+
sigs.k8s.io/kustomize/cmd/config v0.20.1 // indirect
249+
sigs.k8s.io/kustomize/kyaml v0.20.1 // indirect
251250
sigs.k8s.io/randfill v1.0.0 // indirect
252251
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
253252
sigs.k8s.io/yaml v1.5.0 // indirect

tools/mod/go.sum

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ github.com/butuzov/ireturn v0.3.1 h1:mFgbEI6m+9W8oP/oDdfA34dLisRFCj2G6o/yiI1yZrY
6868
github.com/butuzov/ireturn v0.3.1/go.mod h1:ZfRp+E7eJLC0NQmk1Nrm1LOrn/gQlOykv+cVPdiXH5M=
6969
github.com/butuzov/mirror v1.3.0 h1:HdWCXzmwlQHdVhwvsfBb2Au0r3HyINry3bDWLYXiKoc=
7070
github.com/butuzov/mirror v1.3.0/go.mod h1:AEij0Z8YMALaq4yQj9CPPVYOyJQyiexpQEQgihajRfI=
71-
github.com/carapace-sh/carapace-shlex v1.0.1 h1:ww0JCgWpOVuqWG7k3724pJ18Lq8gh5pHQs9j3ojUs1c=
72-
github.com/carapace-sh/carapace-shlex v1.0.1/go.mod h1:lJ4ZsdxytE0wHJ8Ta9S7Qq0XpjgjU0mdfCqiI2FHx7M=
7371
github.com/catenacyber/perfsprint v0.8.2 h1:+o9zVmCSVa7M4MvabsWvESEhpsMkhfE7k0sHNGL95yw=
7472
github.com/catenacyber/perfsprint v0.8.2/go.mod h1:q//VWC2fWbcdSLEY1R3l8n0zQCDPdE4IjZwyY1HMunM=
7573
github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg=
@@ -704,14 +702,14 @@ sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1
704702
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
705703
sigs.k8s.io/kind v0.29.0 h1:3TpCsyh908IkXXpcSnsMjWdwdWjIl7o9IMZImZCWFnI=
706704
sigs.k8s.io/kind v0.29.0/go.mod h1:ldWQisw2NYyM6k64o/tkZng/1qQW7OlzcN5a8geJX3o=
707-
sigs.k8s.io/kustomize/api v0.20.0 h1:xPLqcobHI0bThyRUteO+nCV8G4d1Rlo5HafO57VRcas=
708-
sigs.k8s.io/kustomize/api v0.20.0/go.mod h1:F6CfaV27oevRCMJgehLqyX81dlUnRX/Fc13Uo7+OSo4=
709-
sigs.k8s.io/kustomize/cmd/config v0.20.0 h1:wE9wdZmCUgXjiSAKCwkZnlQUg4/tSX8tWKTTwO+tfoY=
710-
sigs.k8s.io/kustomize/cmd/config v0.20.0/go.mod h1:dAv6Y9uZNj4Lnd6cqs+Uy8eE7Xf6slCIW+TdrsSgPpc=
711-
sigs.k8s.io/kustomize/kustomize/v5 v5.7.0 h1:dqZGF+ZLNb0HYrInmEfZR7rStkWrivYO6fwH7QC1RG8=
712-
sigs.k8s.io/kustomize/kustomize/v5 v5.7.0/go.mod h1:9YjxmCuTY10WIZiQDO8LREHImhpvDgX1mabjGyBAEKg=
713-
sigs.k8s.io/kustomize/kyaml v0.20.0 h1:tT8KMKi4R3hCJ1+9HDdek2VoXpkerP92ZfF6fDgGw14=
714-
sigs.k8s.io/kustomize/kyaml v0.20.0/go.mod h1:0EmkQHRUsJxY8Ug9Niig1pUMSCGHxQ5RklbpV/Ri6po=
705+
sigs.k8s.io/kustomize/api v0.20.1 h1:iWP1Ydh3/lmldBnH/S5RXgT98vWYMaTUL1ADcr+Sv7I=
706+
sigs.k8s.io/kustomize/api v0.20.1/go.mod h1:t6hUFxO+Ph0VxIk1sKp1WS0dOjbPCtLJ4p8aADLwqjM=
707+
sigs.k8s.io/kustomize/cmd/config v0.20.1 h1:4APUORmZe2BYrsqgGfEKdd/r7gM6i43egLrUzilpiFo=
708+
sigs.k8s.io/kustomize/cmd/config v0.20.1/go.mod h1:R7rQ8kxknVlXWVUIbxWtMgu8DCCNVtl8V0KrmeVd/KE=
709+
sigs.k8s.io/kustomize/kustomize/v5 v5.7.1 h1:sYJsarwy/SDJfjjLMUqwFDGPwzUtMOQ1i1Ed49+XSbw=
710+
sigs.k8s.io/kustomize/kustomize/v5 v5.7.1/go.mod h1:+5/SrBcJ4agx1SJknGuR/c9thwRSKLxnKoI5BzXFaLU=
711+
sigs.k8s.io/kustomize/kyaml v0.20.1 h1:PCMnA2mrVbRP3NIB6v9kYCAc38uvFLVs8j/CD567A78=
712+
sigs.k8s.io/kustomize/kyaml v0.20.1/go.mod h1:0EmkQHRUsJxY8Ug9Niig1pUMSCGHxQ5RklbpV/Ri6po=
715713
sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
716714
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
717715
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=

0 commit comments

Comments
 (0)