Skip to content

Commit

Permalink
feat: increase concurrency in controllers, make sqlite datastore defa…
Browse files Browse the repository at this point in the history
…ult (#79)

* improvement: use 0.x.x if 0.3.x is not avaiable for flux
* chart: add default args
* improvement: increase number of concurrent for helm controller to 20
* feat: add concurrency for the uffizzi cluster with default value as 5
* fix: make sqlite as the default store
  • Loading branch information
waveywaves authored Nov 22, 2023
1 parent c6285f1 commit 5ae4f46
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/uffizzicluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ type UffizziClusterSpec struct {
ResourceQuota *UffizziClusterResourceQuota `json:"resourceQuota,omitempty"`
LimitRange *UffizziClusterLimitRange `json:"limitRange,omitempty"`
Sleep bool `json:"sleep,omitempty"`
//+kubebuilder:default:="etcd"
//+kubebuilder:default:="sqlite"
//+kubebuilder:validation:Enum=etcd;sqlite
ExternalDatastore string `json:"externalDatastore,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
version: 2.x.x
- name: flux
repository: https://charts.bitnami.com/bitnami
version: 0.3.x
version: 0.x.x
# - name: ingress-nginx
# version: 4.x.x
# repository: https://kubernetes.github.io/ingress-nginx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ spec:
- k8s
type: string
externalDatastore:
default: etcd
default: sqlite
enum:
- etcd
- sqlite
Expand Down
8 changes: 8 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ flux:
enabled: true
metrics:
enabled: false
args:
- --watch-all-namespaces
- --log-level=info
- --metrics-addr=:8080
- --health-addr=:9440
- --log-encoding=json
- --enable-leader-election
- --concurrent=20
sourceController:
enabled: true
metrics:
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/uffizzi.com_uffizziclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ spec:
- k8s
type: string
externalDatastore:
default: etcd
default: sqlite
enum:
- etcd
- sqlite
Expand Down
2 changes: 1 addition & 1 deletion controllers/helm/build/vcluster/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func BuildK3SHelmValues(uCluster *v1alpha1.UffizziCluster) (vcluster.K3S, string
Common: common(helmReleaseName, vclusterIngressHostname),
}

if uCluster.Spec.ExternalDatastore == constants.ETCD || uCluster.Spec.ExternalDatastore == "" {
if uCluster.Spec.ExternalDatastore == constants.ETCD {
vclusterK3sHelmValues.VCluster.Env = []vcluster.ContainerEnv{
{
Name: constants.K3S_DATASTORE_ENDPOINT,
Expand Down
32 changes: 17 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"flag"
etcd "github.com/UffizziCloud/uffizzi-cluster-operator/controllers/etcd"
"github.com/UffizziCloud/uffizzi-cluster-operator/controllers/uffizzicluster"
"k8s.io/utils/pointer"
"os"
ctrlcfg "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
Expand Down Expand Up @@ -56,14 +58,19 @@ func init() {
}

func main() {
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
var (
metricsAddr string
probeAddr string
enableLeaderElection bool
concurrentReconciliations int
)

flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.IntVar(&concurrentReconciliations, "concurrent", 5, "The number of concurrent reconciles per controller.")
opts := zap.Options{
Development: true,
}
Expand All @@ -79,17 +86,12 @@ func main() {
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "bfbf93f2.uffizzi.com",
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
// when the Manager ends. This requires the binary to immediately end when the
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
// speeds up voluntary leader transitions as the new leader don't have to wait
// LeaseDuration time first.
//
// In the default scaffold provided, the program ends immediately after
// the manager stops, so would be fine to enable this option. However,
// if you are doing or is intended to do any operation such as perform cleanups
// after the manager stops then its usage might be unsafe.
// LeaderElectionReleaseOnCancel: true,
Controller: ctrlcfg.ControllerConfigurationSpec{
GroupKindConcurrency: map[string]int{
uclusteruffizzicomv1alpha1.SchemaGroupVersion.WithKind("UffizziCluster").GroupKind().String(): concurrentReconciliations,
},
RecoverPanic: pointer.Bool(true),
},
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand All @@ -108,7 +110,7 @@ func main() {
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "UffizziCluster")
setupLog.Error(err, "unable to create controller", "controller", "UffizziClusterEtcd")
os.Exit(1)
}
//+kubebuilder:scaffold:builder
Expand Down

0 comments on commit 5ae4f46

Please sign in to comment.