-
Notifications
You must be signed in to change notification settings - Fork 451
/
addons.go
82 lines (71 loc) · 3.33 KB
/
addons.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package botanist
import (
"context"
"fmt"
"path/filepath"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"github.com/gardener/gardener/charts"
"github.com/gardener/gardener/pkg/chartrenderer"
"github.com/gardener/gardener/pkg/operation/common"
"github.com/gardener/gardener/pkg/utils/images"
"github.com/gardener/gardener/pkg/utils/managedresources"
)
// DeployManagedResourceForAddons deploys all the ManagedResource CRDs for the gardener-resource-manager.
func (b *Botanist) DeployManagedResourceForAddons(ctx context.Context) error {
// TODO(rfranzke): Delete this code in a future release.
if err := managedresources.DeleteForShoot(ctx, b.SeedClientSet.Client(), b.Shoot.SeedNamespace, "addons"); err != nil {
return err
}
renderedChart, err := b.generateCoreAddonsChart()
if err != nil {
return fmt.Errorf("error rendering shoot-core chart: %w", err)
}
return managedresources.CreateForShoot(ctx, b.SeedClientSet.Client(), b.Shoot.SeedNamespace, "shoot-core", managedresources.LabelValueGardener, false, renderedChart.AsSecretData())
}
// generateCoreAddonsChart renders the gardener-resource-manager configuration for the core addons. After that it
// creates a ManagedResource CRD that references the rendered manifests and creates it.
func (b *Botanist) generateCoreAddonsChart() (*chartrenderer.RenderedChart, error) {
var (
global = map[string]interface{}{
"vpaEnabled": b.Shoot.WantsVerticalPodAutoscaler,
"pspDisabled": b.Shoot.PSPDisabled,
}
podSecurityPolicies = map[string]interface{}{
"allowPrivilegedContainers": pointer.BoolDeref(b.Shoot.GetInfo().Spec.Kubernetes.AllowPrivilegedContainers, false),
}
nodeExporterConfig = map[string]interface{}{}
blackboxExporterConfig = map[string]interface{}{}
)
nodeExporter, err := b.InjectShootShootImages(nodeExporterConfig, images.ImageNameNodeExporter)
if err != nil {
return nil, err
}
blackboxExporter, err := b.InjectShootShootImages(blackboxExporterConfig, images.ImageNameBlackboxExporter)
if err != nil {
return nil, err
}
values := map[string]interface{}{
"global": global,
"apiserver-proxy": common.GenerateAddonConfig(nil, b.APIServerSNIEnabled()),
"monitoring": common.GenerateAddonConfig(map[string]interface{}{
"node-exporter": nodeExporter,
"blackbox-exporter": blackboxExporter,
}, b.Operation.IsShootMonitoringEnabled()),
"podsecuritypolicies": common.GenerateAddonConfig(podSecurityPolicies, !b.Shoot.PSPDisabled),
}
return b.ShootClientSet.ChartRenderer().Render(filepath.Join(charts.Path, "shoot-core", "components"), "shoot-core", metav1.NamespaceSystem, values)
}