Skip to content

Make per-stack hostnames configurable #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
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
3 changes: 3 additions & 0 deletions cmd/stackset-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
ConfigMapSupportEnabled bool
SecretSupportEnabled bool
PCSSupportEnabled bool
PerStackHostnameEnabled bool
}
)

Expand All @@ -70,6 +71,7 @@ func main() {
kingpin.Flag("enable-configmap-support", "Enable support for ConfigMaps on StackSets.").Default("false").BoolVar(&config.ConfigMapSupportEnabled)
kingpin.Flag("enable-secret-support", "Enable support for Secrets on StackSets.").Default("false").BoolVar(&config.SecretSupportEnabled)
kingpin.Flag("enable-pcs-support", "Enable support for PlatformCredentialsSet on StackSets.").Default("false").BoolVar(&config.PCSSupportEnabled)
kingpin.Flag("enable-per-stack-hostname", "Enable support for per-stack hostnames.").Default("false").BoolVar(&config.PerStackHostnameEnabled)
Copy link
Contributor

@mikkeloscar mikkeloscar Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Let's make it true by default to be backwards compatible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I can keep this TODO open for now. I want to keep it false for now to be able to test. I'll set it to true before merging.

kingpin.Parse()

if config.Debug {
Expand All @@ -91,6 +93,7 @@ func main() {
ConfigMapSupportEnabled: config.ConfigMapSupportEnabled,
SecretSupportEnabled: config.SecretSupportEnabled,
PcsSupportEnabled: config.PCSSupportEnabled,
PerStackHostnameEnabled: config.PerStackHostnameEnabled,
}

ctx, cancel := context.WithCancel(context.Background())
Expand Down
4 changes: 2 additions & 2 deletions controller/stack_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ func (c *StackSetController) ReconcileStackService(ctx context.Context, stack *z
return nil
}

func (c *StackSetController) ReconcileStackIngress(ctx context.Context, stack *zv1.Stack, existing *networking.Ingress, generateUpdated func() (*networking.Ingress, error)) error {
ingress, err := generateUpdated()
func (c *StackSetController) ReconcileStackIngress(ctx context.Context, stack *zv1.Stack, existing *networking.Ingress, generateUpdated func(bool) (*networking.Ingress, error)) error {
ingress, err := generateUpdated(c.config.PerStackHostnameEnabled)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion controller/stack_resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ func TestReconcileStackIngress(t *testing.T) {
require.NoError(t, err)
}

err = env.controller.ReconcileStackIngress(context.Background(), &tc.stack, tc.existing, func() (*networking.Ingress, error) {
err = env.controller.ReconcileStackIngress(context.Background(), &tc.stack, tc.existing, func(bool) (*networking.Ingress, error) {
return tc.updated, nil
})
require.NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions controller/stackset.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type StackSetConfig struct {
ConfigMapSupportEnabled bool
SecretSupportEnabled bool
PcsSupportEnabled bool
PerStackHostnameEnabled bool
}

type stacksetEvent struct {
Expand Down
14 changes: 9 additions & 5 deletions pkg/core/stack_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,15 @@ func (sc *StackContainer) stackHostnames(
return result.List(), nil
}

func (sc *StackContainer) GenerateIngress() (*networking.Ingress, error) {
return sc.generateIngress(false)
func (sc *StackContainer) GenerateIngress(perStackHostnameEnabled bool) (*networking.Ingress, error) {
return sc.generateIngress(false, perStackHostnameEnabled)
}

func (sc *StackContainer) GenerateIngressSegment() (
func (sc *StackContainer) GenerateIngressSegment(perStackHostnameEnabled bool) (
*networking.Ingress,
error,
) {
res, err := sc.generateIngress(true)
res, err := sc.generateIngress(true, perStackHostnameEnabled)
if err != nil || res == nil {
return res, err
}
Expand Down Expand Up @@ -379,11 +379,15 @@ func (sc *StackContainer) GenerateIngressSegment() (
return res, nil
}

func (sc *StackContainer) generateIngress(segment bool) (
func (sc *StackContainer) generateIngress(segment bool, perStackHostnameEnabled bool) (
*networking.Ingress,
error,
) {

// If Per-stack Hostnames and segments are disabled, no need to generate per stack ingresses
if !perStackHostnameEnabled && !segment {
return nil, nil
}
if !sc.HasBackendPort() || sc.ingressSpec == nil {
return nil, nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/core/stack_resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func TestStackGenerateIngress(t *testing.T) {
backendPort: &intStrBackendPort,
clusterDomains: []string{"example.org"},
}
ingress, err := c.GenerateIngress()
ingress, err := c.GenerateIngress(true)

if tc.expectError {
require.Error(t, err)
Expand Down Expand Up @@ -461,7 +461,7 @@ func TestStackGenerateIngressSegment(t *testing.T) {
segmentUpperLimit: tc.upperLimit,
backendPort: &backendPort,
}
ingress, err := c.GenerateIngressSegment()
ingress, err := c.GenerateIngressSegment(true)

if (err != nil) != tc.expectError {
t.Errorf("expected error: %t , got %v", tc.expectError, err)
Expand Down Expand Up @@ -570,7 +570,7 @@ func TestGenerateIngressSegmentWithSyncAnnotations(t *testing.T) {
ingressAnnotationsToSync: tc.ingresssAnnotationsToSync,
syncAnnotationsInIngress: tc.syncAnnotationsInIngress,
}
res, _ := c.GenerateIngressSegment()
res, _ := c.GenerateIngressSegment(true)
Copy link
Member

@linki linki Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we duplicate this block of tests for GenerateIngressSegment(false) or would the result just be empty?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the result would just be empty, because ingresses wouldn't be generated.


delete(
res.Annotations,
Expand Down