Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add externalIP for certificate-data #475

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/kubenest/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type initData struct {
kosmosClient versioned.Interface
virtualClusterDataDir string
privateRegistry string
externalIP string
hostPortManager *vcnodecontroller.HostPortManager
}

Expand Down Expand Up @@ -141,6 +142,7 @@ func newRunData(opt *InitOptions, hostPortManager *vcnodecontroller.HostPortMana
virtualClusterDataDir: opt.virtualClusterDataDir,
privateRegistry: utils.DefaultImageRepository,
CertStore: cert.NewCertStore(),
externalIP: opt.virtualCluster.Spec.ExternalIP,
hostPortManager: hostPortManager,
}, nil
}
Expand Down Expand Up @@ -200,3 +202,7 @@ func (i initData) DataDir() string {
func (i initData) VirtualClusterVersion() string {
return i.virtualClusterVersion.String()
}

func (i initData) ExternalIP() string {
return i.externalIP
}
1 change: 1 addition & 0 deletions pkg/kubenest/tasks/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func mutateCertConfig(data InitData, cc *cert.CertConfig) error {
Namespace: data.GetNamespace(),
ControlplaneAddr: data.ControlplaneAddress(),
ClusterIps: data.ServiceClusterIp(),
ExternalIP: data.ExternalIP(),
}, cc)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions pkg/kubenest/tasks/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ type InitData interface {
KosmosClient() versioned.Interface
DataDir() string
VirtualClusterVersion() string
ExternalIP() string
}
4 changes: 4 additions & 0 deletions pkg/kubenest/util/cert/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type AltNamesMutatorConfig struct {
Namespace string
ControlplaneAddr string
ClusterIps []string
ExternalIP string
}

func (config *CertConfig) defaultPublicKeyAlgorithm() {
Expand Down Expand Up @@ -212,6 +213,9 @@ func apiServerAltNamesMutator(cfg *AltNamesMutatorConfig) (*certutil.AltNames, e
if len(cfg.ControlplaneAddr) > 0 {
appendSANsToAltNames(altNames, []string{cfg.ControlplaneAddr})
}
if len(cfg.ExternalIP) > 0 {
appendSANsToAltNames(altNames, []string{cfg.ExternalIP})
}
if len(cfg.ClusterIps) > 0 {
for _, clusterIp := range cfg.ClusterIps {
appendSANsToAltNames(altNames, []string{clusterIp})
Expand Down
Loading