Skip to content

Commit

Permalink
Merge pull request #21 from kuidio/choreo
Browse files Browse the repository at this point in the history
Choreo
  • Loading branch information
henderiw authored Oct 30, 2024
2 parents 91e584d + 49b47eb commit 17bc7b6
Show file tree
Hide file tree
Showing 784 changed files with 52,132 additions and 89,686 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
Expand Down
40 changes: 40 additions & 0 deletions DESIGN-DEPLOYMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# deployment options

- async design with a generic backend -> reocncilers needed
- async design with etcd -> reconcilers needed
- sync design with a generic backend
- sync design with choreo


async versus sync:
- Async need a reconciler
- Sync can have a special way to allocate before -> create/update/delete are special; watch/list are the same
- Sync cannot be done with etcd as the storage interface changed
- Sync -> We do a special init for both options -> main reason is to use a direct storage interface for saveALL and restore functions
-> we init all 3 resources together due to the storage

## How to select which objects should be rendered?

- name: ENABLE_BE_AS (group)
value: "sync,badgerdb" | "true"
- name: ENABLE_BE_VLAN (group)
value: "sync" | "true"
- name: ENABLE_BE_IPAM (group)
value: "sync" | "true"

## Select between sync and async also per group

-> using ENV flags


## open

- FieldSelector would be nice when listing the items to be able to check if they belong to the index
- Update? How to handle
- Conversion function for CRD(s) - how does this work ???? -> this will determine if we can keep choreo aligned or not

Choreo -> we need a conversion function conversion function


TODO:
- align the rest interface from choreo with the rest interface of
4 changes: 3 additions & 1 deletion DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ Development
4. update artifact
- reconciler
- permissions
- apiservice
- apiservice


2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

# Build the manager binary
FROM golang:1.22 as builder
FROM golang:1.23 as builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
29 changes: 15 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ KFORM ?= $(LOCALBIN)/kform
KFORM_VERSION ?= v0.0.2

# go versions
TARGET_GO_VERSION := go1.21.4
GO_FALLBACK := go
#TARGET_GO_VERSION := go1.21.4
#GO_FALLBACK := go
# We prefer $TARGET_GO_VERSION if it is not available we go with whatever go we find ($GO_FALLBACK)
GO_BIN := $(shell if [ "$$(which $(TARGET_GO_VERSION))" != "" ]; then echo $$(which $(TARGET_GO_VERSION)); else echo $$(which $(GO_FALLBACK)); fi)
#GO_BIN := $(shell if [ "$$(which $(TARGET_GO_VERSION))" != "" ]; then echo $$(which $(TARGET_GO_VERSION)); else echo $$(which $(GO_FALLBACK)); fi)

GOBIN := $(shell go env GOPATH)/bin

.PHONY: codegen fix fmt vet lint test tidy

Expand Down Expand Up @@ -60,23 +62,22 @@ genclients:
-g informer-gen \
-g lister-gen \
-g openapi-gen \
-g go-to-protobuf \
-g defaulter-gen \
-g conversion-gen \
#-g go-to-protobuf \
--module $(REPO) \
--versions $(REPO)/apis/condition/v1alpha1,$(REPO)/apis/common/v1alpha1,$(REPO)/apis/backend/ipam/v1alpha1,$(REPO)/apis/backend/vlan/v1alpha1,$(REPO)/apis/backend/vxlan/v1alpha1,$(REPO)/apis/backend/as/v1alpha1,$(REPO)/apis/backend/esi/v1alpha1,$(REPO)/apis/backend/extcomm/v1alpha1,$(REPO)/apis/backend/genid/v1alpha1,$(REPO)/apis/backend/infra/v1alpha1

.PHONY: generate
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./apis/inv/..."

.PHONY: manifests
manifests: controller-gen artifacts ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
mkdir -p artifacts
##$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./apis/resource/..." output:crd:artifacts:config=artifacts
##$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./apis/resource/..."
##$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./apis/inv/..."
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./apis/..."

.PHONY: crds
crds: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
mkdir -p crds
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./apis/..." output:crd:artifacts:config=crds

.PHONY: artifacts
artifacts: kform manifests
artifacts: kform
mkdir -p artifacts/out
$(KFORM) apply artifacts -o artifacts/out/artifacts.yaml

Expand Down
22 changes: 22 additions & 0 deletions SYNC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# sync startegy

- create/delete index lock/unlock
- when creating/deleting an index -> claims are called which cause a lock issue
- we have a single lock on index create/delete and claim create/delete
- we introduce a special dryrin flag since the delete has very few options if []string{"recursion"} is set we treat this as a special behavior

## differences

1. deleteIndex
- sync: claims and entries get deleted
- async: claims from index get deleted, but other not -> reconciler should trigger the status

2. restart app -> restore
- sync/async: create index need to be triggered (reconciler needed)

3. status of index
- sync/async: reconciler update status with status subresource (reconciler needed)

4. order is important
- sync: when something fails the client need to handle this; once accepted it remains in the system
- async: reconciler tries to recover
5 changes: 5 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# TODO

- rework generic backend to also update MIN/MAX as aprt of index creation (similar to ipam)
- proto generation (also needed for configserver)
- add reconcilers for non IPAM resources
30 changes: 30 additions & 0 deletions apis/all/all.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2024 Nokia.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package all

import (
_ "github.com/kuidio/kuid/apis/infra/register"
_ "github.com/kuidio/kuid/apis/backend/as/register"
_ "github.com/kuidio/kuid/apis/backend/ipam/register"
_ "github.com/kuidio/kuid/apis/backend/vlan/register"
_ "github.com/kuidio/kuid/apis/backend/genid/register"
_ "github.com/kuidio/kuid/apis/backend/extcomm/register"

)

//vxlanbev1alpha1.AddToScheme,
//extcommbev1alpha1.AddToScheme,
46 changes: 26 additions & 20 deletions apis/backend/LabelKeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ import "k8s.io/apimachinery/pkg/util/sets"

const (
// system defined common
KuidOwnerGroupKey = "be.kuid.dev/owner-group"
KuidOwnerVersionKey = "be.kuid.dev/owner-version"
KuidOwnerKindKey = "be.kuid.dev/owner-kind"
KuidOwnerNameKey = "be.kuid.dev/owner-name"
KuidOwnerNamespaceKey = "be.kuid.dev/owner-namespace"
KuidClaimNameKey = "be.kuid.dev/claim-name"
KuidClaimTypeKey = "be.kuid.dev/claim-type"
//KuidOwnerGroupKey = "be.kuid.dev/owner-group"
//KuidOwnerVersionKey = "be.kuid.dev/owner-version"
//KuidOwnerNameKey = "be.kuid.dev/owner-name"
//KuidOwnerNamespaceKey = "be.kuid.dev/owner-namespace"
KuidOwnerKindKey = "be.kuid.dev/owner-kind" // we need to track this to ensure a claim from an index is distinguished from a regular claim
KuidClaimNameKey = "be.kuid.dev/claim-name"
KuidClaimUIDKey = "be.kuid.dev/claim-uid"
KuidClaimTypeKey = "be.kuid.dev/claim-type"
KuidIndexEntryKey = "be.kuid.dev/index-entry"
// system defined ipam
KuidIPAMIPPrefixTypeKey = "ipam.be.kuid.dev/ipprefix-type"
KuidIPAMClaimSummaryTypeKey = "ipam.be.kuid.dev/claim-summary-type"
KuidIPAMClaimSummaryTypeKey = "ipam.be.kuid.dev/claim-summary-type" // used for easy lookup
KuidIPAMddressFamilyKey = "ipam.be.kuid.dev/address-family"
KuidIPAMSubnetKey = "ipam.be.kuid.dev/subnet" // this is the subnet in prefix annotation used for GW selection
KuidIPAMDefaultGatewayKey = "ipam.be.kuid.dev/default-gateway"
KuidIPAMIndexKey = "ipam.be.kuid.dev/index"
//KuidIPAMIndexKey = "ipam.be.kuid.dev/index"

// DNS used keys
KuidINVNetworkKey = "inv.kuid.dev/network"
Expand Down Expand Up @@ -61,23 +63,27 @@ const (
KuidINVNetworkLinkBFDMinRX = "link.network.infra.be.kuid.dev/bfd-min-rx" //
)

var BackendSystemKeys = sets.New[string](KuidOwnerGroupKey,
KuidOwnerVersionKey,
KuidOwnerKindKey,
KuidOwnerNameKey,
KuidOwnerNamespaceKey,
// BackendSystemKeys defined the system keys
// used internally in the cache for faster label based lookups.
// Used to filter the system keys from the information presented
// to the outside world when generating the XXEntry object
var BackendSystemKeys = sets.New[string](
KuidClaimNameKey,
KuidClaimUIDKey,
KuidOwnerKindKey,
KuidClaimTypeKey,
KuidIndexEntryKey,
)

var BackendIPAMSystemKeys = sets.New[string](KuidOwnerGroupKey,
// BackendIPAMSystemKeys defined the system IPAM keys
// used internally in the cache for faster label based lookups
// Used to filter the system keys from the information presented
// to the outside world when generating the IP Entry object
var BackendIPAMSystemKeys = sets.New[string](
KuidIPAMIPPrefixTypeKey,
KuidIPAMClaimSummaryTypeKey,
KuidClaimTypeKey,
KuidIPAMddressFamilyKey,
KuidIPAMSubnetKey,
KuidIPAMDefaultGatewayKey,
KuidIPAMIndexKey,
)

var BackendSystemClaimKeys = sets.New[string](KuidOwnerGroupKey,
KuidClaimTypeKey,
)
Loading

0 comments on commit 17bc7b6

Please sign in to comment.