Skip to content

Commit b00fdd1

Browse files
authored
Merge pull request #17506 from hakman/azure-test
azure: Use `kops` as the default admin user
2 parents 8e83ad6 + d08c94e commit b00fdd1

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

nodeup/pkg/model/kubectl.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,16 @@ func (b *KubectlBuilder) Build(c *fi.NodeupModelBuilderContext) error {
103103

104104
// findKubeconfigUser finds the default user for whom we should create a kubeconfig
105105
func (b *KubectlBuilder) findKubeconfigUser() (*fi.User, *fi.Group, error) {
106-
users, err := b.Distribution.DefaultUsers()
107-
if err != nil {
108-
klog.Warningf("won't write kubeconfig to homedir for distribution %v: %v", b.Distribution, err)
109-
return nil, nil, nil
106+
var users []string
107+
if b.RunningOnAzure() {
108+
users = append(users, b.NodeupConfig.AzureAdminUser)
109+
} else {
110+
defaultUsers, err := b.Distribution.DefaultUsers()
111+
if err != nil {
112+
klog.Warningf("won't write kubeconfig to homedir for distribution %v: %v", b.Distribution, err)
113+
return nil, nil, nil
114+
}
115+
users = append(users, defaultUsers...)
110116
}
111117

112118
for _, s := range users {

pkg/apis/nodeup/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ type Config struct {
118118
WarmPoolImages []string `json:"warmPoolImages,omitempty"`
119119

120120
// Azure-specific
121+
// AzureAdminUser is the admin user of VMs.
122+
AzureAdminUser string `json:",omitempty"`
121123
// AzureLocation is the location of the resource group that the cluster is deployed in.
122124
AzureLocation string `json:",omitempty"`
123125
// 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
280282
config.AzureResourceGroup = cluster.AzureResourceGroupName()
281283
config.AzureRouteTableName = cluster.AzureRouteTableName()
282284
config.Networking.NetworkID = cluster.Spec.Networking.NetworkID
285+
config.AzureAdminUser = cluster.Spec.CloudProvider.Azure.AdminUser
283286
}
284287

285288
if cluster.Spec.CloudProvider.GCE != nil {

tests/e2e/kubetest2-kops/deployer/common.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ func (d *deployer) initialize() error {
8080
}
8181
d.SSHPublicKeyPath = publicKeyPath
8282
d.SSHPrivateKeyPath = privateKeyPath
83-
// TODO: Check if we can use "kops" as SSH user
84-
d.SSHUser = "ubuntu"
83+
d.SSHUser = "kops"
8584
case "digitalocean":
8685
if d.SSHPrivateKeyPath == "" {
8786
d.SSHPrivateKeyPath = os.Getenv("DO_SSH_PRIVATE_KEY_FILE")

tests/e2e/kubetest2-kops/deployer/up.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ func (d *deployer) createCluster(zones []string, adminAccess string, yes bool) e
195195
args = appendIfUnset(args, "--cloud-labels", "DO-NOT-DELETE=kOps")
196196
args = appendIfUnset(args, "--control-plane-size", "Standard_D4s_v3")
197197
args = appendIfUnset(args, "--node-size", "Standard_D2s_v3")
198-
// TODO: Check if we can use "kops" as SSH user
199-
args = appendIfUnset(args, "--azure-admin-user", "ubuntu")
200198
case "gce":
201199
if isArm {
202200
args = appendIfUnset(args, "--master-size", "t2a-standard-2")

upup/pkg/fi/cloudup/new_cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ func (o *NewClusterOptions) InitDefaults() {
176176
o.EtcdClusters = []string{"main", "events"}
177177
o.Networking = "cilium"
178178
o.InstanceManager = "cloudgroups"
179+
180+
// Azure-specific
181+
o.AzureAdminUser = "kops"
179182
}
180183

181184
type NewClusterResult struct {

0 commit comments

Comments
 (0)