/
config.go
110 lines (101 loc) · 3.93 KB
/
config.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
// Copyright 2017 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package provider
import (
"github.com/juju/schema"
"gopkg.in/juju/environschema.v1"
core "k8s.io/api/core/v1"
)
const (
defaultServiceType = core.ServiceTypeClusterIP
defaultIngressClass = "nginx"
defaultIngressSSLRedirect = false
defaultIngressSSLPassthrough = false
defaultIngressAllowHTTPKey = false
ServiceTypeConfigKey = "kubernetes-service-type"
serviceExternalIPsConfigKey = "kubernetes-service-external-ips"
serviceTargetPortConfigKey = "kubernetes-service-target-port"
serviceLoadBalancerIPKey = "kubernetes-service-loadbalancer-ip"
serviceLoadBalancerSourceRangesKey = "kubernetes-service-loadbalancer-sourceranges"
serviceExternalNameKey = "kubernetes-service-externalname"
serviceAnnotationsKey = "kubernetes-service-annotations"
ingressClassKey = "kubernetes-ingress-class"
ingressSSLRedirectKey = "kubernetes-ingress-ssl-redirect"
ingressSSLPassthroughKey = "kubernetes-ingress-ssl-passthrough"
ingressAllowHTTPKey = "kubernetes-ingress-allow-http"
)
var configFields = environschema.Fields{
ServiceTypeConfigKey: {
Description: "determines how the Service is exposed",
Type: environschema.Tstring,
Group: environschema.ProviderGroup,
},
serviceAnnotationsKey: {
Description: "a space separated set of annotations to add to the service",
Type: environschema.Tattrs,
Group: environschema.ProviderGroup,
},
serviceExternalIPsConfigKey: {
Description: "list of IP addresses for which nodes in the cluster will also accept traffic",
Type: environschema.Tstring,
Group: environschema.ProviderGroup,
},
serviceTargetPortConfigKey: {
Description: "name or number of the port to access on the pods targeted by the service",
Type: environschema.Tstring,
Group: environschema.ProviderGroup,
},
serviceLoadBalancerIPKey: {
Description: "LoadBalancer will get created with the IP specified in this field",
Type: environschema.Tstring,
Group: environschema.ProviderGroup,
},
serviceLoadBalancerSourceRangesKey: {
Description: "traffic through the load-balancer will be restricted to the specified client IPs",
Type: environschema.Tstring,
Group: environschema.ProviderGroup,
},
serviceExternalNameKey: {
Description: "external reference that kubedns or equivalent will return as a CNAME record",
Type: environschema.Tstring,
Group: environschema.ProviderGroup,
},
ingressClassKey: {
Description: "the class of the ingress controller to be used by the ingress resource",
Type: environschema.Tstring,
Group: environschema.ProviderGroup,
},
ingressSSLRedirectKey: {
Description: "whether to redirect SSL traffic to the ingress controller",
Type: environschema.Tbool,
Group: environschema.ProviderGroup,
},
ingressSSLPassthroughKey: {
Description: "whether to passthrough SSL traffic to the ingress controller",
Type: environschema.Tbool,
Group: environschema.ProviderGroup,
},
ingressAllowHTTPKey: {
Description: "whether to allow HTTP traffic to the ingress controller",
Type: environschema.Tbool,
Group: environschema.ProviderGroup,
},
}
var schemaDefaults = schema.Defaults{
ServiceTypeConfigKey: schema.Omit,
serviceAnnotationsKey: schema.Omit,
ingressClassKey: defaultIngressClass,
ingressSSLRedirectKey: defaultIngressSSLRedirect,
ingressSSLPassthroughKey: defaultIngressSSLPassthrough,
ingressAllowHTTPKey: defaultIngressAllowHTTPKey,
}
// ConfigSchema returns the configuration schema for
// a kubernetes provider config.
func ConfigSchema() environschema.Fields {
return configFields
}
// ConfigDefaults returns the default values for
// a kubernetes configuration.
func ConfigDefaults() schema.Defaults {
return schemaDefaults
}