mirror of https://github.com/kubernetes/kops.git
Setting project ID as well in cloudconfig. Using loadbalancerID in cloudconfig. Retrieving instance IP from openstack in protokube.
This commit is contained in:
parent
fc740dbba3
commit
eb256593bc
|
@ -109,14 +109,22 @@ func (b *CloudConfigBuilder) Build(c *fi.ModelBuilderContext) error {
|
|||
if osc == nil {
|
||||
break
|
||||
}
|
||||
|
||||
//Support mapping of older keystone API
|
||||
tenantName := os.Getenv("OS_TENANT_NAME")
|
||||
if tenantName == "" {
|
||||
tenantName = os.Getenv("OS_PROJECT_NAME")
|
||||
}
|
||||
tenantID := os.Getenv("OS_TENANT_ID")
|
||||
if tenantID == "" {
|
||||
tenantID = os.Getenv("OS_PROJECT_ID")
|
||||
}
|
||||
lines = append(lines,
|
||||
fmt.Sprintf("auth-url=\"%s\"", os.Getenv("OS_AUTH_URL")),
|
||||
fmt.Sprintf("username=\"%s\"", os.Getenv("OS_USERNAME")),
|
||||
fmt.Sprintf("password=\"%s\"", os.Getenv("OS_PASSWORD")),
|
||||
fmt.Sprintf("region=\"%s\"", os.Getenv("OS_REGION_NAME")),
|
||||
fmt.Sprintf("tenant-id=\"%s\"", os.Getenv("OS_TENANT_ID")),
|
||||
fmt.Sprintf("tenant-name=\"%s\"", os.Getenv("OS_TENANT_NAME")),
|
||||
fmt.Sprintf("tenant-id=\"%s\"", tenantID),
|
||||
fmt.Sprintf("tenant-name=\"%s\"", tenantName),
|
||||
fmt.Sprintf("domain-name=\"%s\"", os.Getenv("OS_DOMAIN_NAME")),
|
||||
fmt.Sprintf("domain-id=\"%s\"", os.Getenv("OS_DOMAIN_ID")),
|
||||
"",
|
||||
|
@ -125,13 +133,20 @@ func (b *CloudConfigBuilder) Build(c *fi.ModelBuilderContext) error {
|
|||
if lb := osc.Loadbalancer; lb != nil {
|
||||
lines = append(lines,
|
||||
"[LoadBalancer]",
|
||||
fmt.Sprintf("floating-network-id=%s", fi.StringValue(lb.FloatingNetwork)),
|
||||
fmt.Sprintf("floating-network-id=%s", fi.StringValue(lb.FloatingNetworkID)),
|
||||
fmt.Sprintf("lb-method=%s", fi.StringValue(lb.Method)),
|
||||
fmt.Sprintf("lb-provider=%s", fi.StringValue(lb.Provider)),
|
||||
fmt.Sprintf("use-octavia=%t", fi.BoolValue(lb.UseOctavia)),
|
||||
"",
|
||||
)
|
||||
}
|
||||
//Block Storage Config
|
||||
lines = append(lines,
|
||||
"[BlockStorage]",
|
||||
"bs-version=v2", //v2 assumed in OpenstackCloud
|
||||
"ignore-volume-az=true",
|
||||
"")
|
||||
|
||||
if monitor := osc.Monitor; monitor != nil {
|
||||
lines = append(lines,
|
||||
"create-monitor=yes",
|
||||
|
|
|
@ -499,6 +499,7 @@ type OpenstackLoadbalancerConfig struct {
|
|||
Provider *string `json:"provider,omitempty"`
|
||||
UseOctavia *bool `json:"useOctavia,omitempty"`
|
||||
FloatingNetwork *string `json:"floatingNetwork,omitempty"`
|
||||
FloatingNetworkID *string `json:"floatingNetworkID,omitempty"`
|
||||
SubnetID *string `json:"subnetID,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -499,6 +499,7 @@ type OpenstackLoadbalancerConfig struct {
|
|||
Provider *string `json:"provider,omitempty"`
|
||||
UseOctavia *bool `json:"useOctavia,omitempty"`
|
||||
FloatingNetwork *string `json:"floatingNetwork,omitempty"`
|
||||
FloatingNetworkID *string `json:"floatingNetworkID,omitempty"`
|
||||
SubnetID *string `json:"subnetID,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -3859,6 +3859,7 @@ func autoConvert_v1alpha1_OpenstackLoadbalancerConfig_To_kops_OpenstackLoadbalan
|
|||
out.Provider = in.Provider
|
||||
out.UseOctavia = in.UseOctavia
|
||||
out.FloatingNetwork = in.FloatingNetwork
|
||||
out.FloatingNetworkID = in.FloatingNetworkID
|
||||
out.SubnetID = in.SubnetID
|
||||
return nil
|
||||
}
|
||||
|
@ -3873,6 +3874,7 @@ func autoConvert_kops_OpenstackLoadbalancerConfig_To_v1alpha1_OpenstackLoadbalan
|
|||
out.Provider = in.Provider
|
||||
out.UseOctavia = in.UseOctavia
|
||||
out.FloatingNetwork = in.FloatingNetwork
|
||||
out.FloatingNetworkID = in.FloatingNetworkID
|
||||
out.SubnetID = in.SubnetID
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -2494,6 +2494,11 @@ func (in *OpenstackLoadbalancerConfig) DeepCopyInto(out *OpenstackLoadbalancerCo
|
|||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.FloatingNetworkID != nil {
|
||||
in, out := &in.FloatingNetworkID, &out.FloatingNetworkID
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.SubnetID != nil {
|
||||
in, out := &in.SubnetID, &out.SubnetID
|
||||
*out = new(string)
|
||||
|
|
|
@ -499,6 +499,7 @@ type OpenstackLoadbalancerConfig struct {
|
|||
Provider *string `json:"provider,omitempty"`
|
||||
UseOctavia *bool `json:"useOctavia,omitempty"`
|
||||
FloatingNetwork *string `json:"floatingNetwork,omitempty"`
|
||||
FloatingNetworkID *string `json:"floatingNetworkID,omitempty"`
|
||||
SubnetID *string `json:"subnetID,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -4129,6 +4129,7 @@ func autoConvert_v1alpha2_OpenstackLoadbalancerConfig_To_kops_OpenstackLoadbalan
|
|||
out.Provider = in.Provider
|
||||
out.UseOctavia = in.UseOctavia
|
||||
out.FloatingNetwork = in.FloatingNetwork
|
||||
out.FloatingNetworkID = in.FloatingNetworkID
|
||||
out.SubnetID = in.SubnetID
|
||||
return nil
|
||||
}
|
||||
|
@ -4143,6 +4144,7 @@ func autoConvert_kops_OpenstackLoadbalancerConfig_To_v1alpha2_OpenstackLoadbalan
|
|||
out.Provider = in.Provider
|
||||
out.UseOctavia = in.UseOctavia
|
||||
out.FloatingNetwork = in.FloatingNetwork
|
||||
out.FloatingNetworkID = in.FloatingNetworkID
|
||||
out.SubnetID = in.SubnetID
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -2581,6 +2581,11 @@ func (in *OpenstackLoadbalancerConfig) DeepCopyInto(out *OpenstackLoadbalancerCo
|
|||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.FloatingNetworkID != nil {
|
||||
in, out := &in.FloatingNetworkID, &out.FloatingNetworkID
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.SubnetID != nil {
|
||||
in, out := &in.SubnetID, &out.SubnetID
|
||||
*out = new(string)
|
||||
|
|
|
@ -2795,6 +2795,11 @@ func (in *OpenstackLoadbalancerConfig) DeepCopyInto(out *OpenstackLoadbalancerCo
|
|||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.FloatingNetworkID != nil {
|
||||
in, out := &in.FloatingNetworkID, &out.FloatingNetworkID
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
if in.SubnetID != nil {
|
||||
in, out := &in.SubnetID, &out.SubnetID
|
||||
*out = new(string)
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/golang/glog"
|
||||
cinderv2 "github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes"
|
||||
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach"
|
||||
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
|
||||
"k8s.io/kops/protokube/pkg/etcd"
|
||||
"k8s.io/kops/protokube/pkg/gossip"
|
||||
gossipos "k8s.io/kops/protokube/pkg/gossip/openstack"
|
||||
|
@ -172,14 +173,21 @@ func (a *OpenstackVolumes) discoverTags() error {
|
|||
|
||||
// Internal IP
|
||||
{
|
||||
ips, err := net.LookupIP(a.meta.Hostname)
|
||||
servers, err := a.cloud.ListInstances(servers.ListOpts{
|
||||
Host: a.instanceName,
|
||||
TenantID: a.meta.ProjectID,
|
||||
})
|
||||
if err != nil || len(servers) < 1 {
|
||||
return fmt.Errorf("error listing servers for hostname %s: %v", a.meta.Hostname, err)
|
||||
}
|
||||
if len(servers) > 1 {
|
||||
return fmt.Errorf("recieved more than one server for hostname %s", a.meta.Hostname)
|
||||
}
|
||||
ip, err := openstack.GetServerFixedIP(&servers[0], a.clusterName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error querying InternalIP from hostname: %v", err)
|
||||
}
|
||||
if len(ips) == 0 {
|
||||
return fmt.Errorf("ip lookups from metadata hostname was empty")
|
||||
}
|
||||
a.internalIP = ips[0]
|
||||
a.internalIP = net.ParseIP(ip)
|
||||
glog.Infof("Found internalIP=%q", a.internalIP)
|
||||
}
|
||||
|
||||
|
|
|
@ -321,6 +321,17 @@ func NewOpenstackCloud(tags map[string]string, spec *kops.ClusterSpec) (Openstac
|
|||
|
||||
c.extNetworkName = spec.CloudConfig.Openstack.Router.ExternalNetwork
|
||||
}
|
||||
if spec.CloudConfig.Openstack.Loadbalancer.FloatingNetworkID == nil &&
|
||||
spec.CloudConfig.Openstack.Loadbalancer.FloatingNetwork != nil {
|
||||
// This field is derived
|
||||
lbNet, err := c.ListNetworks(networks.ListOpts{
|
||||
Name: fi.StringValue(spec.CloudConfig.Openstack.Loadbalancer.FloatingNetwork),
|
||||
})
|
||||
if err != nil || len(lbNet) != 1 {
|
||||
return c, fmt.Errorf("could not establish floating network id.")
|
||||
}
|
||||
spec.CloudConfig.Openstack.Loadbalancer.FloatingNetworkID = fi.String(lbNet[0].ID)
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue