mirror of https://github.com/kubernetes/kops.git
Refactor UsesExternalECRCredentialsProvider()
This commit is contained in:
parent
aef6fbdd29
commit
a56e8eb049
|
|
@ -402,6 +402,10 @@ func (c *NodeupModelContext) UseChallengeCallback(cloudProvider kops.CloudProvid
|
||||||
return model.UseChallengeCallback(cloudProvider)
|
return model.UseChallengeCallback(cloudProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *NodeupModelContext) UseExternalECRCredentialsProvider() bool {
|
||||||
|
return model.UseExternalECRCredentialsProvider(c.kubernetesVersion, c.CloudProvider())
|
||||||
|
}
|
||||||
|
|
||||||
// UsesSecondaryIP checks if the CNI in use attaches secondary interfaces to the host.
|
// UsesSecondaryIP checks if the CNI in use attaches secondary interfaces to the host.
|
||||||
func (c *NodeupModelContext) UsesSecondaryIP() bool {
|
func (c *NodeupModelContext) UsesSecondaryIP() bool {
|
||||||
return (c.NodeupConfig.Networking.CNI != nil && c.NodeupConfig.Networking.CNI.UsesSecondaryIP) ||
|
return (c.NodeupConfig.Networking.CNI != nil && c.NodeupConfig.Networking.CNI.UsesSecondaryIP) ||
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ func (b *KubeletBuilder) Build(c *fi.NodeupModelBuilderContext) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.Cluster.UsesExternalECRCredentialsProvider() {
|
if b.UseExternalECRCredentialsProvider() {
|
||||||
if err := b.addECRCP(c); err != nil {
|
if err := b.addECRCP(c); err != nil {
|
||||||
return fmt.Errorf("failed to add ECR credential provider: %w", err)
|
return fmt.Errorf("failed to add ECR credential provider: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -346,7 +346,7 @@ func (b *KubeletBuilder) buildSystemdEnvironmentFile(kubeletConfig *kops.Kubelet
|
||||||
|
|
||||||
flags += " --config=" + kubeletConfigFilePath
|
flags += " --config=" + kubeletConfigFilePath
|
||||||
|
|
||||||
if b.Cluster.UsesExternalECRCredentialsProvider() {
|
if b.UseExternalECRCredentialsProvider() {
|
||||||
flags += " --image-credential-provider-config=" + credentialProviderConfigFilePath
|
flags += " --image-credential-provider-config=" + credentialProviderConfigFilePath
|
||||||
flags += " --image-credential-provider-bin-dir=" + b.binaryPath()
|
flags += " --image-credential-provider-bin-dir=" + b.binaryPath()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -909,10 +909,6 @@ func (c *Cluster) UsesNoneDNS() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) UsesExternalECRCredentialsProvider() bool {
|
|
||||||
return c.IsKubernetesGTE("1.27") && c.Spec.GetCloudProvider() == CloudProviderAWS
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Cluster) APIInternalName() string {
|
func (c *Cluster) APIInternalName() string {
|
||||||
return "api.internal." + c.ObjectMeta.Name
|
return "api.internal." + c.ObjectMeta.Name
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ limitations under the License.
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/blang/semver/v4"
|
||||||
"k8s.io/kops/pkg/apis/kops"
|
"k8s.io/kops/pkg/apis/kops"
|
||||||
|
"k8s.io/kops/pkg/apis/kops/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UseKopsControllerForNodeBootstrap is true if nodeup should use kops-controller for bootstrapping.
|
// UseKopsControllerForNodeBootstrap is true if nodeup should use kops-controller for bootstrapping.
|
||||||
|
|
@ -69,3 +71,7 @@ func UseCiliumEtcd(cluster *kops.Cluster) bool {
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UseExternalECRCredentialsProvider(k8sVersion semver.Version, cloudProvider kops.CloudProviderID) bool {
|
||||||
|
return util.IsKubernetesGTE("1.27", k8sVersion) && cloudProvider == kops.CloudProviderAWS
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1054,7 +1054,8 @@ func (c *ApplyClusterCmd) addFileAssets(assetBuilder *assets.AssetBuilder) error
|
||||||
c.Assets[arch] = append(c.Assets[arch], mirrors.BuildMirroredAsset(u, hash))
|
c.Assets[arch] = append(c.Assets[arch], mirrors.BuildMirroredAsset(u, hash))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Cluster.UsesExternalECRCredentialsProvider() {
|
kubernetesVersion, _ := util.ParseKubernetesVersion(c.Cluster.Spec.KubernetesVersion)
|
||||||
|
if apiModel.UseExternalECRCredentialsProvider(*kubernetesVersion, c.Cluster.Spec.GetCloudProvider()) {
|
||||||
binaryLocation := c.Cluster.Spec.CloudProvider.AWS.BinariesLocation
|
binaryLocation := c.Cluster.Spec.CloudProvider.AWS.BinariesLocation
|
||||||
if binaryLocation == nil {
|
if binaryLocation == nil {
|
||||||
binaryLocation = fi.PtrTo("https://artifacts.k8s.io/binaries/cloud-provider-aws/v1.27.1")
|
binaryLocation = fi.PtrTo("https://artifacts.k8s.io/binaries/cloud-provider-aws/v1.27.1")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue