Skip to content

Include workload pool specs in chart values #250

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
27 changes: 26 additions & 1 deletion pkg/provisioners/helmapplications/virtualcluster/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package virtualcluster
import (
"context"
"crypto/sha256"
"errors"
"fmt"

"github.com/prometheus/client_golang/prometheus"
Expand All @@ -43,6 +44,10 @@ var (
})
)

var (
errNoVKCInContext = errors.New("no VirtualKubernetesCluster in context")
)

//nolint:gochecknoinits
func init() {
metrics.Registry.MustRegister(durationMetric)
Expand Down Expand Up @@ -84,7 +89,13 @@ func (p *Provisioner) Values(ctx context.Context, version unikornv1core.Semantic
// and the cost is "what you use", we'll need to worry about billing, so it may
// be prudent to add organization, project and cluster labels to pods.
// We use SNI to demutiplex at the ingress to the correct vcluster instance.
hostname := p.ReleaseName(ctx) + "." + p.domain
vkc, ok := application.FromContext(ctx).(*unikornv1.VirtualKubernetesCluster)
if !ok {
return nil, errNoVKCInContext
}

releaseName := p.ReleaseName(ctx)
hostname := releaseName + "." + p.domain

// Allow users to actually hit the cluster.
ingress := map[string]any{
Expand Down Expand Up @@ -185,7 +196,21 @@ func (p *Provisioner) Values(ctx context.Context, version unikornv1core.Semantic
"policies": policies,
"sync": sync,
"exportKubeConfig": kubeConfig,
"workloadPools": workloadPoolsAsValues(vkc),
}

return values, nil
}

func workloadPoolsAsValues(vkc *unikornv1.VirtualKubernetesCluster) []any {
pools := make([]any, len(vkc.Spec.WorkloadPools))
for i, pool := range vkc.Spec.WorkloadPools {
pools[i] = map[string]any{
"name": pool.Name,
"replicas": pool.Replicas,
"flavorId": pool.FlavorID,
}
}

return pools
}