Skip to content

Commit 148121b

Browse files
authored
feat(registry): using etcd storage for chartmuseum (#1333)
1 parent 08cdc03 commit 148121b

File tree

11 files changed

+187
-46
lines changed

11 files changed

+187
-46
lines changed

cmd/tke-installer/app/installer/manifests/tke-registry-api/tke-registry-api.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ data:
184184
apiVersion: registry.config.tkestack.io/v1
185185
kind: RegistryConfiguration
186186
storage:
187+
etcd:
188+
cafile: "/app/certs/etcd-ca.crt"
189+
certfile: "/app/certs/etcd.crt"
190+
keyfile: "/app/certs/etcd.key"
191+
endpoints:
192+
- "https://etcd.kube-system:2379"
193+
prefix: "/chart_backend_bucket"
187194
fileSystem:
188195
rootDirectory: /storage
189196
delete:

cmd/tke-installer/app/installer/manifests/tke-registry-controller/tke-registry-controller.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ data:
106106
apiVersion: registry.config.tkestack.io/v1
107107
kind: RegistryConfiguration
108108
storage:
109+
etcd:
110+
cafile: "/app/certs/etcd-ca.crt"
111+
certfile: "/app/certs/etcd.crt"
112+
keyfile: "/app/certs/etcd.key"
113+
endpoints:
114+
- "https://etcd.kube-system:2379"
115+
prefix: "/chart_backend_bucket"
109116
fileSystem:
110117
rootDirectory: /storage
111118
security:

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ module tkestack.io/tke
33
go 1.12
44

55
replace (
6-
github.com/chartmuseum/storage => github.com/choujimmy/storage v0.0.0-20200507092433-6aea2df34764
6+
github.com/chartmuseum/storage => github.com/choujimmy/storage v0.5.1-0.20210412121305-660c0e91489b
7+
github.com/containerd/containerd => github.com/containerd/containerd v1.4.3
78
github.com/deislabs/oras => github.com/deislabs/oras v0.8.0
9+
go.etcd.io/etcd => go.etcd.io/etcd v0.5.0-alpha.5.0.20200819165624-17cef6e3e9d5
810
google.golang.org/grpc => google.golang.org/grpc v1.26.0
911
helm.sh/helm/v3 => helm.sh/helm/v3 v3.2.0
1012
k8s.io/client-go => k8s.io/client-go v0.18.2
@@ -82,6 +84,7 @@ require (
8284
gopkg.in/square/go-jose.v2 v2.4.1
8385
gopkg.in/yaml.v2 v2.3.0
8486
gotest.tools v2.2.0+incompatible
87+
gotest.tools/v3 v3.0.3 // indirect
8588
helm.sh/chartmuseum v0.12.0
8689
helm.sh/helm/v3 v3.3.4
8790
istio.io/api v0.0.0-20200715212100-dbf5277541ef

go.sum

Lines changed: 20 additions & 42 deletions
Large diffs are not rendered by default.

pkg/registry/apis/config/types.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ type RegistryConfiguration struct {
3434
Redis *Redis
3535
DefaultTenant string
3636
// +optional
37-
DomainSuffix string
37+
DomainSuffix string
3838
HarborEnabled bool
39-
HarborCAFile string
39+
HarborCAFile string
4040
}
4141

4242
type Storage struct {
@@ -47,8 +47,18 @@ type Storage struct {
4747
// +optional
4848
S3 *S3Storage
4949
// +optional
50+
Etcd *EtcdStorage
51+
// +optional
5052
Delete *Delete
5153
}
54+
type EtcdStorage struct {
55+
CAFile string
56+
CertFile string
57+
KeyFile string
58+
EndPoints []string
59+
// +optional
60+
Prefix string
61+
}
5262

5363
type FileSystemStorage struct {
5464
RootDirectory string

pkg/registry/apis/config/v1/types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,20 @@ type Storage struct {
4747
// +optional
4848
S3 *S3Storage `json:"s3,omitempty" yaml:"s3,omitempty"`
4949
// +optional
50+
Etcd *EtcdStorage `json:"etcd,omitempty" yaml:"etcd,omitempty"`
51+
// +optional
5052
Delete *Delete `json:"delete,omitempty" yaml:"delete,omitempty"`
5153
}
5254

55+
type EtcdStorage struct {
56+
CAFile string `json:"cafile" yaml:"cafile"`
57+
CertFile string `json:"certfile" yaml:"certfile"`
58+
KeyFile string `json:"keyfile" yaml:"keyfile"`
59+
EndPoints []string `json:"endpoints" yaml:"endpoints"`
60+
// +optional
61+
Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty"`
62+
}
63+
5364
type FileSystemStorage struct {
5465
RootDirectory string `json:"rootDirectory" yaml:"rootDirectory"`
5566
// +optional

pkg/registry/apis/config/v1/zz_generated.conversion.go

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/registry/apis/config/v1/zz_generated.deepcopy.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/registry/apis/config/validation/validation.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@ func ValidateRegistryConfiguration(rc *registryconfig.RegistryConfiguration) err
3131
storageCount := 0
3232
storageFld := field.NewPath("storage")
3333

34+
if rc.Storage.Etcd != nil {
35+
storageCount++
36+
subFld := storageFld.Child("etcd")
37+
38+
if rc.Storage.Etcd.CAFile == "" {
39+
allErrors = append(allErrors, field.Required(subFld.Child("cafile"), "must be specify"))
40+
}
41+
if rc.Storage.Etcd.CertFile == "" {
42+
allErrors = append(allErrors, field.Required(subFld.Child("certfile"), "must be specify"))
43+
}
44+
if rc.Storage.Etcd.KeyFile == "" {
45+
allErrors = append(allErrors, field.Required(subFld.Child("keyfile"), "must be specify"))
46+
}
47+
if len(rc.Storage.Etcd.EndPoints) == 0 {
48+
allErrors = append(allErrors, field.Required(subFld.Child("endpoints"), "must be specify"))
49+
}
50+
}
51+
3452
if rc.Storage.S3 != nil {
3553
storageCount++
3654
subFld := storageFld.Child("s3")

pkg/registry/apis/config/zz_generated.deepcopy.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)