mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-12 00:40:25 -04:00
Move CSI charts to separate chart and cleanup loader code
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
cb22a25144
commit
ea5c83587c
124 changed files with 547 additions and 2290 deletions
|
@ -51,8 +51,7 @@ var (
|
|||
certManagerInfo = chartInfo{releaseName: "cert-manager", chartName: "cert-manager", path: "charts/cert-manager"}
|
||||
constellationOperatorsInfo = chartInfo{releaseName: "constellation-operators", chartName: "constellation-operators", path: "charts/edgeless/operators"}
|
||||
constellationServicesInfo = chartInfo{releaseName: "constellation-services", chartName: "constellation-services", path: "charts/edgeless/constellation-services"}
|
||||
snapshotCRDsInfo = chartInfo{releaseName: "snapshot-crd", chartName: "crds", path: "charts/csi-snapshotter/crds"}
|
||||
snapshotControllerInfo = chartInfo{releaseName: "snapshot-controller", chartName: "snapshot-controller", path: "charts/csi-snapshotter/snapshot-controller"}
|
||||
csiInfo = chartInfo{releaseName: "constellation-csi", chartName: "constellation-csi", path: "charts/edgeless/csi"}
|
||||
)
|
||||
|
||||
// ChartLoader loads embedded helm charts.
|
||||
|
@ -131,16 +130,11 @@ func (i *ChartLoader) Load(config *config.Config, conformanceMode bool, helmWait
|
|||
releases := helm.Releases{Cilium: ciliumRelease, CertManager: certManagerRelease, Operators: operatorRelease, ConstellationServices: conServicesRelease}
|
||||
|
||||
if config.DeployCSIDriver() {
|
||||
snapshotCRDs, err := i.loadRelease(snapshotCRDsInfo)
|
||||
csi, err := i.loadRelease(csiInfo, helmWaitMode)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("loading snapshot CRDs: %w", err)
|
||||
}
|
||||
snapshotController, err := i.loadRelease(snapshotControllerInfo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("loading snapshot controller: %w", err)
|
||||
}
|
||||
releases.SnapshotCRDs = &snapshotCRDs
|
||||
releases.SnapshotController = &snapshotController
|
||||
releases.CSI = &csi
|
||||
}
|
||||
|
||||
rel, err := json.Marshal(releases)
|
||||
|
@ -157,25 +151,25 @@ func (i *ChartLoader) loadRelease(info chartInfo, helmWaitMode helm.WaitMode) (h
|
|||
return helm.Release{}, fmt.Errorf("loading %s chart: %w", info.releaseName, err)
|
||||
}
|
||||
|
||||
var values map[string]any
|
||||
values := map[string]any{}
|
||||
|
||||
switch info.releaseName {
|
||||
case ciliumInfo.releaseName:
|
||||
values, err = i.loadCiliumValues()
|
||||
values = ciliumVals[i.csp.String()]
|
||||
case certManagerInfo.releaseName:
|
||||
values = i.loadCertManagerValues()
|
||||
case constellationOperatorsInfo.releaseName:
|
||||
updateVersions(chart, compatibility.EnsurePrefixV(constants.VersionInfo()))
|
||||
|
||||
values, err = i.loadOperatorsValues()
|
||||
values = i.loadOperatorsValues()
|
||||
case constellationServicesInfo.releaseName:
|
||||
updateVersions(chart, compatibility.EnsurePrefixV(constants.VersionInfo()))
|
||||
|
||||
values, err = i.loadConstellationServicesValues()
|
||||
values = i.loadConstellationServicesValues()
|
||||
case csiInfo.releaseName:
|
||||
updateVersions(chart, compatibility.EnsurePrefixV(constants.VersionInfo()))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return helm.Release{}, fmt.Errorf("loading %s values: %w", info.releaseName, err)
|
||||
values["tags"] = map[string]any{
|
||||
i.csp.String(): true,
|
||||
}
|
||||
|
||||
chartRaw, err := i.marshalChart(chart)
|
||||
|
@ -186,28 +180,6 @@ func (i *ChartLoader) loadRelease(info chartInfo, helmWaitMode helm.WaitMode) (h
|
|||
return helm.Release{Chart: chartRaw, Values: values, ReleaseName: info.releaseName, WaitMode: helmWaitMode}, nil
|
||||
}
|
||||
|
||||
// loadCiliumValues is used to separate the marshalling step from the loading step.
|
||||
// This reduces the time unit tests take to execute.
|
||||
func (i *ChartLoader) loadCiliumValues() (map[string]any, error) {
|
||||
var values map[string]any
|
||||
switch i.csp {
|
||||
case cloudprovider.AWS:
|
||||
values = awsVals
|
||||
case cloudprovider.Azure:
|
||||
values = azureVals
|
||||
case cloudprovider.GCP:
|
||||
values = gcpVals
|
||||
case cloudprovider.OpenStack:
|
||||
values = openStackVals
|
||||
case cloudprovider.QEMU:
|
||||
values = qemuVals
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown csp: %s", i.csp)
|
||||
}
|
||||
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// extendCiliumValues extends the given values map by some values depending on user input.
|
||||
// This extra step of separating the application of user input is necessary since service upgrades should
|
||||
// reuse user input from the init step. However, we can't rely on reuse-values, because
|
||||
|
@ -232,77 +204,34 @@ func (i *ChartLoader) loadCertManagerValues() map[string]any {
|
|||
"prometheus": map[string]any{
|
||||
"enabled": false,
|
||||
},
|
||||
"tolerations": []map[string]any{
|
||||
{
|
||||
"key": "node-role.kubernetes.io/control-plane",
|
||||
"effect": "NoSchedule",
|
||||
"operator": "Exists",
|
||||
},
|
||||
{
|
||||
"key": "node-role.kubernetes.io/master",
|
||||
"effect": "NoSchedule",
|
||||
"operator": "Exists",
|
||||
},
|
||||
},
|
||||
"tolerations": controlPlaneTolerations(),
|
||||
"webhook": map[string]any{
|
||||
"tolerations": []map[string]any{
|
||||
{
|
||||
"key": "node-role.kubernetes.io/control-plane",
|
||||
"effect": "NoSchedule",
|
||||
"operator": "Exists",
|
||||
},
|
||||
{
|
||||
"key": "node-role.kubernetes.io/master",
|
||||
"effect": "NoSchedule",
|
||||
"operator": "Exists",
|
||||
},
|
||||
},
|
||||
"tolerations": controlPlaneTolerations(),
|
||||
},
|
||||
"cainjector": map[string]any{
|
||||
"tolerations": []map[string]any{
|
||||
{
|
||||
"key": "node-role.kubernetes.io/control-plane",
|
||||
"effect": "NoSchedule",
|
||||
"operator": "Exists",
|
||||
},
|
||||
{
|
||||
"key": "node-role.kubernetes.io/master",
|
||||
"effect": "NoSchedule",
|
||||
"operator": "Exists",
|
||||
},
|
||||
},
|
||||
"tolerations": controlPlaneTolerations(),
|
||||
},
|
||||
"startupapicheck": map[string]any{
|
||||
"timeout": "5m",
|
||||
"extraArgs": []string{
|
||||
"--verbose",
|
||||
},
|
||||
"tolerations": []map[string]any{
|
||||
{
|
||||
"key": "node-role.kubernetes.io/control-plane",
|
||||
"effect": "NoSchedule",
|
||||
"operator": "Exists",
|
||||
},
|
||||
{
|
||||
"key": "node-role.kubernetes.io/master",
|
||||
"effect": "NoSchedule",
|
||||
"operator": "Exists",
|
||||
},
|
||||
},
|
||||
"tolerations": controlPlaneTolerations(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// loadOperatorsHelper is used to separate the marshalling step from the loading step.
|
||||
// This reduces the time unit tests take to execute.
|
||||
func (i *ChartLoader) loadOperatorsValues() (map[string]any, error) {
|
||||
values := map[string]any{
|
||||
func (i *ChartLoader) loadOperatorsValues() map[string]any {
|
||||
return map[string]any{
|
||||
"constellation-operator": map[string]any{
|
||||
"controllerManager": map[string]any{
|
||||
"manager": map[string]any{
|
||||
"image": i.constellationOperatorImage,
|
||||
},
|
||||
},
|
||||
"csp": i.csp.String(),
|
||||
},
|
||||
"node-maintenance-operator": map[string]any{
|
||||
"controllerManager": map[string]any{
|
||||
|
@ -312,66 +241,12 @@ func (i *ChartLoader) loadOperatorsValues() (map[string]any, error) {
|
|||
},
|
||||
},
|
||||
}
|
||||
switch i.csp {
|
||||
case cloudprovider.AWS:
|
||||
conOpVals, ok := values["constellation-operator"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid constellation-operator values")
|
||||
}
|
||||
conOpVals["csp"] = "AWS"
|
||||
|
||||
values["tags"] = map[string]any{
|
||||
"AWS": true,
|
||||
}
|
||||
case cloudprovider.Azure:
|
||||
conOpVals, ok := values["constellation-operator"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid constellation-operator values")
|
||||
}
|
||||
conOpVals["csp"] = "Azure"
|
||||
|
||||
values["tags"] = map[string]any{
|
||||
"Azure": true,
|
||||
}
|
||||
case cloudprovider.GCP:
|
||||
conOpVals, ok := values["constellation-operator"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid constellation-operator values")
|
||||
}
|
||||
conOpVals["csp"] = "GCP"
|
||||
|
||||
values["tags"] = map[string]any{
|
||||
"GCP": true,
|
||||
}
|
||||
case cloudprovider.OpenStack:
|
||||
conOpVals, ok := values["constellation-operator"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid constellation-operator values")
|
||||
}
|
||||
conOpVals["csp"] = "OpenStack"
|
||||
|
||||
values["tags"] = map[string]any{
|
||||
"OpenStack": true,
|
||||
}
|
||||
case cloudprovider.QEMU:
|
||||
conOpVals, ok := values["constellation-operator"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid constellation-operator values")
|
||||
}
|
||||
conOpVals["csp"] = "QEMU"
|
||||
|
||||
values["tags"] = map[string]any{
|
||||
"QEMU": true,
|
||||
}
|
||||
}
|
||||
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// loadConstellationServicesHelper is used to separate the marshalling step from the loading step.
|
||||
// This reduces the time unit tests take to execute.
|
||||
func (i *ChartLoader) loadConstellationServicesValues() (map[string]any, error) {
|
||||
values := map[string]any{
|
||||
func (i *ChartLoader) loadConstellationServicesValues() map[string]any {
|
||||
return map[string]any{
|
||||
"global": map[string]any{
|
||||
"keyServicePort": constants.KeyServicePort,
|
||||
"keyServiceNamespace": "", // empty namespace means we use the release namespace
|
||||
|
@ -390,7 +265,11 @@ func (i *ChartLoader) loadConstellationServicesValues() (map[string]any, error)
|
|||
"image": i.joinServiceImage,
|
||||
},
|
||||
"ccm": map[string]any{
|
||||
"csp": i.csp.String(),
|
||||
"csp": i.csp.String(),
|
||||
"image": i.ccmImage,
|
||||
},
|
||||
"cnm": map[string]any{
|
||||
"image": i.cnmImage,
|
||||
},
|
||||
"autoscaler": map[string]any{
|
||||
"csp": i.csp.String(),
|
||||
|
@ -406,68 +285,6 @@ func (i *ChartLoader) loadConstellationServicesValues() (map[string]any, error)
|
|||
"image": i.konnectivityImage,
|
||||
},
|
||||
}
|
||||
|
||||
switch i.csp {
|
||||
case cloudprovider.AWS:
|
||||
ccmVals, ok := values["ccm"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid ccm values")
|
||||
}
|
||||
ccmVals["AWS"] = map[string]any{
|
||||
"image": i.ccmImage,
|
||||
}
|
||||
|
||||
values["tags"] = map[string]any{
|
||||
"AWS": true,
|
||||
}
|
||||
case cloudprovider.Azure:
|
||||
ccmVals, ok := values["ccm"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid ccm values")
|
||||
}
|
||||
ccmVals["Azure"] = map[string]any{
|
||||
"image": i.ccmImage,
|
||||
}
|
||||
|
||||
values["cnm"] = map[string]any{
|
||||
"image": i.cnmImage,
|
||||
}
|
||||
|
||||
values["tags"] = map[string]any{
|
||||
"Azure": true,
|
||||
}
|
||||
|
||||
case cloudprovider.GCP:
|
||||
ccmVals, ok := values["ccm"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid ccm values")
|
||||
}
|
||||
ccmVals["GCP"] = map[string]any{
|
||||
"image": i.ccmImage,
|
||||
}
|
||||
|
||||
values["tags"] = map[string]any{
|
||||
"GCP": true,
|
||||
}
|
||||
case cloudprovider.OpenStack:
|
||||
ccmVals, ok := values["ccm"].(map[string]any)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid ccm values")
|
||||
}
|
||||
ccmVals["OpenStack"] = map[string]any{
|
||||
"image": i.ccmImage,
|
||||
}
|
||||
|
||||
values["tags"] = map[string]any{
|
||||
"OpenStack": true,
|
||||
}
|
||||
case cloudprovider.QEMU:
|
||||
values["tags"] = map[string]any{
|
||||
"QEMU": true,
|
||||
}
|
||||
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// extendConstellationServicesValues extends the given values map by some values depending on user input.
|
||||
|
@ -504,22 +321,9 @@ func extendConstellationServicesValues(
|
|||
|
||||
csp := cfg.GetProvider()
|
||||
switch csp {
|
||||
case cloudprovider.AWS:
|
||||
in["aws"] = map[string]any{
|
||||
"deployCSIDriver": cfg.DeployCSIDriver(),
|
||||
}
|
||||
case cloudprovider.Azure:
|
||||
in["azure"] = map[string]any{
|
||||
"deployCSIDriver": cfg.DeployCSIDriver(),
|
||||
}
|
||||
case cloudprovider.GCP:
|
||||
in["gcp"] = map[string]any{
|
||||
"deployCSIDriver": cfg.DeployCSIDriver(),
|
||||
}
|
||||
case cloudprovider.OpenStack:
|
||||
in["openstack"] = map[string]any{
|
||||
"deployYawolLoadBalancer": cfg.DeployYawolLoadBalancer(),
|
||||
"deployCSIDriver": cfg.DeployCSIDriver(),
|
||||
}
|
||||
if cfg.DeployYawolLoadBalancer() {
|
||||
in["yawol-controller"] = map[string]any{
|
||||
|
@ -659,3 +463,18 @@ func loadChartsDir(efs embed.FS, dir string) (*chart.Chart, error) {
|
|||
|
||||
return loader.LoadFiles(files)
|
||||
}
|
||||
|
||||
func controlPlaneTolerations() []map[string]any {
|
||||
return []map[string]any{
|
||||
{
|
||||
"key": "node-role.kubernetes.io/control-plane",
|
||||
"effect": "NoSchedule",
|
||||
"operator": "Exists",
|
||||
},
|
||||
{
|
||||
"key": "node-role.kubernetes.io/master",
|
||||
"effect": "NoSchedule",
|
||||
"operator": "Exists",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue