Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(registry): provide registry maintenance readonly mode #1978

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ data:
{{- end }}
delete:
enabled: true
maintenance:
readonly:
enabled: false
security:
tokenPrivateKeyFile: /etc/registry/private_key.pem
tokenPublicKeyFile: /etc/registry/public_key.crt
Expand Down
11 changes: 11 additions & 0 deletions pkg/registry/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type Storage struct {
Etcd *EtcdStorage
// +optional
Delete *Delete
// +optional
Maintenance *Maintenance
}
type EtcdStorage struct {
CAFile string
Expand Down Expand Up @@ -119,6 +121,15 @@ type Delete struct {
Enabled bool
}

// Maintenance ReadOnly enabled set to true, clients will not be allowed to write to the registry.
type Maintenance struct {
ReadOnly ReadOnly
}

type ReadOnly struct {
Enabled bool
}

type Security struct {
TokenPrivateKeyFile string
TokenPublicKeyFile string
Expand Down
11 changes: 11 additions & 0 deletions pkg/registry/apis/config/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type Storage struct {
Etcd *EtcdStorage `json:"etcd,omitempty" yaml:"etcd,omitempty"`
// +optional
Delete *Delete `json:"delete,omitempty" yaml:"delete,omitempty"`
// +optional
Maintenance *Maintenance `json:"maintenance,omitempty" yaml:"maintenance,omitempty"`
}

type EtcdStorage struct {
Expand Down Expand Up @@ -120,6 +122,15 @@ type Delete struct {
Enabled bool `json:"enabled" yaml:"enabled"`
}

// Maintenance ReadOnly enabled set to true, clients will not be allowed to write to the registry.
type Maintenance struct {
ReadOnly ReadOnly `json:"readonly" yaml:"readonly"`
}

type ReadOnly struct {
Enabled bool `json:"enabled" yaml:"enabled"`
}

type Security struct {
TokenPrivateKeyFile string `json:"tokenPrivateKeyFile" yaml:"tokenPrivateKeyFile"`
TokenPublicKeyFile string `json:"tokenPublicKeyFile" yaml:"tokenPublicKeyFile"`
Expand Down
66 changes: 66 additions & 0 deletions pkg/registry/apis/config/v1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions pkg/registry/apis/config/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions pkg/registry/apis/config/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/registry/distribution/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,10 @@ func buildStorageConfiguration(opts *Options) map[string]configuration.Parameter
deleteDriver["enabled"] = storageCfg.Delete.Enabled
storage["delete"] = deleteDriver
}
if storageCfg.Maintenance != nil {
storage["maintenance"] = configuration.Parameters{
"readonly": map[interface{}]interface{}{"enabled": storageCfg.Maintenance.ReadOnly.Enabled},
}
}
return storage
}