Skip to content

Commit a1a2e9f

Browse files
mclasmeierMoritz Clasmeier
andauthored
Polish (containerized) roxie UX for OpenShift (#49)
Co-authored-by: Moritz Clasmeier <mclasmeier@redhat.com>
1 parent 45d254c commit a1a2e9f

10 files changed

Lines changed: 194 additions & 91 deletions

File tree

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,21 @@ test-e2e: build ## Run end-to-end tests (requires kubectl context and cluster ac
114114
fi
115115
$(GOTEST) -v -tags=e2e -timeout=120m -parallel=1 ./tests/e2e/...
116116

117+
.PHONY: test-integration
118+
test-integration: build ## Run integration tests (requires kubectl context and cluster access)
119+
@echo "🧪 Running integration tests..."
120+
@if [ -z "$(shell kubectl config current-context 2>/dev/null)" ]; then \
121+
echo "❌ No kubectl context found. Please configure kubectl first."; \
122+
exit 1; \
123+
fi
124+
@if ! command -v podman >/dev/null 2>&1; then \
125+
echo "❌ podman not found. Please install podman for integration tests."; \
126+
exit 1; \
127+
fi
128+
$(GOTEST) -v -tags=integration -run=_Integration$$ -timeout=120m -parallel=1 ./...
129+
117130
.PHONY: test-all
118-
test-all: test test-e2e ## Run all tests (unit + e2e)
131+
test-all: test test-integration test-e2e ## Run all tests (unit + integration + e2e)
119132

120133
# Benchmarks
121134
.PHONY: bench

README.md

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,39 @@ Support for Helm charts might be dropped in the future.
2626

2727
## Quick start
2828

29-
### Option 1: Deploying using Docker image (Recommended for non-developers)
29+
### Option 1: Deploying using image (Recommended for non-developers)
3030

3131
**Requirements:**
32-
* Working Docker setup
32+
* Podman (or Docker) is set up
3333
* kubeconfig configuration file
34-
* quay.io registry credentials in the environment variables REGISTRY_USERNAME and REGISTRY_PASSWORD.
3534

36-
Note that **Podman is currently not supported** for running
37-
containerized roxie due to incomplete mapping of user IDs on macOS. This prevents the passing-in of the gcloud
38-
configuration directory to be functional within the container, which is required for interacting with GKE clusters.
35+
And, depending on the cluster:
36+
* credentials for the `quay.io` registry in the environment variables `REGISTRY_USERNAME` and `REGISTRY_PASSWORD`.
3937

40-
Example for deploying Central and SecuredCluster to the current Kubernetes cluster context:
41-
```bash
42-
docker run --rm -it --privileged \
43-
-v ~/.config/gcloud:/.config/gcloud \
44-
-v $KUBECONFIG:/kubeconfig \
45-
-e REGISTRY_USERNAME=$REGISTRY_USERNAME \
46-
-e REGISTRY_PASSWORD=$REGISTRY_PASSWORD \
47-
ghcr.io/stackrox/roxie:latest deploy
48-
```
49-
50-
A new roxie image for the current platform can be built using:
38+
Infra OpenShift4 clusters come already equipped with image pull secrets for `quay.io`, so in this case
39+
passing of `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` to the container is not required:
5140

41+
Example for deploying Central and SecuredCluster to an Infra OpenShift 4 cluster:
5242
```bash
53-
make docker-build
43+
podman run --rm -it --privileged \
44+
-v $KUBECONFIG:/kubeconfig:U \
45+
-e MAIN_IMAGE_TAG=4.9.2 \
46+
quay.io/rhacs-eng/roxie:latest deploy --resources=auto
5447
```
48+
Specify the `MAIN_IMAGE_TAG` as desired.
5549

56-
This creates two tags:
57-
- `localhost/roxie:latest`
58-
- `localhost/roxie:<version-tag>`
59-
60-
Docker images can be built for the platforms `linux/amd64` and `linux/arm64`. See the `Makefile` for more
61-
docker related targets.
50+
Deploying to a GKE cluster requires passing of some more arguments:
51+
```
52+
podman run --rm -it --privileged \
53+
-v ~/.config/gcloud:/.config/gcloud:U \
54+
-v $KUBECONFIG:/kubeconfig:U \
55+
-e MAIN_IMAGE_TAG=4.9.2 \
56+
-e REGISTRY_USERNAME=$REGISTRY_USERNAME \
57+
-e REGISTRY_PASSWORD=$REGISTRY_PASSWORD \
58+
quay.io/rhacs-eng/roxie:latest deploy --resources=auto
59+
```
60+
Note that in this case we also need to pass the gcloud configuration for the authentication towards
61+
the cluster to succeed.
6262

6363
### Option 2: Deploying using local build
6464

@@ -80,9 +80,10 @@ Get help:
8080

8181
Deploy using:
8282
```bash
83-
./roxie deploy [ <component> ]
83+
MAIN_IMAGE_TAG=4.9.2 ./roxie deploy [ <component> ]
8484
```
8585
where `component` can be `central` or `sensor`. If not specified, both components will be deployed.
86+
Specify the `MAIN_IMAGE_TAG` as desired.
8687

8788
Similarly, the deployment(s) can be torn down using:
8889
```bash
@@ -104,6 +105,20 @@ make test # Unit tests
104105
make test-e2e # E2E tests (requires a real cluster context)
105106
```
106107

108+
A new roxie image for the current platform can be built using:
109+
110+
```bash
111+
make docker-build
112+
```
113+
114+
This creates two tags:
115+
- `localhost/roxie:latest`
116+
- `localhost/roxie:<version-tag>`
117+
118+
Docker images can be built for the platforms `linux/amd64` and `linux/arm64`. See the `Makefile` for more
119+
docker related targets.
120+
121+
107122
## Testing (E2E)
108123

109124
The E2E suite expects a valid `kubectl` context.

cmd/deploy.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ Examples:
5151

5252
func runDeploy(cmd *cobra.Command, args []string) error {
5353
log := logger.New()
54-
55-
if env.RunningInContainer {
56-
log.Dim("Running containerized.")
54+
if err := env.Initialize(log); err != nil {
55+
return err
5756
}
5857

5958
if env.RunningInteractively {
@@ -99,9 +98,9 @@ func runDeploy(cmd *cobra.Command, args []string) error {
9998
}
10099

101100
// On infra OpenShift we already get image pull secrets for Quay automatically.
102-
if env.GetCurrentClusterType() != env.InfraOpenShift4 {
101+
if clusterType := env.GetCurrentClusterType(); clusterType != env.InfraOpenShift4 {
103102
if os.Getenv("REGISTRY_USERNAME") == "" || os.Getenv("REGISTRY_PASSWORD") == "" {
104-
return errors.New("containerized mode requires REGISTRY_USERNAME and REGISTRY_PASSWORD environment variables")
103+
return fmt.Errorf("containerized mode requires REGISTRY_USERNAME and REGISTRY_PASSWORD environment variables for clusters of type %s", clusterType)
105104
}
106105
if _, err := os.Stat("/kubeconfig"); err != nil {
107106
return fmt.Errorf("containerized mode requires /kubeconfig file: %w", err)

cmd/env.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package main
22

33
import (
44
"fmt"
5+
"os"
56

67
"github.com/spf13/cobra"
78
"github.com/stackrox/roxie/internal/env"
9+
"github.com/stackrox/roxie/internal/logger"
810
)
911

1012
func newEnvCmd() *cobra.Command {
@@ -13,16 +15,24 @@ func newEnvCmd() *cobra.Command {
1315
Short: "Display environment information",
1416
Long: `Display detected environment information including cluster type and container status.`,
1517
Hidden: true, // Hidden command for debugging/inspection
16-
Run: runEnv,
18+
RunE: runEnv,
1719
}
1820

1921
return cmd
2022
}
2123

22-
func runEnv(cmd *cobra.Command, args []string) {
24+
func runEnv(cmd *cobra.Command, args []string) error {
25+
log := logger.New()
26+
if err := env.Initialize(log); err != nil {
27+
return err
28+
}
29+
2330
fmt.Println("Roxie Environment Information:")
2431
fmt.Println("==============================")
32+
fmt.Printf("Kube config: %s\n", os.Getenv("KUBECONFIG"))
2533
fmt.Printf("Running in Container: %v\n", env.RunningInContainer)
2634
fmt.Printf("Current Context: %s\n", env.GetCurrentContext())
2735
fmt.Printf("Cluster Type: %s\n", env.GetCurrentClusterType().String())
36+
37+
return nil
2838
}

cmd/teardown.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/spf13/cobra"
99
"github.com/stackrox/roxie/internal/deployer"
10+
"github.com/stackrox/roxie/internal/env"
1011
"github.com/stackrox/roxie/internal/logger"
1112
)
1213

@@ -28,13 +29,16 @@ func newTeardownCmd() *cobra.Command {
2829
}
2930

3031
func runTeardown(cmd *cobra.Command, args []string) error {
32+
log := logger.New()
33+
if err := env.Initialize(log); err != nil {
34+
return err
35+
}
36+
3137
component := "both"
3238
if len(args) > 0 {
3339
component = args[0]
3440
}
3541

36-
log := logger.New()
37-
3842
log.Infof("Tearing down %s", component)
3943

4044
d, err := deployer.New(log, "", []string{})

internal/deployer/deployer.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,11 @@ func (d *Deployer) Deploy(ctx context.Context, component, resources, exposure st
421421
d.exposure = exposure
422422

423423
// Prepare and verify credentials early to fail fast
424-
if err := d.prepareCredentials(); err != nil {
425-
return fmt.Errorf("failed to prepare credentials: %w", err)
424+
425+
if env.GetCurrentClusterType() != env.InfraOpenShift4 {
426+
if err := d.prepareCredentials(); err != nil {
427+
return fmt.Errorf("failed to prepare credentials: %w", err)
428+
}
426429
}
427430

428431
d.logger.Infof("Initiating deployment of %s", formatComponentName(component))

0 commit comments

Comments
 (0)