Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
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
5 changes: 4 additions & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ else:
# Build cspo and add feature gates
def deploy_cspo():
# yaml = str(kustomizesub("./hack/observability")) # build an observable kind deployment by default
yaml = str(kustomizesub("./config/default"))
if settings.get("local_mode"):
yaml = str(kustomizesub("./config/localmode"))
else:
yaml = str(kustomizesub("./config/default"))
local_resource(
name = "cspo-components",
cmd = ["sh", "-ec", sed_cmd, yaml, "|", envsubst_cmd],
Expand Down
23 changes: 14 additions & 9 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

githubclient "github.com/SovereignCloudStack/cluster-stack-operator/pkg/github/client"
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/github/client/fake"
apiv1alpha1 "github.com/sovereignCloudStack/cluster-stack-provider-openstack/api/v1alpha1"
"github.com/sovereignCloudStack/cluster-stack-provider-openstack/internal/controller"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -49,17 +50,15 @@ func init() {
}

var (
releaseDir string
imageImportTimeout int
releaseDir string
imageImportTimeout int
localMode bool
metricsAddr string
enableLeaderElection bool
probeAddr string
)

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

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(
Expand All @@ -70,6 +69,7 @@ func main() {
)
flag.StringVar(&releaseDir, "release-dir", "/tmp/downloads/", "Specify release directory for cluster-stack releases")
flag.IntVar(&imageImportTimeout, "image-import-timeout", 0, "Maximum time in minutes that you allow cspo to import image. If image-import-timeout <= 0, cspo waits forever.")
flag.BoolVar(&localMode, "local", false, "Enable local mode where no release assets will be downloaded from a remote Git repository. Useful for implementing cluster stacks.")

opts := zap.Options{
Development: true,
Expand Down Expand Up @@ -100,7 +100,12 @@ func main() {
// Initialize event recorder.
record.InitFromRecorder(mgr.GetEventRecorderFor("cspo-controller"))

gitFactory := githubclient.NewFactory()
var gitFactory githubclient.Factory
if localMode {
gitFactory = fake.NewFactory()
} else {
gitFactory = githubclient.NewFactory()
}

if err = (&controller.OpenStackClusterStackReleaseReconciler{
Client: mgr.GetClient(),
Expand Down
10 changes: 10 additions & 0 deletions config/localmode/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace: cspo-system

namePrefix: cspo-
resources:
- ../crd
- ../rbac
- ../manager
patchesStrategicMerge:
- manager_auth_proxy_patch.yaml
- manager_config_patch.yaml
40 changes: 40 additions & 0 deletions config/localmode/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This patch inject a sidecar container which is a HTTP proxy for the
# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews.
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- name: kube-rbac-proxy
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- "ALL"
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8080/"
- "--logtostderr=true"
- "--v=0"
ports:
- containerPort: 8443
protocol: TCP
name: https
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 5m
memory: 64Mi
- name: manager
args:
- "--health-probe-bind-address=:8081"
- "--metrics-bind-address=127.0.0.1:8080"
- "--leader-elect"
- "--local=true"
14 changes: 14 additions & 0 deletions config/localmode/manager_config_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- image: ghcr.io/sovereigncloudstack/cspo-staging:dev
name: manager
args:
- --leader-elect=true
- --local=true
11 changes: 11 additions & 0 deletions config/localmode/manager_pull_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- name: manager
imagePullPolicy: Always

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

1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ github.com/ProtonMail/go-crypto/openpgp/s2k
## explicit; go 1.19
github.com/SovereignCloudStack/cluster-stack-operator/pkg/clusterstack
github.com/SovereignCloudStack/cluster-stack-operator/pkg/github/client
github.com/SovereignCloudStack/cluster-stack-operator/pkg/github/client/fake
github.com/SovereignCloudStack/cluster-stack-operator/pkg/github/client/mocks
github.com/SovereignCloudStack/cluster-stack-operator/pkg/kubernetesversion
github.com/SovereignCloudStack/cluster-stack-operator/pkg/release
Expand Down