Skip to content

feat(sks): add --name option to kubeconfig command#843

Open
nhedger wants to merge 3 commits into
exoscale:masterfrom
nhedger:feat/kubeconfig-cluster-name
Open

feat(sks): add --name option to kubeconfig command#843
nhedger wants to merge 3 commits into
exoscale:masterfrom
nhedger:feat/kubeconfig-cluster-name

Conversation

@nhedger

@nhedger nhedger commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Note

Disclosure:

  • AI assistance was used to implement this feature
  • Manual review and testing was done

Description

This PR adds a -n|--name option to exo compute sks kubeconfig, allowing users to set a custom cluster and context name in the generated kubeconfig.

Why this matters

Currently, the cluster and context names are set to the cluster UUID, making kubeconfigs harder to distinguish when users manage multiple configurations.

Examples

Without --name

exo compute sks kubeconfig demo admin --zone de-fra-1

apiVersion: v1
clusters:
  - cluster:
      certificate-authority-data: <redacted>
      server: https://7fcf7a3d-da67-46e8-af25-858d1eaef682.sks-de-fra-1.exo.io:443
    name: 7fcf7a3d-da67-46e8-af25-858d1eaef682
contexts:
  - context:
      cluster: 7fcf7a3d-da67-46e8-af25-858d1eaef682
      user: admin
      
    name: 7fcf7a3d-da67-46e8-af25-858d1eaef682
current-context: 7fcf7a3d-da67-46e8-af25-858d1eaef682
kind: Config
preferences: {}
users:
  - name: admin
    user:
      client-certificate-data: <redacted>
      client-key-data: <redacted>

With --name

exo compute sks kubeconfig demo admin --zone de-fra-1 --name demo

apiVersion: v1
clusters:
    - cluster:
        certificate-authority-data: <redacted>
        server: https://7fcf7a3d-da67-46e8-af25-858d1eaef682.sks-de-fra-1.exo.io:443
      name: "demo"
contexts:
    - context:
        cluster: "demo"
        user: admin
      name: "demo"
current-context: "demo"
kind: Config
preferences: {}
users:
    - name: admin
      user:
        client-certificate-data: <redacted>
        client-key-data: <redacted>

Why you may NOT want to merge this

You may prefer to implement this API-side rather than having the CLI rewrite the kubeconfig locally. I do not think there is anything inherently wrong with the CLI-based approach, but if you want to offer the same capability in the portal, the API may be the better place for it.

That said, this PR could still be merged as-is, and the CLI-local rewriting could later be replaced by an API-backed implementation.

Checklist

(For exoscale contributors)

  • Changelog updated (under Unreleased block, and add the Pull Request #number for each bit you add to the CHANGELOG.md)
  • Testing

Testing

  • Automated tests as part of the implementation
  • Manual testing

Comment thread go.mod
golang.org/x/text v0.31.0
gopkg.in/h2non/gentleman.v2 v2.0.4
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added yaml.v3 as a direct dependency so we can cleanly generate double-quoted strings. Since it was already included transitively, I figured this was acceptable.

Comment on lines +115 to +118
if c.ExecCredential && c.Name != "" {
return fmt.Errorf("--name cannot be used with --exec-credential")
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being a bit defensive here, could also just ignore --name when using --exec-credential. I leave that to your appreciation.

@nhedger nhedger changed the title feat(sks): add name flag to kubeconfig command feat(sks): add --name option to kubeconfig command Jun 12, 2026
@nhedger nhedger marked this pull request as ready for review June 12, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant