forked from gardener/gardener
/
addons.go
132 lines (112 loc) · 4.31 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Copyright 2018 The Gardener Authors.
//
// 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 (
"github.com/gardener/gardener/pkg/operation/common"
"github.com/gardener/gardener/pkg/utils"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// DeployNginxIngressResources creates the respective wildcard DNS record for the nginx-ingress-controller.
func (b *Botanist) DeployNginxIngressResources() error {
if !b.Shoot.NginxIngressEnabled() {
return b.DestroyNginxIngressResources()
}
loadBalancerIngress, _, err := common.GetLoadBalancerIngress(b.K8sShootClient, metav1.NamespaceSystem, "addons-nginx-ingress-controller")
if err != nil {
return err
}
return b.DeployDNSRecord("ingress", b.Shoot.GetIngressFQDN("*"), loadBalancerIngress, false)
}
// DestroyNginxIngressResources destroys the nginx-ingress resources created by Terraform.
func (b *Botanist) DestroyNginxIngressResources() error {
return b.DestroyDNSRecord("ingress", false)
}
// GenerateNginxIngressConfig generates the values which are required to render the chart of
// the nginx-ingress-controller properly.
func (b *Botanist) GenerateNginxIngressConfig() (map[string]interface{}, error) {
return common.GenerateAddonConfig(nil, b.Shoot.NginxIngressEnabled()), nil
}
// GenerateKubernetesDashboardConfig generates the values which are required to render the chart of
// the kubernetes-dashboard properly.
func (b *Botanist) GenerateKubernetesDashboardConfig() (map[string]interface{}, error) {
return common.GenerateAddonConfig(nil, b.Shoot.KubernetesDashboardEnabled()), nil
}
// GenerateKubeLegoConfig generates the values which are required to render the chart of
// kube-lego properly.
func (b *Botanist) GenerateKubeLegoConfig() (map[string]interface{}, error) {
var (
enabled = b.Shoot.KubeLegoEnabled()
values map[string]interface{}
)
if enabled {
values = map[string]interface{}{
"config": map[string]interface{}{
"LEGO_EMAIL": b.Shoot.Info.Spec.Addons.KubeLego.Mail,
},
}
}
return common.GenerateAddonConfig(values, enabled), nil
}
// GenerateMonocularConfig generates the values which are required to render the chart of
// monocular properly.
func (b *Botanist) GenerateMonocularConfig() (map[string]interface{}, error) {
var (
enabled = b.Shoot.MonocularEnabled()
values map[string]interface{}
)
if enabled {
var (
name = "monocular-tls"
monocularHost = b.Shoot.GetIngressFQDN("monocular")
kubecfgSecret = b.Secrets["kubecfg"]
basicAuth = utils.CreateSHA1Secret(kubecfgSecret.Data["username"], kubecfgSecret.Data["password"])
)
if _, err := b.K8sShootClient.CreateSecret(metav1.NamespaceSystem, name, corev1.SecretTypeTLS, b.Secrets[name].Data, true); err != nil {
return nil, err
}
values = map[string]interface{}{
"ingress": map[string]interface{}{
"basicAuthSecret": basicAuth,
"hosts": []string{monocularHost},
},
}
}
return common.GenerateAddonConfig(values, enabled), nil
}
// GenerateHeapsterConfig generates the values which are required to render the chart of
// heapster properly.
func (b *Botanist) GenerateHeapsterConfig() (map[string]interface{}, error) {
var (
enabled = b.Shoot.HeapsterEnabled()
values map[string]interface{}
)
if enabled {
addonManagerLabels := map[string]interface{}{
"addonmanager.kubernetes.io/mode": "Reconcile",
}
values = map[string]interface{}{
"labels": addonManagerLabels,
"service": map[string]interface{}{
"labels": addonManagerLabels,
},
}
}
return common.GenerateAddonConfig(values, enabled), nil
}
// GenerateHelmTillerConfig generates the values which are required to render the chart of
// helm-tiller properly.
func (b *Botanist) GenerateHelmTillerConfig() (map[string]interface{}, error) {
return common.GenerateAddonConfig(nil, b.Shoot.MonocularEnabled()), nil
}