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

Resources StorageNodeSet and DatabaseNodeSet #169

Merged
merged 41 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
61f04d1
impl NodeSet resources
kobzonega Nov 27, 2023
d33691a
add nodeset crds
kobzonega Nov 27, 2023
cdaa4fa
bump helm Chart version
kobzonega Nov 27, 2023
2884af3
fix manifests generate
kobzonega Nov 27, 2023
228ee93
register kind of new *NodeSet objects
kobzonega Nov 28, 2023
956c1bd
fix NodeSetBuilder
kobzonega Nov 28, 2023
f1f732b
fix nil pointer
kobzonega Nov 28, 2023
e3b8cb4
fix Placeholder
kobzonega Nov 28, 2023
e679c96
nodeSet concurrentReconciles to 10
kobzonega Nov 28, 2023
7479a15
fixes pointers
kobzonega Nov 28, 2023
4e343a1
refactor
kobzonega Dec 4, 2023
0ebdda5
revert service changes
kobzonega Dec 4, 2023
edd354b
fixes
kobzonega Dec 14, 2023
d325893
storageDomains field
kobzonega Dec 14, 2023
9c0d6ce
lint fixes
kobzonega Dec 15, 2023
20a5362
fix revive golangci-lint warn
kobzonega Dec 15, 2023
cabeb16
check grpc secure refactor
kobzonega Dec 15, 2023
4166500
check inline deletion and observedGeneration change
kobzonega Dec 15, 2023
6446d4f
format Recorder.Event
kobzonega Dec 15, 2023
13123cd
trigger ci
kobzonega Dec 15, 2023
13ebcdf
fix pointer types
kobzonega Dec 15, 2023
4172a8f
fix ResourceRequirements field
kobzonega Dec 15, 2023
4082dbd
move changes in monitoringwebhook to another PR
kobzonega Dec 15, 2023
c438421
fix StorageDomains to use interconnectServiceFQDNFormat
kobzonega Dec 15, 2023
ed2e010
fix git diff
kobzonega Jan 12, 2024
c93b263
Merge branch 'master' into YDBOPS-8646
kobzonega Jan 16, 2024
835e7d0
some fixes
kobzonega Jan 16, 2024
944bd76
fix kube-webhook-certgen sha in tag
kobzonega Jan 16, 2024
48ab23a
wait for helm install and uninstall
kobzonega Jan 16, 2024
d3770b7
allow usage ipv6 k8s e2e cluster
kobzonega Jan 18, 2024
fe1bdd1
separate StorageSpec struct to StorageNodeSpec and StorageClusterSpec
kobzonega Jan 18, 2024
85f07e5
separate DatabaseSpec struct to DatabaseNodeSpec and DatabaseClusterSpec
kobzonega Jan 18, 2024
7ab0c20
remove Image and InitContainers fields from nodeSet
kobzonega Jan 19, 2024
259af4d
use plural names for nodeSets
kobzonega Jan 19, 2024
4c26888
remove Domain and Path fields from NodeSet Spec
kobzonega Jan 21, 2024
5738230
update manifests
kobzonega Jan 21, 2024
fc0067d
webhook defaulter for configuration
kobzonega Jan 21, 2024
39bf223
revert Domain to ClusterSpec for statefulset args
kobzonega Jan 22, 2024
0151792
fix domain name in samples config
kobzonega Jan 23, 2024
1851cde
fix nil pointer containerResources and imagePullPolicy
kobzonega Jan 23, 2024
28549dc
some fixes
kobzonega Jan 23, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: check-pr
on:
on:
pull_request_target:
branches:
- 'master'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upload-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches:
- master
jobs:
tag-job:
tag-job:
runs-on: ubuntu-latest
outputs:
tagcreated: ${{steps.tag-step.outputs.tagcreated}}
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
env:
SA_KEYS_FOR_PRIVATE_DOCKER_HELM_AND_PUBLIC_DOCKER: ${{ secrets.SA_KEYS_FOR_PRIVATE_DOCKER_HELM_AND_PUBLIC_DOCKER }}
- name: parse-version-from-chart
run: |
run: |
VERSION=$(cat ./deploy/ydb-operator/Chart.yaml | sed -n 's/^version: //p')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: login-to-registries
Expand Down
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
cp config/crd/bases/ydb.tech_storages.yaml deploy/ydb-operator/crds/storage.yaml
cp config/crd/bases/ydb.tech_databases.yaml deploy/ydb-operator/crds/database.yaml
cp config/crd/bases/ydb.tech_storagenodesets.yaml deploy/ydb-operator/crds/storagenodeset.yaml
cp config/crd/bases/ydb.tech_databasenodesets.yaml deploy/ydb-operator/crds/databasenodeset.yaml
cp config/crd/bases/ydb.tech_databasemonitorings.yaml deploy/ydb-operator/crds/databasemonitoring.yaml
cp config/crd/bases/ydb.tech_storagemonitorings.yaml deploy/ydb-operator/crds/storagemonitoring.yaml

Expand All @@ -61,13 +63,21 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...

test: manifests generate fmt vet envtest docker-build ## Run tests.
kind create cluster --config e2e/kind-cluster-config.yaml --name kind-ydb-operator
kind-init:
if kind get clusters | grep "kind-ydb-operator"; then exit 0; fi; \
kind create cluster --config e2e/kind-cluster-config.yaml --name kind-ydb-operator; \
docker pull k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0; \
kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 --name kind-ydb-operator; \
docker pull cr.yandex/crptqonuodf51kdj7a7d/ydb:22.4.44; \
kind load docker-image cr.yandex/crptqonuodf51kdj7a7d/ydb:22.4.44 --name kind-ydb-operator

kind-load:
docker tag cr.yandex/yc/ydb-operator:latest kind/ydb-operator:current
kind load docker-image kind/ydb-operator:current --name kind-ydb-operator
docker pull cr.yandex/crptqonuodf51kdj7a7d/ydb:22.4.44
kind load docker-image cr.yandex/crptqonuodf51kdj7a7d/ydb:22.4.44 --name kind-ydb-operator
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -timeout 1800s -p 1 ./... -coverprofile cover.out

.PHONY: test
test: manifests generate fmt vet docker-build kind-init kind-load envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -timeout 1800s -p 1 ./... -ginkgo.v -coverprofile cover.out

.PHONY: clean
clean:
Expand Down
22 changes: 22 additions & 0 deletions api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package v1alpha1

import corev1 "k8s.io/api/core/v1"

// NamespacedRef TODO: replace StorageRef
type NamespacedRef struct {
// +kubebuilder:validation:Pattern:=[a-z0-9]([-a-z0-9]*[a-z0-9])?
Expand All @@ -12,3 +14,23 @@ type NamespacedRef struct {
// +optional
Namespace string `json:"namespace"`
}

// PodImage represents the image information for a container that is used
// to build the StatefulSet.
type PodImage struct {
// Container image with supported YDB version.
// This defaults to the version pinned to the operator and requires a full container and tag/sha name.
// For example: cr.yandex/crptqonuodf51kdj7a7d/ydb:22.2.22
// +optional
Name string `json:"name,omitempty"`

// (Optional) PullPolicy for the image, which defaults to IfNotPresent.
// Default: IfNotPresent
// +optional
PullPolicyName *corev1.PullPolicy `json:"pullPolicy,omitempty"`

// (Optional) Secret name containing the dockerconfig to use for a registry that requires authentication. The secret
// must be configured first by the user.
// +optional
PullSecret *string `json:"pullSecret,omitempty"`
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package configuration
package v1alpha1

import (
"crypto/sha256"
Expand All @@ -8,7 +8,6 @@ import (

"gopkg.in/yaml.v3"

"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/configuration/schema"
)

Expand All @@ -25,20 +24,20 @@ func hash(text string) string {
return fmt.Sprintf("%x", h.Sum(nil))
}

func generateSomeDefaults(cr *v1alpha1.Storage, crDB *v1alpha1.Database) schema.Configuration {
func generateSomeDefaults(cr *Storage, crDB *Database) schema.Configuration {
var hosts []schema.Host

for i := 0; i < int(cr.Spec.Nodes); i++ {
datacenter := "az-1"
if cr.Spec.Erasure == v1alpha1.ErasureMirror3DC {
if cr.Spec.Erasure == ErasureMirror3DC {
datacenter = fmt.Sprintf("az-%d", i%3)
}

hosts = append(hosts, schema.Host{
Host: fmt.Sprintf("%v-%d", cr.GetName(), i),
HostConfigID: 1, // TODO
NodeID: i + 1,
Port: v1alpha1.InterconnectPort,
Port: InterconnectPort,
WalleLocation: schema.WalleLocation{
Body: 12340 + i,
DataCenter: datacenter,
Expand All @@ -47,6 +46,17 @@ func generateSomeDefaults(cr *v1alpha1.Storage, crDB *v1alpha1.Database) schema.
})
}

if cr.Spec.NodeSets != nil {
hostIndex := 0
for _, nodeSetSpec := range cr.Spec.NodeSets {
for podIndex := 0; podIndex < int(nodeSetSpec.Nodes); podIndex++ {
podName := cr.GetName() + "-" + nodeSetSpec.Name + "-" + strconv.Itoa(podIndex)
hosts[hostIndex].Host = podName
hostIndex++
}
}
}

var keyConfig *schema.KeyConfig
if crDB != nil && crDB.Spec.Encryption != nil && crDB.Spec.Encryption.Enabled {
keyConfig = &schema.KeyConfig{
Expand Down Expand Up @@ -79,7 +89,7 @@ func tryFillMissingSections(
}
}

func Build(cr *v1alpha1.Storage, crDB *v1alpha1.Database) (map[string]string, error) {
func buildConfiguration(cr *Storage, crDB *Database) (string, error) {
config := make(map[string]interface{})

// If any kind of configuration exists on Database object, then
Expand All @@ -95,20 +105,16 @@ func Build(cr *v1alpha1.Storage, crDB *v1alpha1.Database) (map[string]string, er

err := yaml.Unmarshal([]byte(rawYamlConfiguration), &config)
if err != nil {
return nil, err
return "", err
}

generatedConfig := generateSomeDefaults(cr, crDB)
tryFillMissingSections(config, generatedConfig)

data, err := yaml.Marshal(config)
if err != nil {
return nil, err
return "", err
}

result := string(data)

return map[string]string{
v1alpha1.ConfigFileName: result,
}, nil
return string(data), nil
}
16 changes: 9 additions & 7 deletions api/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ const (

ImagePathFormat = "%s:%s"

GRPCPort = 2135
GRPCServicePortName = "grpc"
GRPCProto = "grpc://"
GRPCSProto = "grpcs://"

InterconnectPort = 19001
InterconnectServicePortName = "interconnect"
GRPCPort = 2135
GRPCServicePortName = "grpc"
GRPCProto = "grpc://"
GRPCSProto = "grpcs://"
GRPCServiceFQDNFormat = "%s-grpc.%s.svc.cluster.local"

InterconnectPort = 19001
InterconnectServicePortName = "interconnect"
InterconnectServiceFQDNFormat = "%s-interconnect.%s.svc.cluster.local"

StatusPort = 8765
StatusServicePortName = "status"
Expand Down
51 changes: 0 additions & 51 deletions api/v1alpha1/database_defaults.go

This file was deleted.

Loading
Loading