Skip to content

Commit 24ce436

Browse files
AlexVulajMoritz Clasmeier
authored andcommitted
Support multi-cluster deployments (Central + SecuredCluster on separate clusters) (#105)
1 parent c563531 commit 24ce436

4 files changed

Lines changed: 95 additions & 4 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,34 @@ Similarly, the deployment(s) can be torn down using:
8787
./bin/roxie teardown [ <component> ]
8888
```
8989

90+
### Multi-cluster deployments
91+
92+
roxie supports hub + spoke architectures where Central and SecuredCluster run on separate clusters.
93+
94+
1. Deploy Central on the hub cluster:
95+
```bash
96+
./roxie deploy central -t 4.9.2
97+
```
98+
99+
2. Create a config file for the spoke cluster, pointing at the Central endpoint (printed during step 1):
100+
```yaml
101+
# spoke-config.yaml
102+
securedCluster:
103+
spec:
104+
centralEndpoint: "<central-loadbalancer-ip>:443"
105+
```
106+
107+
3. Switch kubectl context to the spoke cluster and deploy SecuredCluster:
108+
```bash
109+
ROX_ADMIN_PASSWORD=<admin-password> \
110+
ROX_CA_CERT_FILE=<path-to-ca-cert> \
111+
./roxie deploy secured-cluster -t 4.9.2 -c spoke-config.yaml
112+
```
113+
114+
> **Tip:** If deploying from the roxie subshell, `ROX_ADMIN_PASSWORD` and `ROX_CA_CERT_FILE` are
115+
> already set. For automation, consider using `--envrc <file>` on the Central deploy to write the
116+
> environment to a file instead of spawning a subshell.
117+
90118
## Development
91119

92120
Enter the dev shell:
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package deployer
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
"github.com/stretchr/testify/require"
8+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
9+
)
10+
11+
func TestConfigureSpec_CentralEndpoint(t *testing.T) {
12+
tests := []struct {
13+
name string
14+
spec map[string]interface{}
15+
centralNamespace string
16+
expected string
17+
}{
18+
{
19+
name: "sets internal endpoint when not provided",
20+
spec: map[string]interface{}{},
21+
centralNamespace: "acs-central",
22+
expected: "central.acs-central.svc:443",
23+
},
24+
{
25+
name: "sets internal endpoint with custom namespace",
26+
spec: map[string]interface{}{},
27+
centralNamespace: "stackrox",
28+
expected: "central.stackrox.svc:443",
29+
},
30+
{
31+
name: "preserves user-provided endpoint",
32+
spec: map[string]interface{}{"centralEndpoint": "central.example.com:443"},
33+
centralNamespace: "acs-central",
34+
expected: "central.example.com:443",
35+
},
36+
{
37+
name: "user-provided endpoint takes precedence over internal default",
38+
spec: map[string]interface{}{"centralEndpoint": "10.0.0.1:443"},
39+
centralNamespace: "stackrox",
40+
expected: "10.0.0.1:443",
41+
},
42+
}
43+
44+
for _, tt := range tests {
45+
t.Run(tt.name, func(t *testing.T) {
46+
sc := &SecuredClusterConfig{
47+
Spec: tt.spec,
48+
}
49+
roxie := NewRoxieConfig()
50+
central := &CentralConfig{Namespace: tt.centralNamespace}
51+
52+
err := sc.ConfigureSpec(&roxie, central)
53+
require.NoError(t, err, "ConfigureSpec failed")
54+
55+
got, found, err := unstructured.NestedString(sc.Spec, "centralEndpoint")
56+
require.NoError(t, err, "failed to get centralEndpoint from spec")
57+
require.True(t, found, "centralEndpoint not found in spec")
58+
assert.Equal(t, tt.expected, got)
59+
})
60+
}
61+
}

internal/deployer/config.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,8 @@ func (s *SecuredClusterConfig) ConfigureSpec(roxieConfig *RoxieConfig, centralCo
237237
return err
238238
}
239239

240-
if err := helpers.DeepMerge(s.Spec, map[string]interface{}{
241-
"centralEndpoint": internalCentralEndpoint(centralConfig.Namespace),
242-
}); err != nil {
243-
return err
240+
if _, exists := s.Spec["centralEndpoint"]; !exists {
241+
s.Spec["centralEndpoint"] = internalCentralEndpoint(centralConfig.Namespace)
244242
}
245243

246244
return nil

internal/deployer/deployer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,10 @@ func (d *Deployer) PrintSecuredClusterDeploymentSummary() {
965965
log.Info(cyan.Sprint("│") + createRow("OLM", "Yes"))
966966
}
967967

968+
if ep, ok := d.config.SecuredCluster.Spec["centralEndpoint"].(string); ok && ep != internalCentralEndpoint(d.config.Central.Namespace) {
969+
log.Info(cyan.Sprint("│") + createRow("Central Endpoint", ep))
970+
}
971+
968972
log.Info(cyan.Sprint("└" + strings.Repeat("─", boxWidth) + "┘"))
969973
log.Info("")
970974
}

0 commit comments

Comments
 (0)