mirror of https://github.com/kubernetes/kops.git
Use same method receiver names everywhere
This commit is contained in:
parent
bd7176f45f
commit
c49b71feb5
|
@ -51,14 +51,14 @@ type KopsModelContext struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GatherSubnets maps the subnet names in an InstanceGroup to the ClusterSubnetSpec objects (which are stored on the Cluster)
|
// GatherSubnets maps the subnet names in an InstanceGroup to the ClusterSubnetSpec objects (which are stored on the Cluster)
|
||||||
func (m *KopsModelContext) GatherSubnets(ig *kops.InstanceGroup) ([]*kops.ClusterSubnetSpec, error) {
|
func (b *KopsModelContext) GatherSubnets(ig *kops.InstanceGroup) ([]*kops.ClusterSubnetSpec, error) {
|
||||||
var subnets []*kops.ClusterSubnetSpec
|
var subnets []*kops.ClusterSubnetSpec
|
||||||
var subnetType kops.SubnetType
|
var subnetType kops.SubnetType
|
||||||
|
|
||||||
for _, subnetName := range ig.Spec.Subnets {
|
for _, subnetName := range ig.Spec.Subnets {
|
||||||
var matches []*kops.ClusterSubnetSpec
|
var matches []*kops.ClusterSubnetSpec
|
||||||
for i := range m.Cluster.Spec.Subnets {
|
for i := range b.Cluster.Spec.Subnets {
|
||||||
clusterSubnet := &m.Cluster.Spec.Subnets[i]
|
clusterSubnet := &b.Cluster.Spec.Subnets[i]
|
||||||
if clusterSubnet.Name == subnetName {
|
if clusterSubnet.Name == subnetName {
|
||||||
matches = append(matches, clusterSubnet)
|
matches = append(matches, clusterSubnet)
|
||||||
}
|
}
|
||||||
|
@ -86,8 +86,8 @@ func (m *KopsModelContext) GatherSubnets(ig *kops.InstanceGroup) ([]*kops.Cluste
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindInstanceGroup returns the instance group with the matching Name (or nil if not found)
|
// FindInstanceGroup returns the instance group with the matching Name (or nil if not found)
|
||||||
func (m *KopsModelContext) FindInstanceGroup(name string) *kops.InstanceGroup {
|
func (b *KopsModelContext) FindInstanceGroup(name string) *kops.InstanceGroup {
|
||||||
for _, ig := range m.InstanceGroups {
|
for _, ig := range b.InstanceGroups {
|
||||||
if ig.ObjectMeta.Name == name {
|
if ig.ObjectMeta.Name == name {
|
||||||
return ig
|
return ig
|
||||||
}
|
}
|
||||||
|
@ -96,19 +96,19 @@ func (m *KopsModelContext) FindInstanceGroup(name string) *kops.InstanceGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindSubnet returns the subnet with the matching Name (or nil if not found)
|
// FindSubnet returns the subnet with the matching Name (or nil if not found)
|
||||||
func (m *KopsModelContext) FindSubnet(name string) *kops.ClusterSubnetSpec {
|
func (b *KopsModelContext) FindSubnet(name string) *kops.ClusterSubnetSpec {
|
||||||
return model.FindSubnet(m.Cluster, name)
|
return model.FindSubnet(b.Cluster, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindZonesForInstanceGroup finds the zones for an InstanceGroup
|
// FindZonesForInstanceGroup finds the zones for an InstanceGroup
|
||||||
func (m *KopsModelContext) FindZonesForInstanceGroup(ig *kops.InstanceGroup) ([]string, error) {
|
func (b *KopsModelContext) FindZonesForInstanceGroup(ig *kops.InstanceGroup) ([]string, error) {
|
||||||
return model.FindZonesForInstanceGroup(m.Cluster, ig)
|
return model.FindZonesForInstanceGroup(b.Cluster, ig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MasterInstanceGroups returns InstanceGroups with the master role
|
// MasterInstanceGroups returns InstanceGroups with the master role
|
||||||
func (m *KopsModelContext) MasterInstanceGroups() []*kops.InstanceGroup {
|
func (b *KopsModelContext) MasterInstanceGroups() []*kops.InstanceGroup {
|
||||||
var groups []*kops.InstanceGroup
|
var groups []*kops.InstanceGroup
|
||||||
for _, ig := range m.InstanceGroups {
|
for _, ig := range b.InstanceGroups {
|
||||||
if !ig.IsMaster() {
|
if !ig.IsMaster() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -118,9 +118,9 @@ func (m *KopsModelContext) MasterInstanceGroups() []*kops.InstanceGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeInstanceGroups returns InstanceGroups with the node role
|
// NodeInstanceGroups returns InstanceGroups with the node role
|
||||||
func (m *KopsModelContext) NodeInstanceGroups() []*kops.InstanceGroup {
|
func (b *KopsModelContext) NodeInstanceGroups() []*kops.InstanceGroup {
|
||||||
var groups []*kops.InstanceGroup
|
var groups []*kops.InstanceGroup
|
||||||
for _, ig := range m.InstanceGroups {
|
for _, ig := range b.InstanceGroups {
|
||||||
if ig.Spec.Role != kops.InstanceGroupRoleNode {
|
if ig.Spec.Role != kops.InstanceGroupRoleNode {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -130,11 +130,11 @@ func (m *KopsModelContext) NodeInstanceGroups() []*kops.InstanceGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CloudTagsForInstanceGroup computes the tags to apply to instances in the specified InstanceGroup
|
// CloudTagsForInstanceGroup computes the tags to apply to instances in the specified InstanceGroup
|
||||||
func (m *KopsModelContext) CloudTagsForInstanceGroup(ig *kops.InstanceGroup) (map[string]string, error) {
|
func (b *KopsModelContext) CloudTagsForInstanceGroup(ig *kops.InstanceGroup) (map[string]string, error) {
|
||||||
labels := m.CloudTags(m.AutoscalingGroupName(ig), false)
|
labels := b.CloudTags(b.AutoscalingGroupName(ig), false)
|
||||||
|
|
||||||
// Apply any user-specified global labels first so they can be overridden by IG-specific labels
|
// Apply any user-specified global labels first so they can be overridden by IG-specific labels
|
||||||
for k, v := range m.Cluster.Spec.CloudLabels {
|
for k, v := range b.Cluster.Spec.CloudLabels {
|
||||||
labels[k] = v
|
labels[k] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,13 +144,13 @@ func (m *KopsModelContext) CloudTagsForInstanceGroup(ig *kops.InstanceGroup) (ma
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply NTH Labels
|
// Apply NTH Labels
|
||||||
nth := m.Cluster.Spec.NodeTerminationHandler
|
nth := b.Cluster.Spec.NodeTerminationHandler
|
||||||
if nth != nil && fi.BoolValue(nth.Enabled) && fi.BoolValue(nth.EnableSQSTerminationDraining) {
|
if nth != nil && fi.BoolValue(nth.Enabled) && fi.BoolValue(nth.EnableSQSTerminationDraining) {
|
||||||
labels[fi.StringValue(nth.ManagedASGTag)] = ""
|
labels[fi.StringValue(nth.ManagedASGTag)] = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply labels for cluster autoscaler node labels
|
// Apply labels for cluster autoscaler node labels
|
||||||
for k, v := range nodelabels.BuildNodeLabels(m.Cluster, ig) {
|
for k, v := range nodelabels.BuildNodeLabels(b.Cluster, ig) {
|
||||||
labels[nodeidentityaws.ClusterAutoscalerNodeTemplateLabel+k] = v
|
labels[nodeidentityaws.ClusterAutoscalerNodeTemplateLabel+k] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,10 +186,10 @@ func (m *KopsModelContext) CloudTagsForInstanceGroup(ig *kops.InstanceGroup) (ma
|
||||||
}
|
}
|
||||||
|
|
||||||
// CloudTags computes the tags to apply to a normal cloud resource with the specified name
|
// CloudTags computes the tags to apply to a normal cloud resource with the specified name
|
||||||
func (m *KopsModelContext) CloudTags(name string, shared bool) map[string]string {
|
func (b *KopsModelContext) CloudTags(name string, shared bool) map[string]string {
|
||||||
tags := make(map[string]string)
|
tags := make(map[string]string)
|
||||||
|
|
||||||
switch kops.CloudProviderID(m.Cluster.Spec.CloudProvider) {
|
switch kops.CloudProviderID(b.Cluster.Spec.CloudProvider) {
|
||||||
case kops.CloudProviderAWS:
|
case kops.CloudProviderAWS:
|
||||||
if shared {
|
if shared {
|
||||||
// If the resource is shared, we don't try to set the Name - we presume that is managed externally
|
// If the resource is shared, we don't try to set the Name - we presume that is managed externally
|
||||||
|
@ -209,14 +209,14 @@ func (m *KopsModelContext) CloudTags(name string, shared bool) map[string]string
|
||||||
setLegacyTag = false
|
setLegacyTag = false
|
||||||
}
|
}
|
||||||
if setLegacyTag {
|
if setLegacyTag {
|
||||||
tags[awsup.TagClusterName] = m.Cluster.ObjectMeta.Name
|
tags[awsup.TagClusterName] = b.Cluster.ObjectMeta.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
if shared {
|
if shared {
|
||||||
tags["kubernetes.io/cluster/"+m.Cluster.ObjectMeta.Name] = "shared"
|
tags["kubernetes.io/cluster/"+b.Cluster.ObjectMeta.Name] = "shared"
|
||||||
} else {
|
} else {
|
||||||
tags["kubernetes.io/cluster/"+m.Cluster.ObjectMeta.Name] = "owned"
|
tags["kubernetes.io/cluster/"+b.Cluster.ObjectMeta.Name] = "owned"
|
||||||
for k, v := range m.Cluster.Spec.CloudLabels {
|
for k, v := range b.Cluster.Spec.CloudLabels {
|
||||||
tags[k] = v
|
tags[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,30 +226,30 @@ func (m *KopsModelContext) CloudTags(name string, shared bool) map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseKopsControllerForNodeBootstrap checks if nodeup should use kops-controller to bootstrap.
|
// UseKopsControllerForNodeBootstrap checks if nodeup should use kops-controller to bootstrap.
|
||||||
func (m *KopsModelContext) UseKopsControllerForNodeBootstrap() bool {
|
func (b *KopsModelContext) UseKopsControllerForNodeBootstrap() bool {
|
||||||
return model.UseKopsControllerForNodeBootstrap(m.Cluster)
|
return model.UseKopsControllerForNodeBootstrap(b.Cluster)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseBootstrapTokens checks if bootstrap tokens are enabled
|
// UseBootstrapTokens checks if bootstrap tokens are enabled
|
||||||
func (m *KopsModelContext) UseBootstrapTokens() bool {
|
func (b *KopsModelContext) UseBootstrapTokens() bool {
|
||||||
if m.Cluster.Spec.KubeAPIServer == nil || m.UseKopsControllerForNodeBootstrap() {
|
if b.Cluster.Spec.KubeAPIServer == nil || b.UseKopsControllerForNodeBootstrap() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return fi.BoolValue(m.Cluster.Spec.KubeAPIServer.EnableBootstrapAuthToken)
|
return fi.BoolValue(b.Cluster.Spec.KubeAPIServer.EnableBootstrapAuthToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UsesBastionDns checks if we should use a specific name for the bastion dns
|
// UsesBastionDns checks if we should use a specific name for the bastion dns
|
||||||
func (m *KopsModelContext) UsesBastionDns() bool {
|
func (b *KopsModelContext) UsesBastionDns() bool {
|
||||||
if m.Cluster.Spec.Topology.Bastion != nil && m.Cluster.Spec.Topology.Bastion.BastionPublicName != "" {
|
if b.Cluster.Spec.Topology.Bastion != nil && b.Cluster.Spec.Topology.Bastion.BastionPublicName != "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// UsesSSHBastion checks if we have a Bastion in the cluster
|
// UsesSSHBastion checks if we have a Bastion in the cluster
|
||||||
func (m *KopsModelContext) UsesSSHBastion() bool {
|
func (b *KopsModelContext) UsesSSHBastion() bool {
|
||||||
for _, ig := range m.InstanceGroups {
|
for _, ig := range b.InstanceGroups {
|
||||||
if ig.Spec.Role == kops.InstanceGroupRoleBastion {
|
if ig.Spec.Role == kops.InstanceGroupRoleBastion {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -259,32 +259,32 @@ func (m *KopsModelContext) UsesSSHBastion() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLoadBalancerForAPI checks if we are using a load balancer for the kubeapi
|
// UseLoadBalancerForAPI checks if we are using a load balancer for the kubeapi
|
||||||
func (m *KopsModelContext) UseLoadBalancerForAPI() bool {
|
func (b *KopsModelContext) UseLoadBalancerForAPI() bool {
|
||||||
if m.Cluster.Spec.API == nil {
|
if b.Cluster.Spec.API == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return m.Cluster.Spec.API.LoadBalancer != nil
|
return b.Cluster.Spec.API.LoadBalancer != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseLoadBalancerForInternalAPI check if true then we will use the created loadbalancer for internal kubelet
|
// UseLoadBalancerForInternalAPI check if true then we will use the created loadbalancer for internal kubelet
|
||||||
// connections. The intention here is to make connections to apiserver more
|
// connections. The intention here is to make connections to apiserver more
|
||||||
// HA - see https://github.com/kubernetes/kops/issues/4252
|
// HA - see https://github.com/kubernetes/kops/issues/4252
|
||||||
func (m *KopsModelContext) UseLoadBalancerForInternalAPI() bool {
|
func (b *KopsModelContext) UseLoadBalancerForInternalAPI() bool {
|
||||||
return m.UseLoadBalancerForAPI() &&
|
return b.UseLoadBalancerForAPI() &&
|
||||||
m.Cluster.Spec.API.LoadBalancer.UseForInternalApi
|
b.Cluster.Spec.API.LoadBalancer.UseForInternalApi
|
||||||
}
|
}
|
||||||
|
|
||||||
// APILoadBalancerClass returns which type of load balancer to use for the api
|
// APILoadBalancerClass returns which type of load balancer to use for the api
|
||||||
func (m *KopsModelContext) APILoadBalancerClass() kops.LoadBalancerClass {
|
func (b *KopsModelContext) APILoadBalancerClass() kops.LoadBalancerClass {
|
||||||
if m.Cluster.Spec.API != nil && m.Cluster.Spec.API.LoadBalancer != nil {
|
if b.Cluster.Spec.API != nil && b.Cluster.Spec.API.LoadBalancer != nil {
|
||||||
return m.Cluster.Spec.API.LoadBalancer.Class
|
return b.Cluster.Spec.API.LoadBalancer.Class
|
||||||
}
|
}
|
||||||
return kops.LoadBalancerClassClassic
|
return kops.LoadBalancerClassClassic
|
||||||
}
|
}
|
||||||
|
|
||||||
// UsePrivateDNS checks if we are using private DNS
|
// UsePrivateDNS checks if we are using private DNS
|
||||||
func (m *KopsModelContext) UsePrivateDNS() bool {
|
func (b *KopsModelContext) UsePrivateDNS() bool {
|
||||||
topology := m.Cluster.Spec.Topology
|
topology := b.Cluster.Spec.Topology
|
||||||
if topology != nil && topology.DNS != nil {
|
if topology != nil && topology.DNS != nil {
|
||||||
switch topology.DNS.Type {
|
switch topology.DNS.Type {
|
||||||
case kops.DNSTypePublic:
|
case kops.DNSTypePublic:
|
||||||
|
@ -302,18 +302,18 @@ func (m *KopsModelContext) UsePrivateDNS() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseClassicLoadBalancer checks if we are using Classic LoadBalancer
|
// UseClassicLoadBalancer checks if we are using Classic LoadBalancer
|
||||||
func (m *KopsModelContext) UseClassicLoadBalancer() bool {
|
func (b *KopsModelContext) UseClassicLoadBalancer() bool {
|
||||||
return m.Cluster.Spec.API.LoadBalancer.Class == kops.LoadBalancerClassClassic
|
return b.Cluster.Spec.API.LoadBalancer.Class == kops.LoadBalancerClassClassic
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseNetworkLoadBalancer checks if we are using Network LoadBalancer
|
// UseNetworkLoadBalancer checks if we are using Network LoadBalancer
|
||||||
func (m *KopsModelContext) UseNetworkLoadBalancer() bool {
|
func (b *KopsModelContext) UseNetworkLoadBalancer() bool {
|
||||||
return m.Cluster.Spec.API.LoadBalancer.Class == kops.LoadBalancerClassNetwork
|
return b.Cluster.Spec.API.LoadBalancer.Class == kops.LoadBalancerClassNetwork
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseEtcdManager checks to see if etcd manager is enabled
|
// UseEtcdManager checks to see if etcd manager is enabled
|
||||||
func (c *KopsModelContext) UseEtcdManager() bool {
|
func (b *KopsModelContext) UseEtcdManager() bool {
|
||||||
for _, x := range c.Cluster.Spec.EtcdClusters {
|
for _, x := range b.Cluster.Spec.EtcdClusters {
|
||||||
if x.Provider == kops.EtcdProviderTypeManager {
|
if x.Provider == kops.EtcdProviderTypeManager {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -323,8 +323,8 @@ func (c *KopsModelContext) UseEtcdManager() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseEtcdTLS checks to see if etcd tls is enabled
|
// UseEtcdTLS checks to see if etcd tls is enabled
|
||||||
func (m *KopsModelContext) UseEtcdTLS() bool {
|
func (b *KopsModelContext) UseEtcdTLS() bool {
|
||||||
for _, x := range m.Cluster.Spec.EtcdClusters {
|
for _, x := range b.Cluster.Spec.EtcdClusters {
|
||||||
if x.EnableEtcdTLS {
|
if x.EnableEtcdTLS {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -335,16 +335,16 @@ func (m *KopsModelContext) UseEtcdTLS() bool {
|
||||||
|
|
||||||
// UseSSHKey returns true if SSHKeyName from the cluster spec is not set to an empty string (""). Setting SSHKeyName
|
// UseSSHKey returns true if SSHKeyName from the cluster spec is not set to an empty string (""). Setting SSHKeyName
|
||||||
// to an empty string indicates that an SSH key should not be set on instances.
|
// to an empty string indicates that an SSH key should not be set on instances.
|
||||||
func (m *KopsModelContext) UseSSHKey() bool {
|
func (b *KopsModelContext) UseSSHKey() bool {
|
||||||
sshKeyName := m.Cluster.Spec.SSHKeyName
|
sshKeyName := b.Cluster.Spec.SSHKeyName
|
||||||
return sshKeyName == nil || *sshKeyName != ""
|
return sshKeyName == nil || *sshKeyName != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// KubernetesVersion parses the semver version of kubernetes, from the cluster spec
|
// KubernetesVersion parses the semver version of kubernetes, from the cluster spec
|
||||||
func (m *KopsModelContext) KubernetesVersion() semver.Version {
|
func (b *KopsModelContext) KubernetesVersion() semver.Version {
|
||||||
// TODO: Remove copy-pasting c.f. https://github.com/kubernetes/kops/blob/master/pkg/model/components/context.go#L32
|
// TODO: Remove copy-pasting c.f. https://github.com/kubernetes/kops/blob/master/pkg/model/components/context.go#L32
|
||||||
|
|
||||||
kubernetesVersion := m.Cluster.Spec.KubernetesVersion
|
kubernetesVersion := b.Cluster.Spec.KubernetesVersion
|
||||||
|
|
||||||
if kubernetesVersion == "" {
|
if kubernetesVersion == "" {
|
||||||
klog.Fatalf("KubernetesVersion is required")
|
klog.Fatalf("KubernetesVersion is required")
|
||||||
|
@ -358,26 +358,26 @@ func (m *KopsModelContext) KubernetesVersion() semver.Version {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsKubernetesGTE checks if the kubernetes version is at least version, ignoring prereleases / patches
|
// IsKubernetesGTE checks if the kubernetes version is at least version, ignoring prereleases / patches
|
||||||
func (m *KopsModelContext) IsKubernetesGTE(version string) bool {
|
func (b *KopsModelContext) IsKubernetesGTE(version string) bool {
|
||||||
return util.IsKubernetesGTE(version, m.KubernetesVersion())
|
return util.IsKubernetesGTE(version, b.KubernetesVersion())
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsKubernetesLT checks if the kubernetes version is before the specified version, ignoring prereleases / patches
|
// IsKubernetesLT checks if the kubernetes version is before the specified version, ignoring prereleases / patches
|
||||||
func (m *KopsModelContext) IsKubernetesLT(version string) bool {
|
func (b *KopsModelContext) IsKubernetesLT(version string) bool {
|
||||||
return !m.IsKubernetesGTE(version)
|
return !b.IsKubernetesGTE(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WellKnownServiceIP returns a service ip with the service cidr
|
// WellKnownServiceIP returns a service ip with the service cidr
|
||||||
func (m *KopsModelContext) WellKnownServiceIP(id int) (net.IP, error) {
|
func (b *KopsModelContext) WellKnownServiceIP(id int) (net.IP, error) {
|
||||||
return components.WellKnownServiceIP(&m.Cluster.Spec, id)
|
return components.WellKnownServiceIP(&b.Cluster.Spec, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodePortRange returns the range of ports allocated to NodePorts
|
// NodePortRange returns the range of ports allocated to NodePorts
|
||||||
func (m *KopsModelContext) NodePortRange() (utilnet.PortRange, error) {
|
func (b *KopsModelContext) NodePortRange() (utilnet.PortRange, error) {
|
||||||
// defaultServiceNodePortRange is the default port range for NodePort services.
|
// defaultServiceNodePortRange is the default port range for NodePort services.
|
||||||
defaultServiceNodePortRange := utilnet.PortRange{Base: 30000, Size: 2768}
|
defaultServiceNodePortRange := utilnet.PortRange{Base: 30000, Size: 2768}
|
||||||
|
|
||||||
kubeApiServer := m.Cluster.Spec.KubeAPIServer
|
kubeApiServer := b.Cluster.Spec.KubeAPIServer
|
||||||
if kubeApiServer != nil && kubeApiServer.ServiceNodePortRange != "" {
|
if kubeApiServer != nil && kubeApiServer.ServiceNodePortRange != "" {
|
||||||
err := defaultServiceNodePortRange.Set(kubeApiServer.ServiceNodePortRange)
|
err := defaultServiceNodePortRange.Set(kubeApiServer.ServiceNodePortRange)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -389,6 +389,6 @@ func (m *KopsModelContext) NodePortRange() (utilnet.PortRange, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseServiceAccountIAM returns true if we are using service-account bound IAM roles.
|
// UseServiceAccountIAM returns true if we are using service-account bound IAM roles.
|
||||||
func (m *KopsModelContext) UseServiceAccountIAM() bool {
|
func (b *KopsModelContext) UseServiceAccountIAM() bool {
|
||||||
return featureflag.UseServiceAccountIAM.Enabled()
|
return featureflag.UseServiceAccountIAM.Enabled()
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,8 +86,8 @@ func (b *KopsModelContext) LinkToELBSecurityGroup(prefix string) *awstasks.Secur
|
||||||
// LBName32 will attempt to calculate a meaningful name for an ELB given a prefix
|
// LBName32 will attempt to calculate a meaningful name for an ELB given a prefix
|
||||||
// Will never return a string longer than 32 chars
|
// Will never return a string longer than 32 chars
|
||||||
// Note this is _not_ the primary identifier for the ELB - we use the Name tag for that.
|
// Note this is _not_ the primary identifier for the ELB - we use the Name tag for that.
|
||||||
func (m *KopsModelContext) LBName32(prefix string) string {
|
func (b *KopsModelContext) LBName32(prefix string) string {
|
||||||
return awsup.GetResourceName32(m.Cluster.ObjectMeta.Name, prefix)
|
return awsup.GetResourceName32(b.Cluster.ObjectMeta.Name, prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CLBName returns CLB name plus cluster name
|
// CLBName returns CLB name plus cluster name
|
||||||
|
@ -177,19 +177,19 @@ func (b *KopsModelContext) LinkToIAMInstanceProfile(ig *kops.InstanceGroup) (*aw
|
||||||
|
|
||||||
// SSHKeyName computes a unique SSH key name, combining the cluster name and the SSH public key fingerprint.
|
// SSHKeyName computes a unique SSH key name, combining the cluster name and the SSH public key fingerprint.
|
||||||
// If an SSH key name is provided in the cluster configuration, it will use that instead.
|
// If an SSH key name is provided in the cluster configuration, it will use that instead.
|
||||||
func (c *KopsModelContext) SSHKeyName() (string, error) {
|
func (b *KopsModelContext) SSHKeyName() (string, error) {
|
||||||
// use configured SSH key name if present
|
// use configured SSH key name if present
|
||||||
sshKeyName := c.Cluster.Spec.SSHKeyName
|
sshKeyName := b.Cluster.Spec.SSHKeyName
|
||||||
if sshKeyName != nil && *sshKeyName != "" {
|
if sshKeyName != nil && *sshKeyName != "" {
|
||||||
return *sshKeyName, nil
|
return *sshKeyName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
fingerprint, err := pki.ComputeOpenSSHKeyFingerprint(string(c.SSHPublicKeys[0]))
|
fingerprint, err := pki.ComputeOpenSSHKeyFingerprint(string(b.SSHPublicKeys[0]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
name := "kubernetes." + c.Cluster.ObjectMeta.Name + "-" + fingerprint
|
name := "kubernetes." + b.Cluster.ObjectMeta.Name + "-" + fingerprint
|
||||||
return name, nil
|
return name, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue