Skip to content

Commit

Permalink
chore: remove ClusterID from user input (#169)
Browse files Browse the repository at this point in the history
* Pending changes exported from your codespace

* fixed test cases
  • Loading branch information
krkeshav authored Mar 11, 2024
1 parent ffc09e4 commit f31028b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion designs/aks-node-bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Note that this represents part of the external configuration surface / API, and
A small set of values that are (currently) required for bootstrap are auto-detected or computed:
* Kubernetes version is auto-detected from the cluster (though we will likely add a way to override it)
* CA bundle is obtained from TLS connection to kube-apiserver
* ClusterID is computed from the cluster endpoint FQDN (currently also customizable)
* ClusterID is computed from the cluster endpoint FQDN

### Computed values

Expand Down
7 changes: 2 additions & 5 deletions pkg/operator/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func (o *Options) AddFlags(fs *coreoptions.FlagSet) {
fs.StringVar(&o.ClusterName, "cluster-name", env.WithDefaultString("CLUSTER_NAME", ""), "[REQUIRED] The kubernetes cluster name for resource tags.")
fs.StringVar(&o.ClusterEndpoint, "cluster-endpoint", env.WithDefaultString("CLUSTER_ENDPOINT", ""), "[REQUIRED] The external kubernetes cluster endpoint for new nodes to connect with.")
fs.Float64Var(&o.VMMemoryOverheadPercent, "vm-memory-overhead-percent", env.WithDefaultFloat64("VM_MEMORY_OVERHEAD_PERCENT", 0.075), "The VM memory overhead as a percent that will be subtracted from the total memory for all instance types.")
fs.StringVar(&o.ClusterID, "cluster-id", env.WithDefaultString("CLUSTER_ID", ""), "The kubernetes cluster ID. If not specified, will be generated based on cluster endpoint.")
fs.StringVar(&o.KubeletClientTLSBootstrapToken, "kubelet-bootstrap-token", env.WithDefaultString("KUBELET_BOOTSTRAP_TOKEN", ""), "[REQUIRED] The bootstrap token for new nodes to join the cluster.")
fs.StringVar(&o.SSHPublicKey, "ssh-public-key", env.WithDefaultString("SSH_PUBLIC_KEY", ""), "[REQUIRED] VM SSH public key.")
fs.StringVar(&o.NetworkPlugin, "network-plugin", env.WithDefaultString("NETWORK_PLUGIN", "azure"), "The network plugin used by the cluster.")
Expand Down Expand Up @@ -113,10 +112,8 @@ func (o *Options) Parse(fs *coreoptions.FlagSet, args ...string) error {
return fmt.Errorf("validating options, %w", err)
}

// if ClusterID is not set, generate it from cluster endpoint
if o.ClusterID == "" {
o.ClusterID = getAKSClusterID(o.GetAPIServerName())
}
// ClusterID is generated from cluster endpoint
o.ClusterID = getAKSClusterID(o.GetAPIServerName())

return nil
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/operator/options/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ var _ = Describe("Options", func() {
Context("Env Vars", func() {
It("should correctly fallback to env vars when CLI flags aren't set", func() {
os.Setenv("CLUSTER_NAME", "env-cluster")
os.Setenv("CLUSTER_ENDPOINT", "https://env-cluster")
os.Setenv("CLUSTER_ENDPOINT", "https://environment-cluster-id-value-for-testing")
os.Setenv("VM_MEMORY_OVERHEAD_PERCENT", "0.3")
os.Setenv("CLUSTER_ID", "env-cluster-id")
os.Setenv("KUBELET_BOOTSTRAP_TOKEN", "env-bootstrap-token")
os.Setenv("SSH_PUBLIC_KEY", "env-ssh-public-key")
os.Setenv("NETWORK_PLUGIN", "env-network-plugin")
Expand All @@ -101,9 +100,9 @@ var _ = Describe("Options", func() {
Expect(err).ToNot(HaveOccurred())
expectOptionsEqual(opts, test.Options(test.OptionsFields{
ClusterName: lo.ToPtr("env-cluster"),
ClusterEndpoint: lo.ToPtr("https://env-cluster"),
ClusterEndpoint: lo.ToPtr("https://environment-cluster-id-value-for-testing"),
VMMemoryOverheadPercent: lo.ToPtr(0.3),
ClusterID: lo.ToPtr("env-cluster-id"),
ClusterID: lo.ToPtr("46593302"),
KubeletClientTLSBootstrapToken: lo.ToPtr("env-bootstrap-token"),
SSHPublicKey: lo.ToPtr("env-ssh-public-key"),
NetworkPlugin: lo.ToPtr("env-network-plugin"),
Expand Down

0 comments on commit f31028b

Please sign in to comment.