/
args.go
156 lines (128 loc) · 5.43 KB
/
args.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Copyright 2018 Istio 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 server
import (
"bytes"
"fmt"
"time"
"istio.io/istio/galley/pkg/source/kube/builtin"
"istio.io/istio/pkg/ctrlz"
"istio.io/istio/pkg/mcp/creds"
)
const (
defaultConfigMapFolder = "/etc/config/"
defaultMeshConfigFolder = "/etc/mesh-config/"
defaultAccessListFile = defaultConfigMapFolder + "accesslist.yaml"
defaultMeshConfigFile = defaultMeshConfigFolder + "mesh"
defaultDomainSuffix = "cluster.local"
)
// Args contains the startup arguments to instantiate Galley.
type Args struct {
// The path to kube configuration file.
KubeConfig string
// resync period to be passed to the K8s machinery.
ResyncPeriod time.Duration
// Address to use for Galley's gRPC API.
APIAddress string
// Enables gRPC-level tracing
EnableGRPCTracing bool
// Maximum size of individual received gRPC messages
MaxReceivedMessageSize uint
// Maximum number of outstanding RPCs per connection
MaxConcurrentStreams uint
// Insecure gRPC service is used for the MCP server. CertificateFile and KeyFile is ignored.
Insecure bool
// The credential options to use for MCP.
CredentialOptions *creds.Options
// The introspection options to use
IntrospectionOptions *ctrlz.Options
// Enable galley server mode
EnableServer bool
// AccessListFile is the YAML file that specifies ids of the allowed mTLS peers.
AccessListFile string
// ConfigPath is the path for Galley specific config files
ConfigPath string
// ExcludedResourceKinds is a list of resource kinds for which no source events will be triggered.
ExcludedResourceKinds []string
// MeshConfigFile is the path for mesh config
MeshConfigFile string
// DNS Domain suffix to use while constructing Ingress based resources.
DomainSuffix string
// DisableResourceReadyCheck disables the CRD readiness check. This
// allows Galley to start when not all supported CRD are
// registered with the kube-apiserver.
DisableResourceReadyCheck bool
// SinkAddress should be set to the address of a MCP Resource
// Sink service that Galley will dial out to. Leaving empty disables
// sink.
SinkAddress string
// SinkAuthMode should be set to a name of an authentication plugin,
// see the istio.io/istio/galley/pkg/autplugins package.
SinkAuthMode string
// SinkMeta list of key=values to attach as gRPC stream metadata to
// outgoing Sink connections.
SinkMeta []string
}
// DefaultArgs allocates an Args struct initialized with Mixer's default configuration.
func DefaultArgs() *Args {
return &Args{
APIAddress: "tcp://0.0.0.0:9901",
MaxReceivedMessageSize: 1024 * 1024,
MaxConcurrentStreams: 1024,
IntrospectionOptions: ctrlz.DefaultOptions(),
Insecure: false,
AccessListFile: defaultAccessListFile,
MeshConfigFile: defaultMeshConfigFile,
EnableServer: true,
CredentialOptions: creds.DefaultOptions(),
ConfigPath: "",
DomainSuffix: defaultDomainSuffix,
DisableResourceReadyCheck: false,
ExcludedResourceKinds: defaultExcludedResourceKinds(),
SinkMeta: make([]string, 0),
}
}
func defaultExcludedResourceKinds() []string {
resources := make([]string, 0)
for _, spec := range builtin.GetSchema().All() {
resources = append(resources, spec.Kind)
}
return resources
}
// String produces a stringified version of the arguments for debugging.
func (a *Args) String() string {
buf := &bytes.Buffer{}
_, _ = fmt.Fprintf(buf, "KubeConfig: %s\n", a.KubeConfig)
_, _ = fmt.Fprintf(buf, "ResyncPeriod: %v\n", a.ResyncPeriod)
_, _ = fmt.Fprintf(buf, "APIAddress: %s\n", a.APIAddress)
_, _ = fmt.Fprintf(buf, "EnableGrpcTracing: %v\n", a.EnableGRPCTracing)
_, _ = fmt.Fprintf(buf, "MaxReceivedMessageSize: %d\n", a.MaxReceivedMessageSize)
_, _ = fmt.Fprintf(buf, "MaxConcurrentStreams: %d\n", a.MaxConcurrentStreams)
_, _ = fmt.Fprintf(buf, "IntrospectionOptions: %+v\n", *a.IntrospectionOptions)
_, _ = fmt.Fprintf(buf, "Insecure: %v\n", a.Insecure)
_, _ = fmt.Fprintf(buf, "AccessListFile: %s\n", a.AccessListFile)
_, _ = fmt.Fprintf(buf, "EnableServer: %v\n", a.EnableServer)
_, _ = fmt.Fprintf(buf, "KeyFile: %s\n", a.CredentialOptions.KeyFile)
_, _ = fmt.Fprintf(buf, "CertificateFile: %s\n", a.CredentialOptions.CertificateFile)
_, _ = fmt.Fprintf(buf, "CACertificateFile: %s\n", a.CredentialOptions.CACertificateFile)
_, _ = fmt.Fprintf(buf, "ConfigFilePath: %s\n", a.ConfigPath)
_, _ = fmt.Fprintf(buf, "MeshConfigFile: %s\n", a.MeshConfigFile)
_, _ = fmt.Fprintf(buf, "DomainSuffix: %s\n", a.DomainSuffix)
_, _ = fmt.Fprintf(buf, "DisableResourceReadyCheck: %v\n", a.DisableResourceReadyCheck)
_, _ = fmt.Fprintf(buf, "ExcludedResourceKinds: %v\n", a.ExcludedResourceKinds)
_, _ = fmt.Fprintf(buf, "SinkAddress: %v\n", a.SinkAddress)
_, _ = fmt.Fprintf(buf, "SinkAuthMode: %v\n", a.SinkAuthMode)
_, _ = fmt.Fprintf(buf, "SinkMeta: %v\n", a.SinkMeta)
return buf.String()
}