mirror of
https://github.com/rancher/rke.git
synced 2025-09-16 06:59:25 +00:00
Add AWS cloudprovider config
This commit is contained in:
committed by
Alena Prokharchyk
parent
1938b88023
commit
23aebac488
@@ -1,28 +1,53 @@
|
|||||||
package aws
|
package aws
|
||||||
|
|
||||||
import "github.com/rancher/types/apis/management.cattle.io/v3"
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
type CloudProvider struct {
|
"github.com/go-ini/ini"
|
||||||
Name string
|
|
||||||
}
|
"github.com/rancher/types/apis/management.cattle.io/v3"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AWSCloudProviderName = "aws"
|
AWSCloudProviderName = "aws"
|
||||||
|
AWSConfig = "AWSConfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CloudProvider struct {
|
||||||
|
Config *v3.AWSCloudProvider
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
func GetInstance() *CloudProvider {
|
func GetInstance() *CloudProvider {
|
||||||
return &CloudProvider{}
|
return &CloudProvider{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *CloudProvider) Init(cloudProviderConfig v3.CloudProvider) error {
|
func (p *CloudProvider) Init(cloudProviderConfig v3.CloudProvider) error {
|
||||||
p.Name = AWSCloudProviderName
|
p.Name = AWSCloudProviderName
|
||||||
|
if cloudProviderConfig.AWSCloudProvider == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
p.Config = cloudProviderConfig.AWSCloudProvider
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *CloudProvider) GetName() string {
|
func (p *CloudProvider) GetName() string {
|
||||||
return p.Name
|
return p.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *CloudProvider) GenerateCloudConfigFile() (string, error) {
|
func (p *CloudProvider) GenerateCloudConfigFile() (string, error) {
|
||||||
return "", nil
|
if p.Config == nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
// Generate INI style configuration
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
cloudConfig := ini.Empty()
|
||||||
|
if err := ini.ReflectFrom(cloudConfig, p.Config); err != nil {
|
||||||
|
return "", fmt.Errorf("Failed to parse Openstack cloud config")
|
||||||
|
}
|
||||||
|
if _, err := cloudConfig.WriteTo(buf); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return buf.String(), nil
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ type CloudProvider interface {
|
|||||||
|
|
||||||
func InitCloudProvider(cloudProviderConfig v3.CloudProvider) (CloudProvider, error) {
|
func InitCloudProvider(cloudProviderConfig v3.CloudProvider) (CloudProvider, error) {
|
||||||
var p CloudProvider
|
var p CloudProvider
|
||||||
if cloudProviderConfig.Name == aws.AWSCloudProviderName {
|
if cloudProviderConfig.AWSCloudProvider != nil || cloudProviderConfig.Name == aws.AWSCloudProviderName {
|
||||||
p = aws.GetInstance()
|
p = aws.GetInstance()
|
||||||
}
|
}
|
||||||
if cloudProviderConfig.AzureCloudProvider != nil || cloudProviderConfig.Name == azure.AzureCloudProviderName {
|
if cloudProviderConfig.AzureCloudProvider != nil || cloudProviderConfig.Name == azure.AzureCloudProviderName {
|
||||||
|
@@ -13,7 +13,6 @@ import (
|
|||||||
|
|
||||||
ref "github.com/docker/distribution/reference"
|
ref "github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/rancher/rke/cloudprovider/aws"
|
|
||||||
"github.com/rancher/rke/docker"
|
"github.com/rancher/rke/docker"
|
||||||
"github.com/rancher/rke/hosts"
|
"github.com/rancher/rke/hosts"
|
||||||
"github.com/rancher/rke/k8s"
|
"github.com/rancher/rke/k8s"
|
||||||
@@ -161,7 +160,7 @@ func (c *Cluster) BuildKubeAPIProcess(host *hosts.Host, prefixPath string) v3.Pr
|
|||||||
"tls-cert-file": pki.GetCertPath(pki.KubeAPICertName),
|
"tls-cert-file": pki.GetCertPath(pki.KubeAPICertName),
|
||||||
"tls-private-key-file": pki.GetKeyPath(pki.KubeAPICertName),
|
"tls-private-key-file": pki.GetKeyPath(pki.KubeAPICertName),
|
||||||
}
|
}
|
||||||
if len(c.CloudProvider.Name) > 0 && c.CloudProvider.Name != aws.AWSCloudProviderName {
|
if len(c.CloudProvider.Name) > 0 {
|
||||||
CommandArgs["cloud-config"] = cloudConfigFileName
|
CommandArgs["cloud-config"] = cloudConfigFileName
|
||||||
}
|
}
|
||||||
if c.Authentication.Webhook != nil {
|
if c.Authentication.Webhook != nil {
|
||||||
@@ -306,7 +305,7 @@ func (c *Cluster) BuildKubeControllerProcess(prefixPath string) v3.Process {
|
|||||||
if c.DinD {
|
if c.DinD {
|
||||||
CommandArgs["address"] = "0.0.0.0"
|
CommandArgs["address"] = "0.0.0.0"
|
||||||
}
|
}
|
||||||
if len(c.CloudProvider.Name) > 0 && c.CloudProvider.Name != aws.AWSCloudProviderName {
|
if len(c.CloudProvider.Name) > 0 {
|
||||||
CommandArgs["cloud-config"] = cloudConfigFileName
|
CommandArgs["cloud-config"] = cloudConfigFileName
|
||||||
}
|
}
|
||||||
if len(c.CloudProvider.Name) > 0 {
|
if len(c.CloudProvider.Name) > 0 {
|
||||||
@@ -414,7 +413,7 @@ func (c *Cluster) BuildKubeletProcess(host *hosts.Host, prefixPath string) v3.Pr
|
|||||||
if host.Address != host.InternalAddress {
|
if host.Address != host.InternalAddress {
|
||||||
CommandArgs["node-ip"] = host.InternalAddress
|
CommandArgs["node-ip"] = host.InternalAddress
|
||||||
}
|
}
|
||||||
if len(c.CloudProvider.Name) > 0 && c.CloudProvider.Name != aws.AWSCloudProviderName {
|
if len(c.CloudProvider.Name) > 0 {
|
||||||
CommandArgs["cloud-config"] = cloudConfigFileName
|
CommandArgs["cloud-config"] = cloudConfigFileName
|
||||||
}
|
}
|
||||||
if len(c.CloudProvider.Name) > 0 {
|
if len(c.CloudProvider.Name) > 0 {
|
||||||
|
Reference in New Issue
Block a user