-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:support sync polaris config to k8s configmap
- Loading branch information
1 parent
b993db2
commit 86a867a
Showing
19 changed files
with
1,032 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Tencent is pleased to support the open source community by making Polaris available. | ||
// | ||
// Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
// | ||
// Licensed under the BSD 3-Clause License (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://opensource.org/licenses/BSD-3-Clause | ||
// | ||
// 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 app | ||
|
||
import ( | ||
"io/ioutil" | ||
|
||
"gopkg.in/yaml.v2" | ||
|
||
"github.com/polarismesh/polaris-controller/cmd/polaris-controller/app/options" | ||
"github.com/polarismesh/polaris-controller/common/log" | ||
) | ||
|
||
// ServiceSync controller 用到的配置 | ||
type ProxyMetadata struct { | ||
ServerAddress string `yaml:"serverAddress"` | ||
ClusterName string `yaml:"clusterName"` | ||
CAAddress string `yaml:"caAddress"` | ||
} | ||
|
||
// DefaultConfig controller 用到的配置 | ||
type DefaultConfig struct { | ||
ProxyMetadata ProxyMetadata `yaml:"serviceSync"` | ||
} | ||
|
||
// SidecarInject sidecar 注入相关 | ||
type SidecarInject struct { | ||
Mode string `yaml:"mode"` | ||
Ignores []IgnorePod `yaml:"ignorePods"` | ||
} | ||
|
||
type IgnorePod struct { | ||
Namespace string `yaml:"namespace"` | ||
PodName string `yaml:"podName"` | ||
} | ||
|
||
type Server struct { | ||
// 健康探测时间间隔 | ||
HealthCheckDuration string `yaml:"healthCheckDuration"` | ||
// 定时对账时间间隔 | ||
ResyncDuration string `yaml:"resyncDuration"` | ||
} | ||
|
||
type controllerConfig struct { | ||
Logger map[string]*log.Options `yaml:"logger"` | ||
ClusterName string `yaml:"clusterName"` | ||
Server Server `yaml:"server"` | ||
ServiceSync *options.ServiceSync `yaml:"serviceSync"` | ||
ConfigSync *options.ConfigSync `yaml:"configSync"` | ||
SidecarInject SidecarInject `yaml:"sidecarInject"` | ||
} | ||
|
||
func readConfFromFile() (*controllerConfig, error) { | ||
buf, err := ioutil.ReadFile(MeshFile) | ||
if err != nil { | ||
log.Errorf("read file error, %v", err) | ||
return nil, err | ||
} | ||
|
||
c := &controllerConfig{} | ||
err = yaml.Unmarshal(buf, c) | ||
if err != nil { | ||
log.Errorf("unmarshal config error, %v", err) | ||
return nil, err | ||
} | ||
|
||
return c, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.