Skip to content

Commit

Permalink
Issue 447: OpenApiSchemaValidation added (#448)
Browse files Browse the repository at this point in the history
* openapischemavalidation added

Signed-off-by: prabhaker24 <[email protected]>

* fixed format

Signed-off-by: prabhaker24 <[email protected]>

* fixed typo

Signed-off-by: prabhaker24 <[email protected]>

* changed crd

Signed-off-by: prabhaker24 <[email protected]>

* added more validation in crd

Signed-off-by: prabhaker24 <[email protected]>

* fixed crd in travis.yml file

Signed-off-by: prabhaker24 <[email protected]>

* removed crd from pravega charts

Signed-off-by: prabhaker24 <[email protected]>

* added crd to operator charts

Signed-off-by: prabhaker24 <[email protected]>

* changed name of crd in e2e resources folder

Signed-off-by: prabhaker24 <[email protected]>

* added more check to crd

Signed-off-by: prabhaker24 <[email protected]>

* changed minimum to 0 for controller and ss

Signed-off-by: prabhaker24 <[email protected]>

* added back printercolumns

Signed-off-by: prabhaker24 <[email protected]>

Co-authored-by: prabhaker24 <[email protected]>
  • Loading branch information
Prabhaker24 and prabhaker24 authored Sep 21, 2020
1 parent 8b5e0ab commit 282aa7d
Show file tree
Hide file tree
Showing 17 changed files with 5,657 additions and 2,444 deletions.
811 changes: 0 additions & 811 deletions charts/pravega-operator/templates/crd.yaml

This file was deleted.

1,580 changes: 1,580 additions & 0 deletions charts/pravega-operator/templates/pravega.pravega.io_pravegaclusters_crd.yaml

Large diffs are not rendered by default.

803 changes: 0 additions & 803 deletions deploy/crds/crd.yaml

This file was deleted.

1,573 changes: 1,573 additions & 0 deletions deploy/crds/pravega.pravega.io_pravegaclusters_crd.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/manual-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $ kubectl create -f deploy/version_map.yaml
```
Register the Pravega cluster custom resource definition (CRD).
```
$ kubectl create -f deploy/crds/crd.yaml
$ kubectl create -f deploy/crds/pravega.pravega.io_pravegaclusters_crd.yaml
```
Create the operator role, role binding and service account.
```
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ require (
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da
github.com/securego/gosec v0.0.0-20200401082031-e946c8c39989 // indirect
github.com/sirupsen/logrus v1.5.0
github.com/stripe/safesql v0.2.0 // indirect
github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9 // indirect
github.com/walle/lll v1.0.1 // indirect
golang.org/x/tools v0.0.0-20200426102838-f3a5411a4c3b // indirect
k8s.io/api v0.17.5
k8s.io/apimachinery v0.17.5
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alexflint/go-arg v0.0.0-20160306200701-e71d6514f40a h1:Bc+P30eTWphhueyACA/fjiHJXRDq/kGiqO38nGxvml0=
github.com/alexflint/go-arg v0.0.0-20160306200701-e71d6514f40a/go.mod h1:PHxo6ZWOLVMZZgWSAqBynb/KhIqoGO6WKwOVX7rM9dg=
github.com/aliyun/aliyun-oss-go-sdk v2.0.4+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
Expand Down Expand Up @@ -952,6 +954,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stripe/safesql v0.2.0 h1:xiefmCDd8c35PVSGrL2FhBiaKxviXnGziBDOpOejeBE=
github.com/stripe/safesql v0.2.0/go.mod h1:q7b2n0JmzM1mVGfcYpanfVb2j23cXZeWFxcILPn3JV4=
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
Expand All @@ -962,6 +966,7 @@ github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhV
github.com/timakin/bodyclose v0.0.0-20190721030226-87058b9bfcec/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9 h1:vY5WqiEon0ZSTGM3ayVVi+twaHKHDFUVloaQ/wug9/c=
github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9/go.mod h1:q+QjxYvZ+fpjMXqs+XEriussHjSYqeXVnAdSV1tkMYk=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/uber/jaeger-client-go v2.20.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
Expand Down
23 changes: 18 additions & 5 deletions pkg/apis/pravega/v1alpha1/bookkeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package v1alpha1

import (
"github.com/pravega/pravega-operator/pkg/controller/config"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)

Expand Down Expand Up @@ -58,17 +58,21 @@ const (
type BookkeeperSpec struct {
// Image defines the BookKeeper Docker image to use.
// By default, "pravega/bookkeeper" will be used.
// +optional
Image *BookkeeperImageSpec `json:"image"`

// Replicas defines the number of BookKeeper replicas.
// Minimum is 3. Defaults to 3.
// +optional
Replicas int32 `json:"replicas"`

// Storage configures the storage for BookKeeper
// +optional
Storage *BookkeeperStorageSpec `json:"storage"`

// AutoRecovery indicates whether or not BookKeeper auto recovery is enabled.
// Defaults to true.
// +optional
AutoRecovery *bool `json:"autoRecovery"`

// ServiceAccountName configures the service account used on BookKeeper instances
Expand All @@ -81,11 +85,13 @@ type BookkeeperSpec struct {
// Options is the Bookkeeper configuration that is to override the bk_server.conf
// in bookkeeper. Some examples can be found here
// https://github.com/apache/bookkeeper/blob/master/docker/README.md
// +optional
Options map[string]string `json:"options"`

// JVM is the JVM options for bookkeeper. It will be passed to the JVM for performance tuning.
// If this field is not specified, the operator will use a set of default
// options that is good enough for general deployment.
// +optional
BookkeeperJVMOptions *BookkeeperJVMOptions `json:"bookkeeperJVMOptions"`
}

Expand Down Expand Up @@ -149,7 +155,7 @@ func (s *BookkeeperSpec) withDefaults() (changed bool) {

// BookkeeperImageSpec defines the fields needed for a BookKeeper Docker image
type BookkeeperImageSpec struct {
ImageSpec
ImageSpec `json:"imageSpec,omitempty"`
}

func (s *BookkeeperImageSpec) withDefaults() (changed bool) {
Expand All @@ -169,10 +175,14 @@ func (s *BookkeeperImageSpec) withDefaults() (changed bool) {
}

type BookkeeperJVMOptions struct {
MemoryOpts []string `json:"memoryOpts"`
GcOpts []string `json:"gcOpts"`
// +optional
MemoryOpts []string `json:"memoryOpts"`
// +optional
GcOpts []string `json:"gcOpts"`
// +optional
GcLoggingOpts []string `json:"gcLoggingOpts"`
ExtraOpts []string `json:"extraOpts"`
// +optional
ExtraOpts []string `json:"extraOpts"`
}

func (s *BookkeeperJVMOptions) withDefaults() (changed bool) {
Expand Down Expand Up @@ -204,16 +214,19 @@ type BookkeeperStorageSpec struct {
// LedgerVolumeClaimTemplate is the spec to describe PVC for the BookKeeper ledger
// This field is optional. If no PVC spec and there is no default storage class,
// stateful containers will use emptyDir as volume
// +optional
LedgerVolumeClaimTemplate *v1.PersistentVolumeClaimSpec `json:"ledgerVolumeClaimTemplate"`

// JournalVolumeClaimTemplate is the spec to describe PVC for the BookKeeper journal
// This field is optional. If no PVC spec and there is no default storage class,
// stateful containers will use emptyDir as volume
// +optional
JournalVolumeClaimTemplate *v1.PersistentVolumeClaimSpec `json:"journalVolumeClaimTemplate"`

// IndexVolumeClaimTemplate is the spec to describe PVC for the BookKeeper index
// This field is optional. If no PVC spec and there is no default storage class,
// stateful containers will use emptyDir as volume
// +optional
IndexVolumeClaimTemplate *v1.PersistentVolumeClaimSpec `json:"indexVolumeClaimTemplate"`
}

Expand Down
35 changes: 27 additions & 8 deletions pkg/apis/pravega/v1alpha1/pravega.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package v1alpha1

import (
"github.com/pravega/pravega-operator/pkg/controller/config"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)

Expand Down Expand Up @@ -69,43 +69,52 @@ const (
type PravegaSpec struct {
// ControllerReplicas defines the number of Controller replicas.
// Defaults to 1.
// +optional
ControllerReplicas int32 `json:"controllerReplicas"`

// SegmentStoreReplicas defines the number of Segment Store replicas.
// Defaults to 1.
// +optional
SegmentStoreReplicas int32 `json:"segmentStoreReplicas"`

// DebugLogging indicates whether or not debug level logging is enabled.
// Defaults to false.
// +optional
DebugLogging bool `json:"debugLogging"`

// Image defines the Pravega Docker image to use.
// By default, "pravega/pravega" will be used.
// +optional
Image *PravegaImageSpec `json:"image"`

// Options is the Pravega configuration that is passed to the Pravega processes
// as JAVA_OPTS. See the following file for a complete list of options:
// https://github.com/pravega/pravega/blob/master/config/config.properties
// +optional
Options map[string]string `json:"options"`

// ControllerJvmOptions is the JVM options for controller. It will be passed to the JVM
// for performance tuning. If this field is not specified, the operator will use a set of default
// options that is good enough for general deployment.
// +optional
ControllerJvmOptions []string `json:"controllerjvmOptions"`

// SegmentStoreJVMOptions is the JVM options for Segmentstore. It will be passed to the JVM
// for performance tuning. If this field is not specified, the operator will use a set of default
// options that is good enough for general deployment.
// +optional
SegmentStoreJVMOptions []string `json:"segmentStoreJVMOptions"`

// CacheVolumeClaimTemplate is the spec to describe PVC for the Pravega cache.
// This field is optional. If no PVC spec, stateful containers will use
// emptyDir as volume
// +optional
CacheVolumeClaimTemplate *v1.PersistentVolumeClaimSpec `json:"cacheVolumeClaimTemplate"`

// Tier2 is the configuration of Pravega's tier 2 storage. If no configuration
// is provided, it will assume that a PersistentVolumeClaim called "pravega-tier2"
// is present and it will use it as Tier 2
// +optional
Tier2 *Tier2Spec `json:"tier2"`

// ControllerServiceAccountName configures the service account used on controller instances.
Expand All @@ -130,6 +139,7 @@ type PravegaSpec struct {
ControllerExternalServiceType v1.ServiceType `json:"controllerExtServiceType,omitempty"`

// Annotations to be added to the external service
// +optional
ControllerServiceAnnotations map[string]string `json:"controllerSvcAnnotations"`

// Type specifies the service type to achieve external access.
Expand All @@ -138,6 +148,7 @@ type PravegaSpec struct {
SegmentStoreExternalServiceType v1.ServiceType `json:"segmentStoreExtServiceType,omitempty"`

// Annotations to be added to the external service
// +optional
SegmentStoreServiceAnnotations map[string]string `json:"segmentStoreSvcAnnotations"`
}

Expand Down Expand Up @@ -239,7 +250,7 @@ func (s *PravegaSpec) withDefaults() (changed bool) {

// PravegaImageSpec defines the fields needed for a Pravega Docker image
type PravegaImageSpec struct {
ImageSpec
ImageSpec `json:"imageSpec,omitempty"`
}

func (s *PravegaImageSpec) withDefaults() (changed bool) {
Expand Down Expand Up @@ -290,20 +301,28 @@ func (s *Tier2Spec) withDefaults() (changed bool) {

// FileSystemSpec contains the reference to a PVC.
type FileSystemSpec struct {
// +optional
PersistentVolumeClaim *v1.PersistentVolumeClaimVolumeSource `json:"persistentVolumeClaim"`
}

// ECSSpec contains the connection details to a Dell EMC ECS system
type ECSSpec struct {
ConfigUri string `json:"configUri"`
Bucket string `json:"bucket"`
Prefix string `json:"prefix"`
// +optional
ConfigUri string `json:"configUri"`
// +optional
Bucket string `json:"bucket"`
// +optional
Prefix string `json:"prefix"`
// +optional
Credentials string `json:"credentials"`
}

// HDFSSpec contains the connection details to an HDFS system
type HDFSSpec struct {
Uri string `json:"uri"`
Root string `json:"root"`
ReplicationFactor int32 `json:"replicationFactor"`
// +optional
Uri string `json:"uri"`
// +optional
Root string `json:"root"`
// +optional
ReplicationFactor int32 `json:"replicationFactor"`
}
21 changes: 20 additions & 1 deletion pkg/apis/pravega/v1alpha1/pravegacluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,19 @@ type PravegaClusterList struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true

// Generate CRD using kubebuilder

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=pk
// +kubebuilder:printcolumn:name="Version",type=string,JSONPath=`.status.currentVersion`,description="The current pravega version"
// +kubebuilder:printcolumn:name="Desired Version",type=string,JSONPath=`.spec.version`,description="The desired pravega version"
// +kubebuilder:printcolumn:name="Desired Members",type=integer,JSONPath=`.status.replicas`,description="The number of desired pravega members"
// +kubebuilder:printcolumn:name="Ready Members",type=integer,JSONPath=`.status.readyReplicas`,description="The number of ready pravega members"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// PravegaCluster is the Schema for the pravegaclusters API
// +k8s:openapi-gen=true
type PravegaCluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -77,11 +87,13 @@ type ClusterSpec struct {
// By default, the value "zookeeper-client:2181" is used, that corresponds to the
// default Zookeeper service created by the Pravega Zookkeeper operator
// available at: https://github.com/pravega/zookeeper-operator
// +optional
ZookeeperUri string `json:"zookeeperUri"`

// ExternalAccess specifies whether or not to allow external access
// to clients and the service type to use to achieve it
// By default, external access is not enabled
// +optional
ExternalAccess *ExternalAccess `json:"externalAccess"`

// TLS is the Pravega security configuration that is passed to the Pravega processes.
Expand All @@ -102,12 +114,15 @@ type ClusterSpec struct {
// Only Pravega released versions are supported: https://github.com/pravega/pravega/releases
//
// If version is not set, default is "0.4.0".
// +optional
Version string `json:"version"`

// Bookkeeper configuration
// +optional
Bookkeeper *BookkeeperSpec `json:"bookkeeper"`

// Pravega configuration
// +optional
Pravega *PravegaSpec `json:"pravega"`
}

Expand Down Expand Up @@ -167,6 +182,7 @@ func (s *ClusterSpec) withDefaults() (changed bool) {
type ExternalAccess struct {
// Enabled specifies whether or not external access is enabled
// By default, external access is not enabled
// +optional
Enabled bool `json:"enabled"`

// Type specifies the service type to achieve external access.
Expand Down Expand Up @@ -223,6 +239,7 @@ func (tp *TLSPolicy) IsCaBundlePresent() bool {
type AuthenticationParameters struct {
// Enabled specifies whether or not authentication is enabled
// By default, authentication is not enabled
// +optional
Enabled bool `json:"enabled"`

// name of Secret containing Password based Authentication Parameters like username, password and acl
Expand All @@ -239,10 +256,12 @@ func (ap *AuthenticationParameters) IsEnabled() bool {

// ImageSpec defines the fields needed for a Docker repository image
type ImageSpec struct {
// +optional
Repository string `json:"repository"`

// Deprecated: Use `spec.Version` instead
Tag string `json:"tag,omitempty"`

// +optional
PullPolicy v1.PullPolicy `json:"pullPolicy"`
}
12 changes: 11 additions & 1 deletion pkg/apis/pravega/v1alpha1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,42 @@ type ClusterStatus struct {
VersionHistory []string `json:"versionHistory,omitempty"`

// Replicas is the number of desired replicas in the cluster
// +optional
Replicas int32 `json:"replicas"`

// CurrentReplicas is the number of current replicas in the cluster
// +optional
CurrentReplicas int32 `json:"currentReplicas"`

// ReadyReplicas is the number of ready replicas in the cluster
// +optional
ReadyReplicas int32 `json:"readyReplicas"`

// Members is the Pravega members in the cluster
// +optional
Members MembersStatus `json:"members"`
}

// MembersStatus is the status of the members of the cluster with both
// ready and unready node membership lists
type MembersStatus struct {
Ready []string `json:"ready"`
// +optional
// +nullable
Ready []string `json:"ready"`
// +optional
// +nullable
Unready []string `json:"unready"`
}

// ClusterCondition shows the current condition of a Pravega cluster.
// Comply with k8s API conventions
type ClusterCondition struct {
// Type of Pravega cluster condition.
// +optional
Type ClusterConditionType `json:"type"`

// Status of the condition, one of True, False, Unknown.
// +optional
Status corev1.ConditionStatus `json:"status"`

// The reason for the condition's last transition.
Expand Down
Loading

0 comments on commit 282aa7d

Please sign in to comment.