mirror of https://github.com/kubernetes/kops.git
azure: Use `kops` as the default admin user
This commit is contained in:
parent
8e83ad6dcd
commit
d08c94e54e
|
@ -103,10 +103,16 @@ func (b *KubectlBuilder) Build(c *fi.NodeupModelBuilderContext) error {
|
||||||
|
|
||||||
// findKubeconfigUser finds the default user for whom we should create a kubeconfig
|
// findKubeconfigUser finds the default user for whom we should create a kubeconfig
|
||||||
func (b *KubectlBuilder) findKubeconfigUser() (*fi.User, *fi.Group, error) {
|
func (b *KubectlBuilder) findKubeconfigUser() (*fi.User, *fi.Group, error) {
|
||||||
users, err := b.Distribution.DefaultUsers()
|
var users []string
|
||||||
if err != nil {
|
if b.RunningOnAzure() {
|
||||||
klog.Warningf("won't write kubeconfig to homedir for distribution %v: %v", b.Distribution, err)
|
users = append(users, b.NodeupConfig.AzureAdminUser)
|
||||||
return nil, nil, nil
|
} else {
|
||||||
|
defaultUsers, err := b.Distribution.DefaultUsers()
|
||||||
|
if err != nil {
|
||||||
|
klog.Warningf("won't write kubeconfig to homedir for distribution %v: %v", b.Distribution, err)
|
||||||
|
return nil, nil, nil
|
||||||
|
}
|
||||||
|
users = append(users, defaultUsers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range users {
|
for _, s := range users {
|
||||||
|
|
|
@ -118,6 +118,8 @@ type Config struct {
|
||||||
WarmPoolImages []string `json:"warmPoolImages,omitempty"`
|
WarmPoolImages []string `json:"warmPoolImages,omitempty"`
|
||||||
|
|
||||||
// Azure-specific
|
// Azure-specific
|
||||||
|
// AzureAdminUser is the admin user of VMs.
|
||||||
|
AzureAdminUser string `json:",omitempty"`
|
||||||
// AzureLocation is the location of the resource group that the cluster is deployed in.
|
// AzureLocation is the location of the resource group that the cluster is deployed in.
|
||||||
AzureLocation string `json:",omitempty"`
|
AzureLocation string `json:",omitempty"`
|
||||||
// AzureSubscriptionID is the ID of the Azure Subscription that the cluster is deployed in.
|
// AzureSubscriptionID is the ID of the Azure Subscription that the cluster is deployed in.
|
||||||
|
@ -280,6 +282,7 @@ func NewConfig(cluster *kops.Cluster, instanceGroup *kops.InstanceGroup) (*Confi
|
||||||
config.AzureResourceGroup = cluster.AzureResourceGroupName()
|
config.AzureResourceGroup = cluster.AzureResourceGroupName()
|
||||||
config.AzureRouteTableName = cluster.AzureRouteTableName()
|
config.AzureRouteTableName = cluster.AzureRouteTableName()
|
||||||
config.Networking.NetworkID = cluster.Spec.Networking.NetworkID
|
config.Networking.NetworkID = cluster.Spec.Networking.NetworkID
|
||||||
|
config.AzureAdminUser = cluster.Spec.CloudProvider.Azure.AdminUser
|
||||||
}
|
}
|
||||||
|
|
||||||
if cluster.Spec.CloudProvider.GCE != nil {
|
if cluster.Spec.CloudProvider.GCE != nil {
|
||||||
|
|
|
@ -80,8 +80,7 @@ func (d *deployer) initialize() error {
|
||||||
}
|
}
|
||||||
d.SSHPublicKeyPath = publicKeyPath
|
d.SSHPublicKeyPath = publicKeyPath
|
||||||
d.SSHPrivateKeyPath = privateKeyPath
|
d.SSHPrivateKeyPath = privateKeyPath
|
||||||
// TODO: Check if we can use "kops" as SSH user
|
d.SSHUser = "kops"
|
||||||
d.SSHUser = "ubuntu"
|
|
||||||
case "digitalocean":
|
case "digitalocean":
|
||||||
if d.SSHPrivateKeyPath == "" {
|
if d.SSHPrivateKeyPath == "" {
|
||||||
d.SSHPrivateKeyPath = os.Getenv("DO_SSH_PRIVATE_KEY_FILE")
|
d.SSHPrivateKeyPath = os.Getenv("DO_SSH_PRIVATE_KEY_FILE")
|
||||||
|
|
|
@ -195,8 +195,6 @@ func (d *deployer) createCluster(zones []string, adminAccess string, yes bool) e
|
||||||
args = appendIfUnset(args, "--cloud-labels", "DO-NOT-DELETE=kOps")
|
args = appendIfUnset(args, "--cloud-labels", "DO-NOT-DELETE=kOps")
|
||||||
args = appendIfUnset(args, "--control-plane-size", "Standard_D4s_v3")
|
args = appendIfUnset(args, "--control-plane-size", "Standard_D4s_v3")
|
||||||
args = appendIfUnset(args, "--node-size", "Standard_D2s_v3")
|
args = appendIfUnset(args, "--node-size", "Standard_D2s_v3")
|
||||||
// TODO: Check if we can use "kops" as SSH user
|
|
||||||
args = appendIfUnset(args, "--azure-admin-user", "ubuntu")
|
|
||||||
case "gce":
|
case "gce":
|
||||||
if isArm {
|
if isArm {
|
||||||
args = appendIfUnset(args, "--master-size", "t2a-standard-2")
|
args = appendIfUnset(args, "--master-size", "t2a-standard-2")
|
||||||
|
|
|
@ -176,6 +176,9 @@ func (o *NewClusterOptions) InitDefaults() {
|
||||||
o.EtcdClusters = []string{"main", "events"}
|
o.EtcdClusters = []string{"main", "events"}
|
||||||
o.Networking = "cilium"
|
o.Networking = "cilium"
|
||||||
o.InstanceManager = "cloudgroups"
|
o.InstanceManager = "cloudgroups"
|
||||||
|
|
||||||
|
// Azure-specific
|
||||||
|
o.AzureAdminUser = "kops"
|
||||||
}
|
}
|
||||||
|
|
||||||
type NewClusterResult struct {
|
type NewClusterResult struct {
|
||||||
|
|
Loading…
Reference in New Issue