mirror of https://github.com/kubernetes/kops.git
Always set cluster-id flag for Protokube
This commit is contained in:
parent
a700e1b771
commit
bb8bd5ae27
|
|
@ -156,6 +156,7 @@ func (t *ProtokubeBuilder) buildSystemdService() (*nodetasks.Service, error) {
|
|||
|
||||
// ProtokubeFlags are the flags for protokube
|
||||
type ProtokubeFlags struct {
|
||||
ClusterID *string `json:"clusterID,omitempty" flag:"cluster-id"`
|
||||
Channels []string `json:"channels,omitempty" flag:"channels"`
|
||||
Cloud *string `json:"cloud,omitempty" flag:"cloud"`
|
||||
Containerized *bool `json:"containerized,omitempty" flag:"containerized"`
|
||||
|
|
@ -195,6 +196,8 @@ func (t *ProtokubeBuilder) ProtokubeFlags(k8sVersion semver.Version) (*Protokube
|
|||
Master: b(t.IsMaster),
|
||||
}
|
||||
|
||||
f.ClusterID = fi.String(t.Cluster.ObjectMeta.Name)
|
||||
|
||||
zone := t.Cluster.Spec.DNSZone
|
||||
if zone != "" {
|
||||
if strings.Contains(zone, ".") {
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ definition: |
|
|||
Documentation=https://kops.sigs.k8s.io
|
||||
|
||||
[Service]
|
||||
ExecStart=/opt/kops/bin/protokube --bootstrap-master-node-labels=true --cloud=aws --containerized=false --dns-internal-suffix=.internal.minimal.example.com --dns=aws-route53 --master=true --node-name=master.hostname.invalid --remove-dns-names=etcd-master-us-test-1a.internal.minimal.example.com,etcd-events-master-us-test-1a.internal.minimal.example.com --v=4 --zone=*/Z1AFAKE1ZON3YO
|
||||
ExecStart=/opt/kops/bin/protokube --bootstrap-master-node-labels=true --cloud=aws --cluster-id=minimal.example.com --containerized=false --dns-internal-suffix=.internal.minimal.example.com --dns=aws-route53 --master=true --node-name=master.hostname.invalid --remove-dns-names=etcd-master-us-test-1a.internal.minimal.example.com,etcd-events-master-us-test-1a.internal.minimal.example.com --v=4 --zone=*/Z1AFAKE1ZON3YO
|
||||
EnvironmentFile=/etc/sysconfig/protokube
|
||||
Restart=always
|
||||
RestartSec=3s
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ func run() error {
|
|||
flag.BoolVar(&containerized, "containerized", containerized, "Set if we are running containerized.")
|
||||
flag.BoolVar(&master, "master", master, "Whether or not this node is a master")
|
||||
flag.StringVar(&cloud, "cloud", "aws", "CloudProvider we are using (aws,digitalocean,gce,openstack)")
|
||||
flag.StringVar(&clusterID, "cluster-id", clusterID, "Cluster ID")
|
||||
flag.StringVar(&clusterID, "cluster-id", clusterID, "Cluster ID for internal domain names")
|
||||
flag.StringVar(&dnsInternalSuffix, "dns-internal-suffix", dnsInternalSuffix, "DNS suffix for internal domain names")
|
||||
flags.IntVar(&dnsUpdateInterval, "dns-update-interval", 5, "Configure interval at which to update DNS records.")
|
||||
flag.StringVar(&flagChannels, "channels", flagChannels, "channels to install")
|
||||
|
|
@ -112,10 +112,6 @@ func run() error {
|
|||
volumes = awsVolumes
|
||||
internalIP = awsVolumes.InternalIP()
|
||||
|
||||
if clusterID == "" {
|
||||
clusterID = awsVolumes.ClusterID()
|
||||
}
|
||||
|
||||
} else if cloud == "digitalocean" {
|
||||
doVolumes, err := protokube.NewDOVolumes()
|
||||
if err != nil {
|
||||
|
|
@ -129,13 +125,6 @@ func run() error {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
if clusterID == "" {
|
||||
clusterID, err = protokube.GetClusterID()
|
||||
if err != nil {
|
||||
klog.Errorf("Error getting clusterid: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
} else if cloud == "gce" {
|
||||
gceVolumes, err := protokube.NewGCEVolumes()
|
||||
if err != nil {
|
||||
|
|
@ -146,9 +135,6 @@ func run() error {
|
|||
volumes = gceVolumes
|
||||
internalIP = gceVolumes.InternalIP()
|
||||
|
||||
if clusterID == "" {
|
||||
clusterID = gceVolumes.ClusterID()
|
||||
}
|
||||
} else if cloud == "openstack" {
|
||||
klog.Info("Initializing openstack volumes")
|
||||
osVolumes, err := protokube.NewOpenstackVolumes()
|
||||
|
|
@ -159,9 +145,6 @@ func run() error {
|
|||
volumes = osVolumes
|
||||
internalIP = osVolumes.InternalIP()
|
||||
|
||||
if clusterID == "" {
|
||||
clusterID = osVolumes.ClusterID()
|
||||
}
|
||||
} else if cloud == "azure" {
|
||||
klog.Info("Initializing Azure volumes")
|
||||
azureVolumes, err := protokube.NewAzureVolumes()
|
||||
|
|
@ -172,25 +155,20 @@ func run() error {
|
|||
volumes = azureVolumes
|
||||
internalIP = azureVolumes.InternalIP()
|
||||
|
||||
if clusterID == "" {
|
||||
clusterID = azureVolumes.ClusterID()
|
||||
}
|
||||
} else {
|
||||
klog.Errorf("Unknown cloud %q", cloud)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if clusterID == "" {
|
||||
return fmt.Errorf("cluster-id is required (cannot be determined from cloud)")
|
||||
}
|
||||
klog.Infof("cluster-id: %s", clusterID)
|
||||
|
||||
if internalIP == nil {
|
||||
klog.Errorf("Cannot determine internal IP")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if dnsInternalSuffix == "" {
|
||||
if clusterID == "" {
|
||||
return fmt.Errorf("cluster-id is required when dns-internal-suffix is not set")
|
||||
}
|
||||
// TODO: Maybe only master needs DNS?
|
||||
dnsInternalSuffix = ".internal." + clusterID
|
||||
klog.Infof("Setting dns-internal-suffix to %q", dnsInternalSuffix)
|
||||
|
|
|
|||
|
|
@ -100,10 +100,6 @@ func NewAWSVolumes() (*AWSVolumes, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
func (a *AWSVolumes) ClusterID() string {
|
||||
return a.clusterTag
|
||||
}
|
||||
|
||||
func (a *AWSVolumes) InternalIP() net.IP {
|
||||
return a.internalIP
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,11 +80,6 @@ func NewAzureVolumes() (*AzureVolumes, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
// ClusterID implements Volumes ClusterID.
|
||||
func (a *AzureVolumes) ClusterID() string {
|
||||
return a.clusterTag
|
||||
}
|
||||
|
||||
// InstanceID implements Volumes InstanceID.
|
||||
func (a *AzureVolumes) InstanceID() string {
|
||||
return a.instanceID
|
||||
|
|
|
|||
|
|
@ -67,11 +67,6 @@ func NewGCEVolumes() (*GCEVolumes, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
// ClusterID implements Volumes ClusterID
|
||||
func (a *GCEVolumes) ClusterID() string {
|
||||
return a.clusterName
|
||||
}
|
||||
|
||||
// Project returns the current GCE project
|
||||
func (a *GCEVolumes) Project() string {
|
||||
return a.project
|
||||
|
|
|
|||
|
|
@ -117,11 +117,6 @@ func NewOpenstackVolumes() (*OpenstackVolumes, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
// ClusterID implements Volumes ClusterID
|
||||
func (a *OpenstackVolumes) ClusterID() string {
|
||||
return a.meta.UserMeta.ClusterName
|
||||
}
|
||||
|
||||
// Project returns the current GCE project
|
||||
func (a *OpenstackVolumes) Project() string {
|
||||
return a.meta.ProjectID
|
||||
|
|
|
|||
Loading…
Reference in New Issue