-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Separate the certificate configuration to solve the problem of k…
…ubeclient initialization failure
- Loading branch information
yingjianjian
committed
Feb 26, 2022
1 parent
c3878c9
commit d3f9934
Showing
11 changed files
with
136 additions
and
75 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,66 @@ | ||
/* | ||
Copyright 2022 The OpenYurt 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 cert | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"k8s.io/klog/v2" | ||
|
||
"github.com/openyurtio/openyurt/cmd/yurthub/app/config" | ||
"github.com/openyurtio/openyurt/cmd/yurthub/app/options" | ||
"github.com/openyurtio/openyurt/pkg/yurthub/certificate" | ||
"github.com/openyurtio/openyurt/pkg/yurthub/certificate/hubself" | ||
"github.com/openyurtio/openyurt/pkg/yurthub/util" | ||
) | ||
|
||
func Complete(options *options.YurtHubOptions) (*config.CertificateConfiguration, error) { | ||
us, err := util.ParseRemoteServers(options.ServerAddr) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
hubCertOrgs := make([]string, 0) | ||
if options.YurtHubCertOrganizations != "" { | ||
for _, orgStr := range strings.Split(options.YurtHubCertOrganizations, ",") { | ||
hubCertOrgs = append(hubCertOrgs, orgStr) | ||
} | ||
} | ||
|
||
klog.Infof("register cert managers") | ||
cmr := certificate.NewCertificateManagerRegistry() | ||
hubself.Register(cmr) | ||
|
||
cfg := &config.CertificateConfiguration{ | ||
CertMgrMode: options.CertMgrMode, | ||
KubeletRootCAFilePath: options.KubeletRootCAFilePath, | ||
KubeletPairFilePath: options.KubeletPairFilePath, | ||
YurtHubCertOrganizations: hubCertOrgs, | ||
NodeName: options.NodeName, | ||
JoinToken: options.JoinToken, | ||
RootDir: options.RootDir, | ||
RemoteServers: us, | ||
} | ||
klog.Infof("create cert manager with %s mode", cfg.CertMgrMode) | ||
certManager, err := cmr.New(cfg.CertMgrMode, cfg) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not create certificate manager, %v", err) | ||
} | ||
cfg.CertManager = certManager | ||
return cfg, 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
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