mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #49215 from rrati/aws-require-cluster-id
Automatic merge from submit-queue Make ClusterID required for AWS. **What this PR does / why we need it**: Makes ClusterID required for AWS and provides a flag to run in un-tagged mode fixes #48954 **Release note**: ```release-note A cluster using the AWS cloud provider will need to label existing nodes and resources with a ClusterID or the kube-controller-manager will not start. To run without a ClusterID pass --allow-untagged-cloud=true to the kube-controller-manager on startup. ```
This commit is contained in:
commit
e9ab489728
@ -71,6 +71,8 @@ func (s *CloudControllerManagerServer) AddFlags(fs *pflag.FlagSet) {
|
|||||||
fs.Var(componentconfig.IPVar{Val: &s.Address}, "address", "The IP address to serve on (set to 0.0.0.0 for all interfaces)")
|
fs.Var(componentconfig.IPVar{Val: &s.Address}, "address", "The IP address to serve on (set to 0.0.0.0 for all interfaces)")
|
||||||
fs.StringVar(&s.CloudProvider, "cloud-provider", s.CloudProvider, "The provider of cloud services. Cannot be empty.")
|
fs.StringVar(&s.CloudProvider, "cloud-provider", s.CloudProvider, "The provider of cloud services. Cannot be empty.")
|
||||||
fs.StringVar(&s.CloudConfigFile, "cloud-config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
|
fs.StringVar(&s.CloudConfigFile, "cloud-config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
|
||||||
|
fs.BoolVar(&s.AllowUntaggedCloud, "allow-untagged-cloud", false, "Allow the cluster to run without the cluster-id on cloud instances. This is a legacy mode of operation and a cluster-id will be required in the future.")
|
||||||
|
fs.MarkDeprecated("allow-untagged-cloud", "This flag is deprecated and will be removed in a future release. A cluster-id will be required on cloud instances")
|
||||||
fs.DurationVar(&s.MinResyncPeriod.Duration, "min-resync-period", s.MinResyncPeriod.Duration, "The resync period in reflectors will be random between MinResyncPeriod and 2*MinResyncPeriod")
|
fs.DurationVar(&s.MinResyncPeriod.Duration, "min-resync-period", s.MinResyncPeriod.Duration, "The resync period in reflectors will be random between MinResyncPeriod and 2*MinResyncPeriod")
|
||||||
fs.DurationVar(&s.NodeMonitorPeriod.Duration, "node-monitor-period", s.NodeMonitorPeriod.Duration,
|
fs.DurationVar(&s.NodeMonitorPeriod.Duration, "node-monitor-period", s.NodeMonitorPeriod.Duration,
|
||||||
"The period for syncing NodeStatus in NodeController.")
|
"The period for syncing NodeStatus in NodeController.")
|
||||||
|
@ -61,6 +61,14 @@ func main() {
|
|||||||
glog.Fatalf("Cloud provider could not be initialized: %v", err)
|
glog.Fatalf("Cloud provider could not be initialized: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cloud.HasClusterID() == false {
|
||||||
|
if s.AllowUntaggedCloud == true {
|
||||||
|
glog.Warning("detected a cluster without a ClusterID. A ClusterID will be required in the future. Please tag your cluster to avoid any future issues")
|
||||||
|
} else {
|
||||||
|
glog.Fatalf("no ClusterID Found. A ClusterID is required for the cloud provider to function properly. This check can be bypassed by setting the allow-untagged-cloud option")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := app.Run(s, cloud); err != nil {
|
if err := app.Run(s, cloud); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -411,6 +411,14 @@ func CreateControllerContext(s *options.CMServer, rootClientBuilder, clientBuild
|
|||||||
if cloud != nil {
|
if cloud != nil {
|
||||||
// Initialize the cloud provider with a reference to the clientBuilder
|
// Initialize the cloud provider with a reference to the clientBuilder
|
||||||
cloud.Initialize(rootClientBuilder)
|
cloud.Initialize(rootClientBuilder)
|
||||||
|
|
||||||
|
if cloud.HasClusterID() == false {
|
||||||
|
if s.AllowUntaggedCloud == true {
|
||||||
|
glog.Warning("detected a cluster without a ClusterID. A ClusterID will be required in the future. Please tag your cluster to avoid any future issues")
|
||||||
|
} else {
|
||||||
|
return ControllerContext{}, fmt.Errorf("no ClusterID Found. A ClusterID is required for the cloud provider to function properly. This check can be bypassed by setting the allow-untagged-cloud option")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := ControllerContext{
|
ctx := ControllerContext{
|
||||||
|
@ -134,6 +134,8 @@ func (s *CMServer) AddFlags(fs *pflag.FlagSet, allControllers []string, disabled
|
|||||||
fs.BoolVar(&s.UseServiceAccountCredentials, "use-service-account-credentials", s.UseServiceAccountCredentials, "If true, use individual service account credentials for each controller.")
|
fs.BoolVar(&s.UseServiceAccountCredentials, "use-service-account-credentials", s.UseServiceAccountCredentials, "If true, use individual service account credentials for each controller.")
|
||||||
fs.StringVar(&s.CloudProvider, "cloud-provider", s.CloudProvider, "The provider for cloud services. Empty string for no provider.")
|
fs.StringVar(&s.CloudProvider, "cloud-provider", s.CloudProvider, "The provider for cloud services. Empty string for no provider.")
|
||||||
fs.StringVar(&s.CloudConfigFile, "cloud-config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
|
fs.StringVar(&s.CloudConfigFile, "cloud-config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
|
||||||
|
fs.BoolVar(&s.AllowUntaggedCloud, "allow-untagged-cloud", false, "Allow the cluster to run without the cluster-id on cloud instances. This is a legacy mode of operation and a cluster-id will be required in the future.")
|
||||||
|
fs.MarkDeprecated("allow-untagged-cloud", "This flag is deprecated and will be removed in a future release. A cluster-id will be required on cloud instances")
|
||||||
fs.Int32Var(&s.ConcurrentEndpointSyncs, "concurrent-endpoint-syncs", s.ConcurrentEndpointSyncs, "The number of endpoint syncing operations that will be done concurrently. Larger number = faster endpoint updating, but more CPU (and network) load")
|
fs.Int32Var(&s.ConcurrentEndpointSyncs, "concurrent-endpoint-syncs", s.ConcurrentEndpointSyncs, "The number of endpoint syncing operations that will be done concurrently. Larger number = faster endpoint updating, but more CPU (and network) load")
|
||||||
fs.Int32Var(&s.ConcurrentServiceSyncs, "concurrent-service-syncs", s.ConcurrentServiceSyncs, "The number of services that are allowed to sync concurrently. Larger number = more responsive service management, but more CPU (and network) load")
|
fs.Int32Var(&s.ConcurrentServiceSyncs, "concurrent-service-syncs", s.ConcurrentServiceSyncs, "The number of services that are allowed to sync concurrently. Larger number = more responsive service management, but more CPU (and network) load")
|
||||||
fs.Int32Var(&s.ConcurrentRCSyncs, "concurrent_rc_syncs", s.ConcurrentRCSyncs, "The number of replication controllers that are allowed to sync concurrently. Larger number = more responsive replica management, but more CPU (and network) load")
|
fs.Int32Var(&s.ConcurrentRCSyncs, "concurrent_rc_syncs", s.ConcurrentRCSyncs, "The number of replication controllers that are allowed to sync concurrently. Larger number = more responsive replica management, but more CPU (and network) load")
|
||||||
|
@ -669,6 +669,8 @@ type KubeControllerManagerConfiguration struct {
|
|||||||
CloudProvider string
|
CloudProvider string
|
||||||
// cloudConfigFile is the path to the cloud provider configuration file.
|
// cloudConfigFile is the path to the cloud provider configuration file.
|
||||||
CloudConfigFile string
|
CloudConfigFile string
|
||||||
|
// run with untagged cloud instances
|
||||||
|
AllowUntaggedCloud bool
|
||||||
// concurrentEndpointSyncs is the number of endpoint syncing operations
|
// concurrentEndpointSyncs is the number of endpoint syncing operations
|
||||||
// that will be done concurrently. Larger number = faster endpoint updating,
|
// that will be done concurrently. Larger number = faster endpoint updating,
|
||||||
// but more CPU (and network) load.
|
// but more CPU (and network) load.
|
||||||
|
@ -45,6 +45,8 @@ type Interface interface {
|
|||||||
ProviderName() string
|
ProviderName() string
|
||||||
// ScrubDNS provides an opportunity for cloud-provider-specific code to process DNS settings for pods.
|
// ScrubDNS provides an opportunity for cloud-provider-specific code to process DNS settings for pods.
|
||||||
ScrubDNS(nameservers, searches []string) (nsOut, srchOut []string)
|
ScrubDNS(nameservers, searches []string) (nsOut, srchOut []string)
|
||||||
|
// HasClusterID returns true if a ClusterID is required and set
|
||||||
|
HasClusterID() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clusters is an abstract, pluggable interface for clusters of containers.
|
// Clusters is an abstract, pluggable interface for clusters of containers.
|
||||||
|
@ -971,6 +971,11 @@ func (c *Cloud) Routes() (cloudprovider.Routes, bool) {
|
|||||||
return c, true
|
return c, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasClusterID returns true if the cluster has a clusterID
|
||||||
|
func (c *Cloud) HasClusterID() bool {
|
||||||
|
return len(c.tagging.clusterID()) > 0
|
||||||
|
}
|
||||||
|
|
||||||
// NodeAddresses is an implementation of Instances.NodeAddresses.
|
// NodeAddresses is an implementation of Instances.NodeAddresses.
|
||||||
func (c *Cloud) NodeAddresses(name types.NodeName) ([]v1.NodeAddress, error) {
|
func (c *Cloud) NodeAddresses(name types.NodeName) ([]v1.NodeAddress, error) {
|
||||||
if c.selfAWSInstance.nodeName == name || len(name) == 0 {
|
if c.selfAWSInstance.nodeName == name || len(name) == 0 {
|
||||||
|
@ -276,3 +276,7 @@ func (t *awsTagging) buildTags(lifecycle ResourceLifecycle, additionalTags map[s
|
|||||||
|
|
||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *awsTagging) clusterID() string {
|
||||||
|
return t.ClusterID
|
||||||
|
}
|
||||||
|
@ -391,6 +391,11 @@ func (az *Cloud) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []stri
|
|||||||
return nameservers, searches
|
return nameservers, searches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasClusterID returns true if the cluster has a clusterID
|
||||||
|
func (az *Cloud) HasClusterID() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// ProviderName returns the cloud provider ID.
|
// ProviderName returns the cloud provider ID.
|
||||||
func (az *Cloud) ProviderName() string {
|
func (az *Cloud) ProviderName() string {
|
||||||
return CloudProviderName
|
return CloudProviderName
|
||||||
|
@ -120,6 +120,11 @@ func (cs *CSCloud) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []st
|
|||||||
return nameservers, searches
|
return nameservers, searches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasClusterID returns true if the cluster has a clusterID
|
||||||
|
func (cs *CSCloud) HasClusterID() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// GetZone returns the Zone containing the region that the program is running in.
|
// GetZone returns the Zone containing the region that the program is running in.
|
||||||
func (cs *CSCloud) GetZone() (cloudprovider.Zone, error) {
|
func (cs *CSCloud) GetZone() (cloudprovider.Zone, error) {
|
||||||
glog.V(2).Infof("Current zone is %v", cs.zone)
|
glog.V(2).Infof("Current zone is %v", cs.zone)
|
||||||
|
@ -111,6 +111,11 @@ func (f *FakeCloud) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []s
|
|||||||
return nameservers, searches
|
return nameservers, searches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasClusterID returns true if the cluster has a clusterID
|
||||||
|
func (f *FakeCloud) HasClusterID() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// LoadBalancer returns a fake implementation of LoadBalancer.
|
// LoadBalancer returns a fake implementation of LoadBalancer.
|
||||||
// Actually it just returns f itself.
|
// Actually it just returns f itself.
|
||||||
func (f *FakeCloud) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
|
func (f *FakeCloud) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
|
||||||
|
@ -469,6 +469,11 @@ func (gce *GCECloud) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []
|
|||||||
return nameservers, srchOut
|
return nameservers, srchOut
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasClusterID returns true if the cluster has a clusterID
|
||||||
|
func (gce *GCECloud) HasClusterID() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// GCECloud implements cloudprovider.Interface.
|
// GCECloud implements cloudprovider.Interface.
|
||||||
var _ cloudprovider.Interface = (*GCECloud)(nil)
|
var _ cloudprovider.Interface = (*GCECloud)(nil)
|
||||||
|
|
||||||
|
@ -458,6 +458,11 @@ func (os *OpenStack) ScrubDNS(nameServers, searches []string) ([]string, []strin
|
|||||||
return nameServers, searches
|
return nameServers, searches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasClusterID returns true if the cluster has a clusterID
|
||||||
|
func (os *OpenStack) HasClusterID() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (os *OpenStack) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
|
func (os *OpenStack) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
|
||||||
glog.V(4).Info("openstack.LoadBalancer() called")
|
glog.V(4).Info("openstack.LoadBalancer() called")
|
||||||
|
|
||||||
|
@ -134,6 +134,11 @@ func (v *OVirtCloud) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []
|
|||||||
return nameservers, searches
|
return nameservers, searches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasClusterID returns true if the cluster has a clusterID
|
||||||
|
func (v *OVirtCloud) HasClusterID() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// LoadBalancer returns an implementation of LoadBalancer for oVirt cloud
|
// LoadBalancer returns an implementation of LoadBalancer for oVirt cloud
|
||||||
func (v *OVirtCloud) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
|
func (v *OVirtCloud) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
|
||||||
return nil, false
|
return nil, false
|
||||||
|
@ -539,6 +539,11 @@ func (pc *PCCloud) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []st
|
|||||||
return nameservers, searches
|
return nameservers, searches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasClusterID returns true if the cluster has a clusterID
|
||||||
|
func (pc *PCCloud) HasClusterID() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Attaches given virtual disk volume to the compute running kubelet.
|
// Attaches given virtual disk volume to the compute running kubelet.
|
||||||
func (pc *PCCloud) AttachDisk(pdID string, nodeName k8stypes.NodeName) error {
|
func (pc *PCCloud) AttachDisk(pdID string, nodeName k8stypes.NodeName) error {
|
||||||
photonClient, err := getPhotonClient(pc)
|
photonClient, err := getPhotonClient(pc)
|
||||||
|
@ -529,6 +529,11 @@ func (os *Rackspace) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []
|
|||||||
return nameservers, searches
|
return nameservers, searches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasClusterID returns true if the cluster has a clusterID
|
||||||
|
func (os *Rackspace) HasClusterID() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (os *Rackspace) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
|
func (os *Rackspace) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
@ -747,3 +747,8 @@ func (vs *VSphere) DeleteVolume(vmDiskPath string) error {
|
|||||||
vclib.RecordvSphereMetric(vclib.OperationDeleteVolume, requestTime, err)
|
vclib.RecordvSphereMetric(vclib.OperationDeleteVolume, requestTime, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasClusterID returns true if the cluster has a clusterID
|
||||||
|
func (vs *VSphere) HasClusterID() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user