Skip to content

Commit 23af956

Browse files
committed
Issue certifcates for etcd-operator
This commit will add the capability to issue selfsigned certificates for etcd-operator. Signed-off-by: ArkaSaha30 <[email protected]>
1 parent df5acd2 commit 23af956

12 files changed

+207
-113
lines changed

api/v1alpha1/etcdcluster_types.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ import (
2323
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2424
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2525

26+
type EtcdMember struct {
27+
PeerSecret string `json:"peerSecret"`
28+
ServerSecret string `json:"serverSecret"`
29+
}
30+
31+
// TLSCertificate defines the certificate issued by the certificate provider
32+
type TLSCertificate struct {
33+
Member EtcdMember `json:"member,omitempty"`
34+
OperatorSecret string `json:"operatorSecret"`
35+
Provider string `json:"provider"`
36+
}
37+
2638
// EtcdClusterSpec defines the desired state of EtcdCluster.
2739
type EtcdClusterSpec struct {
2840
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
@@ -31,7 +43,8 @@ type EtcdClusterSpec struct {
3143
// Size is the expected size of the etcd cluster.
3244
Size int `json:"size"`
3345
// Version is the expected version of the etcd container image.
34-
Version string `json:"version"`
46+
Version string `json:"version"`
47+
Tls TLSCertificate `json:"tls,omitempty"`
3548
}
3649

3750
// EtcdClusterStatus defines the observed state of EtcdCluster.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Issuer
3+
metadata:
4+
name: selfsigned
5+
namespace: etcd-operator-system
6+
spec:
7+
selfSigned: {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Certificate
3+
metadata:
4+
name: etcd-client-certificate
5+
namespace: etcd-operator-system
6+
spec:
7+
secretName: etcd-client-tls
8+
dnsNames:
9+
- etcd.etcd-operator-system
10+
issuerRef:
11+
name: etcd-operator-selfsigned
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Certificate
3+
metadata:
4+
name: etcd-peer-certificate
5+
namespace: etcd-operator-system
6+
spec:
7+
secretName: etcd-peer-tls
8+
dnsNames:
9+
- etcd.etcd-operator-system
10+
issuerRef:
11+
name: etcd-operator-selfsigned
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Certificate
3+
metadata:
4+
name: etcd-server-certificate
5+
namespace: etcd-operator-system
6+
spec:
7+
secretName: etcd-server-tls
8+
dnsNames:
9+
- etcd.etcd-operator-system
10+
issuerRef:
11+
name: etcd-operator-selfsigned

config/certmanager/kustomization.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
resources:
2+
- cert-manager_issuer.yaml
3+
- etcd-peer-cert.yaml
4+
- etcd-server-cert.yaml
5+
- etcd-client-cert.yaml

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,28 @@ spec:
4242
size:
4343
description: Size is the expected size of the etcd cluster.
4444
type: integer
45+
tls:
46+
description: TLSCertificate defines the certificate issued by the
47+
certificate provider
48+
properties:
49+
member:
50+
properties:
51+
peerSecret:
52+
type: string
53+
serverSecret:
54+
type: string
55+
required:
56+
- peerSecret
57+
- serverSecret
58+
type: object
59+
operatorSecret:
60+
type: string
61+
provider:
62+
type: string
63+
required:
64+
- operatorSecret
65+
- provider
66+
type: object
4567
version:
4668
description: Version is the expected version of the etcd container
4769
image.

config/default/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ resources:
2222
# crd/kustomization.yaml
2323
#- ../webhook
2424
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
25-
#- ../certmanager
25+
- ../certmanager
2626
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
2727
#- ../prometheus
2828
# [METRICS] Expose the controller manager metrics service.

config/manager/kustomization.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
resources:
22
- manager.yaml
3+
apiVersion: kustomize.config.k8s.io/v1beta1
4+
kind: Kustomization
5+
images:
6+
- name: controller
7+
newName: arkasaha30/etcd-operator
8+
newTag: cert2

config/samples/operator_v1alpha1_etcdcluster.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@ metadata:
77
name: etcdcluster-sample
88
spec:
99
# TODO(user): Add fields here
10+
size: 4
11+
version: "3.5.17"
12+
tls:
13+
member:
14+
peerSecret: etcd-peer-tls
15+
serverSecret: etcd-server-tls
16+
operatorSecret: etcd-client-tls
17+
provider: cert-manager
18+

go.mod

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,31 @@ go 1.22.0
55
require (
66
github.com/onsi/ginkgo/v2 v2.19.0
77
github.com/onsi/gomega v1.33.1
8-
k8s.io/apimachinery v0.31.0
9-
k8s.io/client-go v0.31.0
8+
k8s.io/apimachinery v0.31.1
9+
k8s.io/client-go v0.31.1
1010
sigs.k8s.io/controller-runtime v0.19.1
1111
)
1212

1313
require (
1414
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
15-
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
15+
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
1616
github.com/beorn7/perks v1.0.1 // indirect
1717
github.com/blang/semver/v4 v4.0.0 // indirect
1818
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
1919
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2020
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
21-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
21+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
22+
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
2223
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
2324
github.com/felixge/httpsnoop v1.0.4 // indirect
2425
github.com/fsnotify/fsnotify v1.7.0 // indirect
2526
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
2627
github.com/go-logr/logr v1.4.2 // indirect
2728
github.com/go-logr/stdr v1.2.2 // indirect
2829
github.com/go-logr/zapr v1.3.0 // indirect
29-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
30-
github.com/go-openapi/jsonreference v0.20.2 // indirect
31-
github.com/go-openapi/swag v0.22.4 // indirect
30+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
31+
github.com/go-openapi/jsonreference v0.21.0 // indirect
32+
github.com/go-openapi/swag v0.23.0 // indirect
3233
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
3334
github.com/gogo/protobuf v1.3.2 // indirect
3435
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@@ -37,60 +38,61 @@ require (
3738
github.com/google/gnostic-models v0.6.8 // indirect
3839
github.com/google/go-cmp v0.6.0 // indirect
3940
github.com/google/gofuzz v1.2.0 // indirect
40-
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af // indirect
41+
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect
4142
github.com/google/uuid v1.6.0 // indirect
4243
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
43-
github.com/imdario/mergo v0.3.6 // indirect
44+
github.com/imdario/mergo v0.3.16 // indirect
4445
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4546
github.com/josharian/intern v1.0.0 // indirect
4647
github.com/json-iterator/go v1.1.12 // indirect
48+
github.com/klauspost/compress v1.17.9 // indirect
4749
github.com/mailru/easyjson v0.7.7 // indirect
4850
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4951
github.com/modern-go/reflect2 v1.0.2 // indirect
5052
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5153
github.com/pkg/errors v0.9.1 // indirect
52-
github.com/prometheus/client_golang v1.19.1 // indirect
54+
github.com/prometheus/client_golang v1.20.4 // indirect
5355
github.com/prometheus/client_model v0.6.1 // indirect
5456
github.com/prometheus/common v0.55.0 // indirect
5557
github.com/prometheus/procfs v0.15.1 // indirect
5658
github.com/spf13/cobra v1.8.1 // indirect
5759
github.com/spf13/pflag v1.0.5 // indirect
58-
github.com/stoewer/go-strcase v1.2.0 // indirect
60+
github.com/stoewer/go-strcase v1.3.0 // indirect
5961
github.com/x448/float16 v0.8.4 // indirect
60-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
61-
go.opentelemetry.io/otel v1.28.0 // indirect
62+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
63+
go.opentelemetry.io/otel v1.29.0 // indirect
6264
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
6365
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
64-
go.opentelemetry.io/otel/metric v1.28.0 // indirect
66+
go.opentelemetry.io/otel/metric v1.29.0 // indirect
6567
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
66-
go.opentelemetry.io/otel/trace v1.28.0 // indirect
68+
go.opentelemetry.io/otel/trace v1.29.0 // indirect
6769
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
6870
go.uber.org/multierr v1.11.0 // indirect
69-
go.uber.org/zap v1.26.0 // indirect
70-
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
71-
golang.org/x/net v0.26.0 // indirect
72-
golang.org/x/oauth2 v0.21.0 // indirect
73-
golang.org/x/sync v0.7.0 // indirect
74-
golang.org/x/sys v0.21.0 // indirect
75-
golang.org/x/term v0.21.0 // indirect
76-
golang.org/x/text v0.16.0 // indirect
77-
golang.org/x/time v0.3.0 // indirect
78-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
71+
go.uber.org/zap v1.27.0 // indirect
72+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
73+
golang.org/x/net v0.29.0 // indirect
74+
golang.org/x/oauth2 v0.23.0 // indirect
75+
golang.org/x/sync v0.8.0 // indirect
76+
golang.org/x/sys v0.25.0 // indirect
77+
golang.org/x/term v0.24.0 // indirect
78+
golang.org/x/text v0.18.0 // indirect
79+
golang.org/x/time v0.6.0 // indirect
80+
golang.org/x/tools v0.24.0 // indirect
7981
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
80-
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
81-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
82-
google.golang.org/grpc v1.65.0 // indirect
82+
google.golang.org/genproto/googleapis/api v0.0.0-20240827150818-7e3bb234dfed // indirect
83+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
84+
google.golang.org/grpc v1.66.2 // indirect
8385
google.golang.org/protobuf v1.34.2 // indirect
8486
gopkg.in/inf.v0 v0.9.1 // indirect
8587
gopkg.in/yaml.v2 v2.4.0 // indirect
8688
gopkg.in/yaml.v3 v3.0.1 // indirect
87-
k8s.io/api v0.31.0 // indirect
88-
k8s.io/apiextensions-apiserver v0.31.0 // indirect
89-
k8s.io/apiserver v0.31.0 // indirect
90-
k8s.io/component-base v0.31.0 // indirect
89+
k8s.io/api v0.31.1 // indirect
90+
k8s.io/apiextensions-apiserver v0.31.1 // indirect
91+
k8s.io/apiserver v0.31.1 // indirect
92+
k8s.io/component-base v0.31.1 // indirect
9193
k8s.io/klog/v2 v2.130.1 // indirect
92-
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
93-
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
94+
k8s.io/kube-openapi v0.0.0-20240903163716-9e1beecbcb38 // indirect
95+
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 // indirect
9496
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect
9597
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
9698
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect

0 commit comments

Comments
 (0)